By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,056 Members | 1,320 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,056 IT Pros & Developers. It's quick & easy.

Calling EXE Function

P: n/a
Hello All
I am able to call the function exported by Exe from a dll file
im getting the address of the function but whille calling that function im
getting access violation Error as bellow my code

Function Exported by EXE
void __declspec(dllexport) ExeFn()
{
MessageBox(NULL,"hi","From Exe",MB_OK);
}
Function call from Dll

HMODULE hModule;
LPTSTR modname;
hModule=GetModuleHandle("Placeholder.exe");
if (hModule == NULL)
{
hModule=(HMODULE)LoadLibrary ("Placeholder.exe");
}

FnPtrT FnPtr = (FnPtrT)::GetProcAddress((HMODULE)hModule, "ExeFn");
if(FnPtr)
{
MessageBox(NULL,(LPCTSTR)FnPtr,"Exec",MB_OK);
(*FnPtr)();
}

Followinf Error

Unhandled exception at 0xfffffff9 in Mayur.dll 0xC0000005: Access violation
reading location 0xfffffff9.

Sep 25 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"Mayur" <ma***@activelement.comwrote in message
news:Ok**************@TK2MSFTNGP04.phx.gbl...
| Hello All
| I am able to call the function exported by Exe from a dll file
| im getting the address of the function but whille calling that function im
| getting access violation Error as bellow my code
|
|
|
| Function Exported by EXE
| void __declspec(dllexport) ExeFn()
| {
| MessageBox(NULL,"hi","From Exe",MB_OK);
| }
|
|
| Function call from Dll
|
| HMODULE hModule;
| LPTSTR modname;
| hModule=GetModuleHandle("Placeholder.exe");
| if (hModule == NULL)
| {
| hModule=(HMODULE)LoadLibrary ("Placeholder.exe");
| }
|
| FnPtrT FnPtr = (FnPtrT)::GetProcAddress((HMODULE)hModule, "ExeFn");
| if(FnPtr)
| {
| MessageBox(NULL,(LPCTSTR)FnPtr,"Exec",MB_OK);
| (*FnPtr)();
| }
|
|
|
| Followinf Error
|
| Unhandled exception at 0xfffffff9 in Mayur.dll 0xC0000005: Access
violation
| reading location 0xfffffff9.
|
|
|

Wrong NG, please post to a vc or Win32 NG.

Willy.
Sep 25 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.