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

請問一個呼叫DLL的問題?

尚未結案
ying0515
中階會員


發表:90
回覆:168
積分:81
註冊:2003-01-04

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-04-11 17:22:29 IP:61.218.xxx.xxx 未訂閱
library myFuns;
uses
  ShareMem,  SysUtils,  Classes;
  myFuns_u in 'myFuns_u.pas';
{$R *.RES}
exports ttt;
begin
end.
----------------------------------------
unit myFuns_u;
interface
uses
  Windows, SysUtils, Classes, Controls, Forms, DB, DBClient, Jpeg, dbctrls,
  Graphics, IniFiles, StdCtrls, Menus, ExtCtrls, ComCtrls, DBGrids, Dialogs;
procedure ttt(frm: TForm); export;
implementation
procedure ttt(frm: TForm);
var i: Integer;
begin
  for i:= 0 to frm.ComponentCount - 1 do
  begin
    ShowMessage((frm.Components[i]).Name);
    if (frm.Components[i] is TLabel) then  <<-----為何沒作用!
       ShowMessage('aaaaa');  
  end;
end;
end.
-------------------------------------------------------
program Test;
uses
  ShareMem,  Forms;
  Test_u in 'Test_u.pas' {Test_Form};
{$R *.RES}
begin
  Application.Initialize;
  Application.CreateForm(TTest_Form, Test_Form);
  Application.Run;
end.
-----------------------------------------------------
unit Test_u;
interface
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,  StdCtrls;
type
  TTest_Form = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Test_Form: TTest_Form;
  procedure ttt(frm: TForm); far; external 'myFuns.dll';
implementation
{$R *.DFM}
procedure TTest_Form.Button1Click(Sender: TObject);
begin
  ttt(Self);  //<<--呼叫DLL
end;
end.
請問上述程式在呼叫ttt()的DLL時其
    if (frm.Components[i] is TLabel) then <<-----為何沒作用!
       ShowMessage('aaaaa');  
 
Delphi follower 發表人 - ying0515 於 2005/04/11 17:29:12 發表人 - ying0515 於 2005/04/11 17:31:13
------
Delphi
mustapha.wang
資深會員


發表:89
回覆:409
積分:274
註冊:2002-03-13

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-04-11 21:22:38 IP:218.1.xxx.xxx 未訂閱
因为dll并不能共享资料,Test.exe里的TLabel并不是myFuns.dll里的TLabel,也就是TTest_Form里的TLabel并不是myFuns.dll里的TLabel。 而bpl可以很好地共享这些RTTI信息,如果dll用Runtime Package编译,Test.exe也用Runtime Package编译就可以了。     久病成良医--多试 千人之诺诺,不如一士之谔谔--兼听
------
江上何人初见月,江月何年初照人
ying0515
中階會員


發表:90
回覆:168
積分:81
註冊:2003-01-04

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-04-12 08:18:36 IP:61.218.xxx.xxx 未訂閱
請問如何改寫成Rentime Package? Delphi follower
------
Delphi
ying0515
中階會員


發表:90
回覆:168
積分:81
註冊:2003-01-04

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-04-12 08:27:33 IP:61.218.xxx.xxx 未訂閱
Sorry!我試出來了!原來在Porject->Options->Packages->將Build with runtime packages 打勾就好!感謝! Delphi follower
------
Delphi
系統時間:2024-07-01 9:30:04
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!