全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1479
推到 Plurk!
推到 Facebook!

load vc++ DLL,请教

 
wxss2008
一般會員


發表:1
回覆:0
積分:0
註冊:2006-08-24

發送簡訊給我
#1 引用回覆 回覆 發表時間:2007-03-13 15:30:27 IP:210.72.xxx.xxx 訂閱
我要用delphi调一个vc++的DLL
在vc里的声明为:int myfunc(char const *, int, class CString &)
我的delphi source:

type TDLLFunc = function (const ss: PChar; i: integer; var param2: string): boolean;
{assign a nil - not loaded function}
const DLLFunc: TDLLFunc = nil;
DLLName = 'my.dll'; {handle of loaded dll}
procedure TForm1.Button1Click(Sender: TObject);
var DLLHandle: THandle;
s:string;
begin { load a library }
DLLHandle := LoadLibrary(DLLName);
if (DLLHandle < HINSTANCE_ERROR) then
raise Exception.Create(DLLName ' library can not be loaded or not found. ' SysErrorMessage(GetLastError));
try { load an address of required procedure}
@DLLFunc := GetProcAddress(DLLHandle, 'myfunc');
{if procedure is found in the dll}
if Assigned(DLLFunc) then
DLLFunc('dddddddddddddddddddd', 2, s);
finally {unload a library}
FreeLibrary(DLLHandle);
end;

end;
问题是Assigned(DLLFunc) 失败,我的接口声明type TDLLFunc = function (const ss: PChar; i: integer; var param2: string): boolean;
有问题吗? 请不吝赐教
------
wxs
syntax
尊榮會員


發表:26
回覆:1139
積分:1258
註冊:2002-04-23

發送簡訊給我
#2 引用回覆 回覆 發表時間:2007-03-14 04:22:53 IP:61.64.xxx.xxx 訂閱
你的語法錯誤,用搜尋,已有答案
系統時間:2024-05-03 4:57:05
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!