Hi. I'm using vbAdvance for Visual Basic 6.0, and that's how I'm compiling my DLL - it took me a while, but I managed to get everything exporting properly, and I think my code is fine - but I'm having a bit of trouble with some of my string functions...
Please take a look at my MExportedFunctions.bas, and tell me what's wrong. I know there's other Winsock DLLs out there, but i just wanted to make my own suited for my needs...
Thanks again...
Option Explicit
Dim cUDP As New cUDPWinsock
Private Declare Function lstrlen Lib "kernel32.dll" Alias "lstrlenA" (ByVal lpString As Long) As Long
Private Declare Function SysAllocStringByteLen Lib "oleaut32.dll" (ByVal m_pBase As Long, ByRef FunctionCall As Long) As String
Public Function DllMain(ByVal hinstDLL As Long, ByVal fdwReason As Long, ByVal lpvReserved As Long) As Long
Const DLL_PROCESS_ATTACH As Long = 1
If fdwReason = DLL_PROCESS_ATTACH Then
'Initialize the VB Runtime when this DLL is first
'loaded by a process:
RuntimeInitialize hinstDLL
'Must return TRUE for success:
DllMain = 1
End If
End Function
'//Required for receiving and returning Strings/////////////
Private Function ConvInputStr(strX As Long) As String
ConvInputStr = StrConv(SysAllocStringByteLen(strX, lstrlen(strX)), vbUnicode)
End Function
Private Function ConvOutputStr(strX As String) As String
ConvOutputStr = StrConv(strX, vbFromUnicode)
End Function
'////////////////////////////////////////////////////////////
Function GimmeIP() As String
GimmeIP = ConvOutputStr(cUDP.GetMyIP)
End Function
Sub KillWinsock()
cUDP.CloseSocket
End Sub
Sub SetSocketPorts(localPort As Integer, remotePort As Integer)
cUDP.SetPorts localPort, remotePort
End Sub
Function GetData() As String
GetData = ConvOutputStr(cUDP.GetIt())
End Function
Sub SendData(RemoteName As Long, DataToSend As Long)
cUDP.Send ConvInputStr(RemoteName), ConvInputStr(DataToSend)
End Sub
Note: cUDP is my code. Nothing wrong with it.
When I run this code, I can't use the 'SendData' function - I get a 'failed to execute call DLL' error or something of a similar kind..
2005 - Year of cartoony red cubes (look! black outline!), for me at least.