|
extern "C" __declspec(dllexport) void __stdcall testfunc( TComponent *pParent )
{
Form2=new TForm2(pParent );
Form2->Show();
}
이렇게 하니 DLL 생성은 오류 없이 되었습니다.
이것만 수정해서 DLL 로드 하여 버튼 클릭하면
Access violation at address 400058FE in module 'rtl60.bpl'.Read of address 83EC8B25.
오류 메시지가 뜹니다.
void TestForm::OnClickButton( TObject *Sender )
{
// TestForm 이 메인 Form 이라면...
testfunc( this );
}
또 위의 내용처럼 아래 이부분을 수정 하시라 해서 따라 해보았습니다.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
HMODULE hDll;
hDll = LoadLibrary("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)(this); // <----이렇게 하라는 거 맞는지요 ?
}
FreeLibrary(hDll);
}
이렇게 하니... 안되네요.. ㅜ.ㅜ
|