Calling a DLL Function - Windows Server 2003
I am trying to call a function in one DLL from another DLL. The code works
fine on workstations but is failing when the same call is made on the server.
I'll try to give as much info as I can without including irrelevant code,
but please ask if there is anything I've left out.
Each DLL was compiled separately using Visual C++ 6.0.
ABTest.dll is written in C++. The other DLL is written in C.
Exported function from ABTest.dll: ?fnABTest@@YAHPAH00@Z
ABTest.dll takes three pointers to integers. It adds the first two integers
and returns the sum as the third parameter.
Code from other DLL:
typedef void (*PFNDLL)(int *, int *, int *);
HMODULE hLibrary;
PFNDLL lpfndllTemplate = (PFNDLL)NULL;
int a = 0;
int b = 0;
int result = 0;
if((hLibrary = LoadLibrary(_J("ABTest.dll")))==(HINSTANCE)NULL)
{
return(ER_ERROR);
}
if ((lpfndllTemplate= (PFNDLL)GetProcAddress(hLibrary,
_J("?fnABTest@@YAHPAH00@Z"))) == (PFNDLL)NULL)
{
return(ER_ERROR);
}
a = 5;
b = 11;
jdeSprintf (szBuffer,_J("a = %d, b = %d, result = %d"), a, b, result);
jdeWriteLog (_J("Before Values"), 0, szBuffer);
lpfndllTemplate (&a, &b, &result);
jdeSprintf (szBuffer,_J("a = %d, b = %d, result = %d"), a, b, result);
jdeWriteLog (_J("After Values"), 0, szBuffer);
*** END OF RELEVANT CODE ***
Results I get on a client in the log file are:
Before call: a = 5, b = 11, result = 0
After call: a = 5, b = 11, result = 16
Results I get on the server in the log file are:
Before call: a = 5, b = 11, result = 0
After call: a = 43663208, b = 0, result = 2198820
A couple of important notes here:
1. The calling DLL is from within an ERP system (JDE OneWorld), so type
HMODULE and "jdeSprintf", "jdeWriteLog" are defined and not likely causing
the issue. Also, "_J()" is a function that is defined to convert to unicode.
2. When called from a client running on a Windows Server 2003 using Citrix,
the results match a client workstation.
3. I have also tried:
typedef void (WINAPI *PFNDLL)(int *, int *, int *);
(*lpfndllTemplate) (&a, &b, &result);
Not sure what the difference is, if any, but the results are the same with
either call.
4. I am forced by the ERP system to use VC 6.0 and that the calling DLL be
written in C, not C++.
Can anyone provide any suggestions as to why I am getting the results I am
getting and possibly what I can do to correct it?
If there is any other information I can provide, please tell me and I will
post it.
Thank you all for your help!