Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Some DLL questions !!!

Status
Not open for further replies.

HadiRezaee

Technical User
Mar 9, 2001
165
IR
Hi there,
Please answer to my questions about DLL …

Q1.
I want to write simple function in a Win32 DLL project …
And call that by LoadLibrary …

I made a Win32 DLL project …
Then I wrote this function in .h file:

__declspec(dllexport) void SayHello();

And I wrote it in .cpp file:

void SayHello()
{
MessageBox(NULL, “Helllllllllo !”, “Info”, MB_ICONINFORMATION);
}

Then I compiled it without any problem …
In my MFC exe project …
I loaded that:

CoInitialize(NULL);
HMODULE hModule = LoadLibrary( "test4.dll" );

FARPROC procFunc;
procFunc = GetProcAddress(hModule, "SayHello");
(procFunc)();

FreeLibrary(hModule);
CoUninitialize();


There is no problem in DLL path file, I checked it …
But when I run this code, program show me this error:
“Unhandled exception in testdll.exe : 0x0000005 : Access violation.”

What is my wrong ?


Q2.
If I write a DLL by MFC DLL, can I use of that from other programming language like Delphi or VB ?

 
Include this in SayHello()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
rest of code....
}

And in all other functions in the DLL.

HTH


William
Software Engineer
ICQ No. 56047340
 
Hi,
Thanks for your reply ...
But my project is based on Win32 DLL, that is not MFC DLL ...

When i write it in my function, i got some linking error !!!!

Plz help me !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top