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

請問呼叫dll傳回的bool值該如何抓取

尚未結案
kochen
一般會員


發表:8
回覆:5
積分:2
註冊:2004-09-05

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-05-31 12:19:09 IP:61.56.xxx.xxx 未訂閱
這是我寫的dll檔 library Project1; { Important note about DLL memory management: ShareMem must be the first unit in your library's USES clause AND your project's (select Project-View Source) USES clause if your DLL exports any procedures or functions that pass strings as parameters or function results. This applies to all strings passed to and from your DLL--even those that are nested in records and classes9. ShareMem is the interface unit to the BORLNDMM.DLL shared memory manager, which must be deployed along with your DLL. To avoid using BORLNDMM.DLL, pass string information using PChar or ShortString parameters. } uses SysUtils, Windows, Classes, Unit1 in 'Unit1.pas'; function a():string; export; {宣告一個函數} begin end; exports PCopyFile; // {$R *.RES} var result: Boolean = False; begin result := result; exit; end. 以下是我滴程式 我有拉一個 TextBox 和一個 button unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var FormF,ToF:String; Form1: TForm1; Procedure PCopyFile(FromFIleN,ToFIleN:String);far; external 'Project1.dll' implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var re: integer; bo: LongBool; st : String; begin PCopyFile(FormF,ToF) ; if( bo ) then re := 10 Else re := -20; Edit1.Text := IntToStr(re); exit; end; end. 只是我想把 PCopyFile(FormF,ToF) ; 改成 bo:= PCopyFile(FormF,ToF) ; 這樣我就能判段是不是true或false值 PCopyFile(FormF,ToF) ;是我呼叫dll所寫的,他會開啟另一個程式出來 可是這樣寫會錯....能否請那位指點小弟我一下 感激不盡...
supman
尊榮會員


發表:29
回覆:770
積分:924
註冊:2002-04-22

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-05-31 13:16:42 IP:61.70.xxx.xxx 未訂閱
您好: 請參考我這篇 http://delphi.ktop.com.tw/topic.php?topic_id=69648
kochen
一般會員


發表:8
回覆:5
積分:2
註冊:2004-09-05

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-06-01 00:46:27 IP:61.56.xxx.xxx 未訂閱
引言: 您好: 請參考我這篇 http://delphi.ktop.com.tw/topic.php?topic_id=69648
謝謝,不過我有個問題.因為我寫的時後就是在result會一直說是error的message 這讓我不知道怎麼辦.能否幫我忙~~感激
supman
尊榮會員


發表:29
回覆:770
積分:924
註冊:2002-04-22

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-06-01 05:06:06 IP:203.204.xxx.xxx 未訂閱
您好: 請問你函數怎麼宣告的?? 如果您宣告為一個procedure,則他會將Result當成變數,而您沒有宣告他,就會出現變數沒有定義的錯誤訊息了. function a():string;export;//重點 begin ShowMessage('you success use dll'); result:='result'; end;
系統時間:2024-06-02 19:08:52
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!