I have an executable that needs to call an external DLL. This DLL accepts a string and opens up a new window.
If I call it in VB, the window opens fine. I get the CPP program to call it, but the window closes right away.
I'm missing something, but not sure what. Below is the code:
If I call it in VB, the window opens fine. I get the CPP program to call it, but the window closes right away.
I'm missing something, but not sure what. Below is the code:
Code:
*/
main()
{
/* get handle to dll */
HINSTANCE hGetProcIDDLL = LoadLibrary("C:\\WINDOWS\\system32\\Chem2D.dll");
/* get pointer to the function in the dll*/
FARPROC lpfnGetProcessID = GetProcAddress(HMODULE(hGetProcIDDLL), "Show2D");
/* Define the Function in the DLL for reuse. This is just prototyping
the dll's function. A mock of it. Use "stdcall" for maximum compatibility.
*/
typedef int (__stdcall * pICFUNC)(char*);
pICFUNC MyFunction;
MyFunction = pICFUNC(lpfnGetProcessID);
/* The actual call to the function contained in the dll */
int intMyReturnVal = MyFunction("CCCCC");
/* Release the Dll */
FreeLibrary(hGetProcIDDLL);
/* The return val from the dll */
return intMyReturnVal;
cin.get();
}