raymondwee
asked on
Writing Main Program to test dll
I need a short Main program written in BC5 to test out my dll.
Dll complied using MFC, VC++6.
dll function -
extern "C" int Testing(void);
return value is the status of Testing function.
I have tried using _import and loadlibrary. But can't seems to work.
Dll complied using MFC, VC++6.
dll function -
extern "C" int Testing(void);
return value is the status of Testing function.
I have tried using _import and loadlibrary. But can't seems to work.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
a program to test this would look like...
void main()
{
HANDLE hLib=LoadLibrary("MyLib.DL L");
if(hLib)
{
FARPROC fProc=GetProcAddress(hLib, "Testing") ;
if(fProc)
{
// successfully got proc address
}
}
}
void main()
{
HANDLE hLib=LoadLibrary("MyLib.DL
if(hLib)
{
FARPROC fProc=GetProcAddress(hLib,
if(fProc)
{
// successfully got proc address
}
}
}
ASKER
Adjusted points from 30 to 50
ASKER
Thanks.
I have added those codes you mentioned.
but I can't get the address of the Function.(dll)
I have just changed my dll function to
extern int __declspec(dllimport) Test(char *name), where name is a input parameter for user to input name.
So my GetProcAddress should still be fProc = GetProcAddress(hLib,"Test" );
right?
But the "if(fProc) ruturns NULL..
Pls help.
I have added those codes you mentioned.
but I can't get the address of the Function.(dll)
I have just changed my dll function to
extern int __declspec(dllimport) Test(char *name), where name is a input parameter for user to input name.
So my GetProcAddress should still be fProc = GetProcAddress(hLib,"Test"
right?
But the "if(fProc) ruturns NULL..
Pls help.
"C" grade?????
why not just ask for more info and not grade yet?
why not just ask for more info and not grade yet?
My answer was correct - by not putting extern "C" you have changed the name of the function.
You have introduced C++ name mangling - put the extern "C" back and all should be well.
Use the quickview application or depends.exe with VC++ to view the exports of a DLL.
C ???
You have introduced C++ name mangling - put the extern "C" back and all should be well.
Use the quickview application or depends.exe with VC++ to view the exports of a DLL.
C ???
extern "C" __declspec(dllexport) __stdcall int Testing(void)
This will ensure that the parameter passing method can be used by VB and other stdcall mechanism languages.
regards,
Mike.