3
A
回答
6
最有可能的,你將有VCL的兩個實例在你的過程中,一個主機exe文件,一個用於DLL。這是一個例子太多了。宿主exe文件中的TForm類是與DLL中的TForm類不同的類。
的基本規則是,你不能跨模塊邊界共享VCL/RTL對象,除非所有模塊使用VCL/RTL運行的同一個實例。實現這一點的方法是使用包鏈接到VCL/RTL。
1
我假設你有一個框架,你有一個TMemo的形式:
聲明兩種類型:
type
PTform = ^TForm;
TStringArray = array of string;
,使這些可見的EXE和DLL都
.DPR實現部分:
procedure dllcomplist(p_pt_form : PTForm;
var p_tx_component : TStringArray);
stdcall;
external 'dllname.dll';
...
var
t_tx_component : TStringArray;
t_ix_component : integer;
...
Memo1.Lines.Add('Call DLL to return componentlist');
dllcomplist(pt_form,t_tx_component);
Memo1.Lines.Add('Result in main program');
for t_ix_component := 0 to pred(length(t_tx_component)) do
Memo1.Lines.Add(inttostr(t_ix_component) + '=' + t_tx_component[t_ix_component]);
setlength(t_tx_component,0);
和DLL的.DPR
...
procedure dllcomplist(p_pt_form : PTForm;
var p_tx_component : TStringArray);
stdcall;
var
t_ix_component : integer;
t_ix_memo : integer;
t_tx_component : TStringArray;
begin with p_pt_form^ do begin
setlength(t_tx_component,componentcount);
setlength(p_tx_component,componentcount);
for t_ix_component := 0 to pred(componentcount) do
begin
t_tx_component[t_ix_component] := components[t_ix_component].Name;
p_tx_component[t_ix_component] := components[t_ix_component].Name;
if components[t_ix_component].ClassName = 'TMemo' then
t_ix_memo := t_ix_component;
end;
Tmemo(components[t_ix_memo]).lines.add('Within DLL...');
for t_ix_component := 0 to pred(componentcount) do
Tmemo(components[t_ix_memo]).lines.add(inttostr(t_ix_component) + ' '
+ t_tx_component[t_ix_component]);
Tmemo(components[t_ix_memo]).lines.add('DLL...Done');
setlength(t_tx_component,0);
end;
end;
...
exports dllcomplist;
{OK - 這是更多比嚴格要求複雜。我在做什麼正在建立在調用程序動態數組,它填充在DLL然後在呼叫者顯示結果
AND
檢測TMemo在DLL和從相同的動態寫入數據數組中的DLL到TMemo從來電者 - 顯示的數據是相同}
+0
你還沒有解決的事實DLL.TForm是EXE.TForm不同。這是不可逾越的。 – 2013-03-03 18:56:53
相關問題
- 1. WiX - 將參數傳遞給CustomAction(DLL)
- 2. 將URL作爲參數傳遞給XSL
- 3. 將參數傳遞給類作爲VAL
- 4. 將XMLDocument作爲參數傳遞給XSLT
- 5. 將ArrayList作爲參數傳遞給StoredProcedure
- 6. 將struct傳遞給pthread作爲參數
- 7. 將stdin作爲參數傳遞給sed
- 8. 如何將參數傳遞給作爲參考傳遞的函數?
- 9. 如何將任何HtmlControl作爲參數傳遞給函數
- 10. 如何將幾何點作爲參數傳遞給postgres函數?
- 11. 如何將$ params數組作爲參數傳遞給函數?
- 12. 如何將數組作爲多個參數傳遞給函數?
- 13. 如何將數組作爲url參數傳遞給Azure函數
- 14. 如何將TextBox中的值作爲參數傳遞給動作
- 15. 如何將可變內容作爲參數傳遞給函數
- 16. 如何將數據從coffeescript傳遞給rails作爲參數
- 17. JavaScript:如何將對象作爲參數傳遞給addEventListener函數?
- 18. 如何將setter屬性作爲參數傳遞給函數?
- 19. 如何將函數作爲參數傳遞給elisp?
- 20. 如何將數組作爲參數傳遞給puppet類
- 21. 如何將json作爲參數傳遞給函數
- 22. 如何將函數作爲變量傳遞給固定參數
- 23. 如何將強引號作爲參數傳遞給bash函數
- 24. 如何將php變量作爲參數傳遞給JavaScript函數
- 25. 如何將動態屬性作爲參數傳遞給函數?
- 26. 如何將行號作爲參數傳遞給SUMIF()函數?
- 27. 如何將列名作爲參數傳遞給函數?
- 28. 我該如何將參數作爲「整數」傳遞給ansible?
- 29. 如何將值傳遞給作爲參數的函數
- 30. 如何將url作爲參數傳遞給JavaScript函數?
喜大衛,因爲我的問題我的DLL來獲取組件列表的工作沒有錯誤,但如果我指定組件「」 Tsomecomponent我得到錯誤。我仍然混亂有關 – AsepRoro 2013-03-11 08:38:38