Problems while calling MFC-DLL functions 
Author Message
 Problems while calling MFC-DLL functions

Hi all,
I have written an MFC-DLL that have some functions like:

void MyPortDLL::Port_Settings(const char *pcPort)
{
    strcpy(my_pcPort, pcPort);

Quote:
}

In my Application I called that function as follows:

typedef void (*MY_PORTSETTINGS_FUNC)(const char* pcPort)
....

// Port Settings
HINSTANCE my_Dll_H;
MY_PORTSETTINGS_FUNC Dll_Port_Settings;

my_Dll_H = LoadLibrary("MyPortDLL.dll");
Dll_Port_Settings = (MY_PORTSETTINGS_FUNC)GetProcAddress(my_Dll_H,"Port_Settings");
....
Dll_Port_Settings("COM3");
At this point I get a Debug Error that says:
The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.

Any Help is appreciated. Thanks in advance
--
If you want to reply to me, please erase "nospam." from the E-Mail adress.
Regards Sidibou



Tue, 24 Dec 2002 03:00:00 GMT  
 Problems while calling MFC-DLL functions

Try explicitly setting the function prototype to a calling convention.  For example, let's assume __stdcall (though __cdecl would work too).  In this case you would change the prototype and implementation of your DLL function as follows:

   void __stdcall MyPortDLL::Port_Settings(const char* pcPort)

and

   typedef void (__stdcall *MY_PORTSETTINGS_FUNC)(const char* pcPort);

Give that a shot and see if it helps

Joe O'

  Hi all,
  I have written an MFC-DLL that have some functions like:

  void MyPortDLL::Port_Settings(const char *pcPort)
  {
      strcpy(my_pcPort, pcPort);
  }

  In my Application I called that function as follows:

  typedef void (*MY_PORTSETTINGS_FUNC)(const char* pcPort)
  ....

  // Port Settings
  HINSTANCE my_Dll_H;
  MY_PORTSETTINGS_FUNC Dll_Port_Settings;

  my_Dll_H = LoadLibrary("MyPortDLL.dll");
  Dll_Port_Settings = (MY_PORTSETTINGS_FUNC)GetProcAddress(my_Dll_H,"Port_Settings");
  ....
  Dll_Port_Settings("COM3");
  At this point I get a Debug Error that says:
  The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.

  Any Help is appreciated. Thanks in advance
  --
  If you want to reply to me, please erase "nospam." from the E-Mail adress.
  Regards Sidibou



Tue, 24 Dec 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Problems while calling MFC-DLL functions

2. Problems while calling MFC-DLL functions

3. DLL function calling problems (explicit - only knowing function name at runtime)

4. Calling function in managed dll from Unmanaged MFC Application doesn't work on XP

5. Calling a DLL function from a mfc prj

6. Calling MFC Dll functions from a Progress Database

7. Calling functions in a VB dll from MFC

8. Problem calling into managed DLL that calls unmanaged DLL

9. Problem calling dll functions

10. Problem calling DLL functions in _finally blocks when optimized

11. Problem with function call to a DLL

12. Calling MFC extension dll problem

 

 
Powered by phpBB® Forum Software