DLL问题,欢迎讨论
DLL中导出函数:
extern "C" BSTR __declspec(dllexport) __stdcall GetStr(){ WideString s=str; return SysAllocString((BSTR)s);}
//---------------------------------------#include <vcl.h>#pragma hdrstop#include "Unit1.h"//---------------------------------------#pragma package(smart_init)#pragma resource "*.dfm"TForm1 *Form1;HINSTANCE hdll;BSTR __stdcall (*GetStr)();//---------------------------------------__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner){}//---------------------------------------void __fastcall TForm1::Button1Click(TObject *Sender){ Memo1->Lines->Add(GetStr());}//---------------------------------------void __fastcall TForm1::FormCreate(TObject *Sender){ hdll = LoadLibrary("TextHook.dll"); GetStr=GetProcAddress(hdll, "GetStr");}