HadiRezaee
Technical User
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 ?
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 ?