quote:
Originally posted by raceprouk
I believe all the functions in the Win32 API use __cdecl, but VB can still use them
No, the Windows API use __stdcall, that's why VB can use them.
quote:
Originally posted by raceprouk
Typical VB API access declaration:
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
'Template':
Private Declare Function <functionname> Lib "<filename>.dll" Alias "<funcnamefromdll>" (<arglist>) As <returntype>
yes, I know
I have several years of experience in calling APIs from VB
quote:
Originally posted by raceprouk
EDIT: Tell you what, you post the function header from your DLL, and I'll see if I can come up with a VB declaration statement to allow you to use it.
the problem is not that i don't know who to declare it in VB... anyway, if you're happier with this
:
the VC++ DLL (traductor.dll) exports this function:
code:
int __cdecl TRADUCIR(const char *p_fichero_iso,const char *p_fichero_mac,const char *p_fichero_mec)
in VB i have this declaration:
code:
Public Declare Function TRADUCIR Lib "traductor.dll" (ByVal iso As Long, ByVal mac As Long, ByVal mec As Long) As Long
and when I try to call it from VB it says wrong call convention
(logic)
well, I've solved that doing this (however I'm still interested if vb can call __cdelc functions or how would be done if I couldn't modify the dll code) :
in VC++, add and export this function
code:
int __stdcall TRADUCIR__stdcall(const char *p_fichero_iso,const char *p_fichero_mac,const char *p_fichero_mec) {
return TRADUCIR(p_fichero_iso,p_fichero_mac,p_fichero_mec);
}
and in VB change the declaration by this one:
code:
Public Declare Function TRADUCIR Lib "traductor.dll" Alias "TRADUCIR__stdcall" (ByVal iso As Long, ByVal mac As Long, ByVal mec As Long) As Long