|
-
March 29th, 1999, 09:00 PM
#1
The stack, AfxLoadLib and HWnd?
Why can I not pass an HWND* just like any other pointer to my dll?
Here is the guts of my dll, it does nothing with the HWND.
extern "C" bool Func1(HWND* pMy)
{
bool bReturn = TRUE;
AfxMessageBox("Func1 active" ;
return bReturn;
}//Is_RTF_Control_Available
This is my one line def file entry
EXPORTS
Func1 @1
As you can see from the code of my Func1 I allocate no memory and I do nothing with the HWND*.
This is my calling function.
void CTestExeDlg::OnOK()
{
typedef bool (CALLBACK* TestDll) (HWND*);//( );
bool bResult;
TestDll pFunc1 = NULL;
HINSTANCE hInstance = LoadLibrary("TestDll.dll" ;
if(hInstance) {
pFunc1 = (TestDll) GetProcAddress(hInstance,"Func1" ;
if(pFunc1)
bResult = pFunc1(&m_hWnd);
}
AfxMessageBox("Returned" ;
if(hInstance){
AfxFreeLibrary(hInstance);
AfxMessageBox("Frreed" ;
}
CDialog::OnOK();
}
This code works perfect in debug mode, but the stack gets corrupted in release mode. Does anybody know why?
Thanks.
-
March 29th, 1999, 09:00 PM
#2
The stack, AfxLoadLib and HWnd?
Why can I not pass an HWND* just like any other pointer to my dll?
Here is the guts of my dll, it does nothing with the HWND.
extern "C" bool Func1(HWND* pMy)
{
bool bReturn = TRUE;
AfxMessageBox("Func1 active" ;
return bReturn;
}//Is_RTF_Control_Available
This is my one line def file entry
EXPORTS
Func1 @1
As you can see from the code of my Func1 I allocate no memory and I do nothing with the HWND*.
This is my calling function.
void CTestExeDlg::OnOK()
{
typedef bool (CALLBACK* TestDll) (HWND*);//( );
bool bResult;
TestDll pFunc1 = NULL;
HINSTANCE hInstance = LoadLibrary("TestDll.dll" ;
if(hInstance) {
pFunc1 = (TestDll) GetProcAddress(hInstance,"Func1" ;
if(pFunc1)
bResult = pFunc1(&m_hWnd);
}
AfxMessageBox("Returned" ;
if(hInstance){
AfxFreeLibrary(hInstance);
AfxMessageBox("Frreed" ;
}
CDialog::OnOK();
}
This code works perfect in debug mode, but the stack gets corrupted in release mode. Does anybody know why?
Thanks.
-
March 30th, 1999, 07:03 AM
#3
Re: The stack, AfxLoadLib and HWnd?
The client an the server use different calling conventions. The server use __cdecl and the client use __stdcall. Remove "CALLBACK" in your typedef and your code should work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|