Re: MFC dll and exe porting to 64-bit
Sorry for not seeing that....
Here is the only function exported in dll
----------------------------------
void CUesOastplsubApp::CreateInstance(char* sDsn, char* lpszDriver, int
fRequest, char* szResPath)
{
CDsnPropertyDlg dlg;
INT_PTR nResponse = dlg.DoModal(sDsn, lpszDriver, fRequest, szResPath);
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
}
----------------------------------
Here is my test exe
---------------------------------
typedef void (WINAPI*CreateInstancePtr)(char*, char*, int, char*);
{
HINSTANCE loadDll;
loadDll = LoadLibrary("path\\to\\my.dll");
if(loadDll == NULL)
MessageBox("Load Dll NONOK !","Info",MB_OK);
else
MessageBox("Load Dll OK !","Info",MB_OK);
//retrive the dll function
CreateInstancePtr pCreateInstance;
pCreateInstance =
(CreateInstancePtr)GetProcAddress(loadDll,"?CreateInstance@CSubApp@@QEAAXPEAD0_K0@Z");
if(pCreateInstance == NULL)
MessageBox("Dll Error - Fail to load function","Info",MB_OK);
else
{
GetDlgItemText(IDC_EDITDSN, m_Dsn);
//cast the CString to char*
char temp[512];
strcpy(temp,m_Dsn);
pCreateInstance(temp, "ODBC Driver Name", ODBC_CONFIG_DSN,
"path\\to\\resource.dll");
}
}
---------------------------------
Thanks
--
Struggling on 64-bit
"Joseph M. Newcomer" wrote:
See below...
Note that the absence of any code makes it hard to determine what is going on!
On Wed, 28 Nov 2007 07:25:03 -0800, Tailai Chen <TailaiChen@discussions.microsoft.com>
wrote:
Hi
I had several MFC Dlls and EXEs (32bit was built in VC6) to be ported to
64-bit. I recompile them using PSDK and VC6 on a 64-bit XP SP2 (amd64)
development machine.
The problem is, when testing, although they all compiled and built fine, my
MFC exe was able to load the dll dynamically and can find the exported
functions, BUT the parameters passed when calling the exported function have
been messed up. The exported function CreateInstance(char*, char*, int,
char*) taking four parameters to create an instance of a dialog, and I got an
"Access violation - code c0000005 (first chance)" when debugging with WinDbg,
which clearly that certain parameters are not right.
****
You did not get an "access violation"; you got "an access violation in <module name here>"
and quite likely "at line <number>" which is the line "<text of line here>" and the
backtrace to your call site is "<backtrace here>". Lacking all this information, what we
can safely say is that you made an error in the conversion to 64-bit, but without this
information and you sample code of the DLL, the call, etc., we could not possibly guess
what has gone wrong.
****
So I went on created a sample MFC dll and exe trying to prove. I got an
unexpected results:
e.g. function included in dll print out the parameter it get, when passing
one int, it prints out 0 no matter what the number is, when passing two ints,
it prints out the first one right following a "2345667" which looks like part
of memory address, when passing three parameters, it prints out the first two
right with "3554345".
****
And in the absence of the code for this, we have NO IDEA what you did!
****
I tried regular dll, it works fine, so only to MFC dll
I know this may turn out to be a basic mistake, I will be appriciate that
someone could at least prove me wrong, then I can get my life going again.
****
Give us enough information to help, and we can try. Give us no information, as this post
has, and we haven't a chance
joe
****
Thanks
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm