extern "C" __declspec(dllexport) void showme(void) { MessageBox(NULL,"function print executed","ddd",MB_OK); }
typedef void(__stdcall *showme)(void); HINSTANCE DLLhInstance; DLLhInstance=LoadLibrary("docbook.exe"); if(!DLLhInstance) { return -1; } showme pshowme =(AddNewTitle)GetProcAddress(DLLhInstance,"showme"); if(pshowme ) { pshowme(); } FreeLibrary(DLLhInstance);
4
7
5
2
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "t.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- extern "C" _stdcall __declspec(dllexport) int showme(int x1,double &x2,int &x3) { x3=x1+1000; x2=3.45; return 100; }
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "t1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { typedef int (__stdcall *showme)(int x1,double &x2,int &x3); HINSTANCE DLLhInstance; DLLhInstance=LoadLibrary("tp.exe"); if(!DLLhInstance) { ShowMessage("error"); return ; } showme pshowme =(showme)GetProcAddress(DLLhInstance,"showme"); int x1,x3,r; double x2; if(pshowme ) { x1=10; r=pshowme(x1,x2,x3); Edit1->Text=r; Edit2->Text=x1; Edit3->Text=x2; Edit4->Text=x3; } FreeLibrary(DLLhInstance); } //---------------------------------------------------------------------------