//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Unit2.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { // 以下4行がDLLの動的リンクに必要な部分 Func = LoadLibrary("sampledll"); PFunc1 = (void __stdcall(*)(void))GetProcAddress(Func,"Func1"); PFunc2 = (void __stdcall(*)(AnsiString))GetProcAddress(Func,"Func2"); PFunc3 = (int __stdcall(*)(int,int))GetProcAddress(Func,"Func3"); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { PFunc1(); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender) { PFunc2(Edit1->Text); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button3Click(TObject *Sender) { int a,b; a = StrToIntDef(Edit2->Text,0); b = StrToIntDef(Edit3->Text,0); Button3->Caption = PFunc3(a,b); } //---------------------------------------------------------------------------