Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21230

Calling cdecl DLL with vbRichClient5

$
0
0
Hello.
I have a "test.dll" and it declares functions in cdecl. Knowing that vbRichClient5 can call these functions, I tried to call some functions and it succeeded.
However, there's a function I can't do so. Here's the code in a header:

Code:

__cdecl __declspec(dllimport) int16_t fileput(void *handle, const char *localpath, const char *remotepath);
And in VB6, I wrote like this:
Code:

Public Function FilePut(ByVal Handle as Long, ByVal LocalPath as String, ByVal RemotePath as String) as Integer
'libHandle = LoadLibrary("test.dll")
'Set Con as New cConstructor
Dim pFunc as Long
pFunc = GetProcAddress(libHandle, "fileput")
Debug.Assert pFunc

Dim ret as Integer
Dim tmpLocalPath as String * 255, tmpRemotePath as String * 255
tmpLocalPath = StrConv(LocalPath, vbFromUnicode)
tmpRemotePath = StrConv(RemotePath, vbFromUnicode)
ret = Con.cdeclCall(retInteger, pFunc, Handle, tmpLocalPath, tmpRemotePath)
Debug.Assert ret >= 0

FilePut = ret
End Function

It returns "Invalid argument". But I tried in another language with the same arguments and it succeeded. Can anyone figure out what goes wrong?

Thanks.

Viewing all articles
Browse latest Browse all 21230

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>