線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1076
推到 Plurk!
推到 Facebook!

載入dll時..變數宣告

答題得分者是:cmf
yoyo12345
一般會員


發表:33
回覆:77
積分:22
註冊:2003-03-19

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-09-03 11:15:31 IP:203.69.xxx.xxx 未訂閱
載入dll時 請問變數(dllname)怎麼宣告? 因為都會出現'Unknown directive:dllname'的訊息。 謝謝!! unit MaxUnit; interface function Max(I1,I2:integer):integer; var dllname:string; implementation dllname:'maxlib.dll'; function Max; external dllname name 'Max'; end.
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-09-03 11:55:21 IP:147.8.xxx.xxx 未訂閱
I think you cannot has shared variable in a dll implemented by Delphi/BCB. In fact, your host application and the dll have their own independent instance of memory storage. Perhaps you could make use of memory mapped file? Or simply export function to get set the variable in dll? Remember to use ShareMem when passing string...
cmf
尊榮會員


發表:84
回覆:918
積分:1032
註冊:2002-06-26

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-09-03 12:05:03 IP:61.218.xxx.xxx 未訂閱
unit MaxUnit;    interface function Max(I1,I2:integer):integer;        implementation    const  dllname='maxlib.dll';    function Max; external dllname name 'Max';    end.    僅供參考,歡迎繼續發言願以此功德 莊嚴佛淨土 上報四重恩 下濟三塗苦 若有見聞者 悉發菩提心 盡此一報身 同生極樂國
------
︿︿
yoyo12345
一般會員


發表:33
回覆:77
積分:22
註冊:2003-03-19

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-09-03 16:10:55 IP:203.69.xxx.xxx 未訂閱
可以了,謝謝!! 但,為什麼要用常數宣告才可?
cmf
尊榮會員


發表:84
回覆:918
積分:1032
註冊:2002-06-26

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-09-03 17:00:46 IP:61.218.xxx.xxx 未訂閱
To import routines from a dynamically loadable library (.so or .DLL), attach a directive of the form    external stringConstant; to the end of a normal procedure or function header, where stringConstant is the name of the library file in single quotation marks.
------
︿︿
yoyo12345
一般會員


發表:33
回覆:77
積分:22
註冊:2003-03-19

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