|
DLL Project 의 파일에
있는 함수는 아래와 같이
extern "C" __declspec(dllexport) void __stdcall testfunc()
{
ShowMessage("Message from DLL");
}
호출하는 exe 소스코드는 아래와 같이
void __fastcall TForm1::Button1Click(TObject *Sender)
{
HMODULE hDll;
hDll = LoadLibrary("C:\\DLLTEST\\Debug\\Project1.dll");
if(hDll==NULL)
{
ShowMessage("Can't load dll");
return;
}
typedef __declspec(dllimport) void (*TestFunc)(void);
TestFunc Test;
Test = (TestFunc)GetProcAddress(hDll,"testfunc");
if(Test)
{
(*Test)();
}
FreeLibrary(hDll);
}
해보세요..~~~
성공하시길 바래요...
라이손레종ㅎ 님이 쓰신 글 :
: if (hDll = NULL) {ShowMessage("dll not load");}
:
: if (hDll == NULL) {ShowMessage("dll not load");}
:
: 요렇게 수정했는데.. 그래도.. 결과는 같습니다.. 대신 경고 문이 사라 졌네요 . .. 휴..
:
: 두 고수님 풀어 주세요 ㅠ.ㅠ
|