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

DLL應用上遇到的瓶頸

答題得分者是:christie
yuhboy
一般會員


發表:12
回覆:27
積分:12
註冊:2004-11-01

發送簡訊給我
#1 引用回覆 回覆 發表時間:2007-12-15 09:35:08 IP:140.116.xxx.xxx 訂閱
壓縮檔中有兩個資料夾

dllform DLL 程式
dllshow 應用上

我希望 dllshow 去呼叫 crfrom.dll 後
所出現的 form , 當我在這個 form中的 Edit1 輸入完文字後按下 Button1 後
程式會關閉

但同時,我的 dllshow 裡的變數 str1 會存入我在 Dll form 的 edit1 所輸入的文字

我想用範例應該較容易理解我想做到的效果

謝謝
附加檔案:47632f4bf421b_提問.rar
christie
資深會員


發表:30
回覆:299
積分:475
註冊:2005-03-25

發送簡訊給我
#2 引用回覆 回覆 發表時間:2007-12-16 16:02:55 IP:220.143.xxx.xxx 未訂閱

===================引 用 yuhboy 文 章===================
壓縮檔中有兩個資料夾

dllform DLL 程式
dllshow 應用上

我希望 dllshow 去呼叫 crfrom.dll 後
所出現的 form , 當我在這個 form中的 Edit1 輸入完文字後按下 Button1 後
程式會關閉

但同時,我的 dllshow 裡的變數 str1 會存入我在 Dll form 的 edit1 所輸入的文字

謝謝
====================================================

[code delphi]
unit Umain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
CString= string[100];

type
TFmain = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Fmain: TFmain;
str1 : string;
//procedure crform;external 'dllform.dll';
implementation
function DisplaySampleFrm: CString; stdcall; external 'dllform.DLL';
{$R *.dfm}
procedure TFmain.Button1Click(Sender: TObject);
begin
caption:=DisplaySampleFrm
//showMessage('I Get :' DisplaySampleFrm ' From DLL.');
end;
end.
/////////////////////////////////////////////////////////////
library dllform;
uses
SysUtils,
Classes,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
type CString = string[100];
function DisplaySampleFrm:Cstring;
var
rcstr:string;
begin
rcstr:='';
Form1 := TForm1.Create(nil);
try
Form1.Showmodal;
rcstr:=Form1.PASS_val;
finally
Form1.Free;
end;
result:=rcStr;
end;
exports DisplaySampleFrm;
end.

/////////////////////////////////////////////////////////////
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
PASS_val:string;
end;
var
Form1: TForm1;
//procedure crform;
implementation
{$R *.dfm}
//按下 Button1 後程式會關閉
procedure TForm1.Button1Click(Sender: TObject);
begin
pass_val:=Edit1.Text;
Close//Form1.Close
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1.Text:=''
end;
end.
[/code]
------
What do we live for if not to make life less difficult for each other?
yuhboy
一般會員


發表:12
回覆:27
積分:12
註冊:2004-11-01

發送簡訊給我
#3 引用回覆 回覆 發表時間:2007-12-17 21:47:07 IP:61.225.xxx.xxx 訂閱
很感謝你提供這個答案

我試做出來了

只是我又突發其想

那能否回傳一個集合呢

因為回傳不只一種資料時

要如何實作呢

christie
資深會員


發表:30
回覆:299
積分:475
註冊:2005-03-25

發送簡訊給我
#4 引用回覆 回覆 發表時間:2007-12-18 08:45:46 IP:203.73.xxx.xxx 未訂閱
[About Calling conventions]參考:
http://www.swissdelphicenter.ch/torry/showcode.php?id=1233
===================引 用 yuhboy 文 章===================
很感謝你提供這個答案

我試做出來了

只是我又突發其想

那能否回傳一個集合呢

因為回傳不只一種資料時

要如何實作呢

------
What do we live for if not to make life less difficult for each other?
yuhboy
一般會員


發表:12
回覆:27
積分:12
註冊:2004-11-01

發送簡訊給我
#5 引用回覆 回覆 發表時間:2007-12-18 11:10:10 IP:140.116.xxx.xxx 訂閱
好奇怪哦
我試了你那個方法
是OK的

但遇到一個問題

在 dll 上的 form 上
如果放上去 ADOConnection
再再呼叫

Coinitialize 尚未被呼叫

的錯誤訊息

不過只要把 ADOConnection 拿掉即可
系統時間:2024-04-30 13:23:45
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!