[color=#FF0000]EDIT: Problem solved.[/color] It turns out that this method is better for calling a DLL function:
[DllImport(“K8055D.dll”, EntryPoint = “OpenDevice”)]
extern “C” long openDI(long nr);
Thanks
I am not calling the functions directly from the K8055D.DLL but through another dll (which is a hassle, but this is the only way it has to be in my project).
In the other dll (capldll.dll) I’ve written:
typedef long (*t_open)(long);
void CAPLEXPORT far CAPLPASCAL opencard(long CardAddress)
{
t_open func;
HINSTANCE hDLL = LoadLibrary (“K8055D.DLL”);
func = (t_open)GetProcAddress(hDLL, “OpenDevice”);
func(CardAddress);
FreeLibrary (hDLL);
// I’m omitting the return value here since this call works OK
}
void CAPLEXPORT far CAPLPASCAL setdigi(void)
{
FARPROC setall;
HINSTANCE hDLL = LoadLibrary (“K8055D.DLL”);
setall = GetProcAddress(hDLL, “SetAllDigital”);
setall();
FreeLibrary (hDLL);
}
All the return values of the calls OpenDevice and SetAllDigital are OK, the local variables do get the addresses of both of the functions I want to call.
Then I complied this capldll.dll file and add it to my project. But when i call the functions opencard and setdigi in my project I don’t see any lit LED.
Can someone please explain this? Thanks so much in advance
Hieu Nguyen