如何將Delphi的DFM表單從二進制格式轉換爲使用C#的文本格式?Delphi Form(DFM)To Text
回答
最好的方法可能是撥打CONVERT.EXE
,這是Delphi附帶的一個命令行應用程序。 Here's an example in Delphi。你可以在C#中做同樣的事情。
我用這四種方法來測試DFM文件格式,並轉換爲:
function IsDFMStreamBinary(AStream: TMemoryStream): Boolean;
{ Returns true if dfm file is in a binary format }
var
F: TMemoryStream;
B: byte;
begin
B := 0;
F := TMemoryStream.Create;
F.LoadFromStream(AStream);
try
F.read(B, 1);
Result := B = $FF;
finally
F.Free;
end;
end;
function DfmFile2Stream(const ASrc: string; ADest: TStream): Boolean;
{ Save dfm to stream }
var
SrcS: TFileStream;
begin
SrcS := TFileStream.Create(ASrc, fmOpenRead or fmShareDenyWrite);
try
ObjectResourceToText(SrcS, ADest);
Result := True;
finally
SrcS.Free;
end;
end;
procedure Txt2DFM(ASrc, ADest: string);
{ Convert Text to DFM }
var
SrcS, DestS: TFileStream;
begin
SrcS := TFileStream.Create(ASrc, fmOpenRead);
DestS := TFileStream.Create(ADest, fmCreate);
try
ObjectTextToResource(SrcS, DestS);
finally
SrcS.Free;
DestS.Free;
end;
end;
function Dfm2Txt(const ASrc, ADest: string): boolean;
{ Convert a binary DFM to text }
var
ASrcS, ADestS: TFileStream;
begin
ASrcS := TFileStream.Create(ASrc, fmOpenRead);
ADestS := TFileStream.Create(ADest, fmCreate);
try
ObjectResourceToText(ASrcS, ADestS);
Result := True;
finally
ASrcS.Free;
ADestS.Free;
end;
end;
如果您沒有忽略問題的「來自C#」部分,我會對此進行投票。 – 2010-08-17 12:50:17
謝謝,但我需要的C#代碼不是德爾福 – Lennie 2010-08-18 13:55:37
德爾福的二進制文件DFM是對象的所有二進制表示之後。
正確的方法做的工作就是寫自私的C#命令行實用程序(不再需要任何外部扶養的),基於二進制DFM文件本身的格式的知識。
如果格式沒有公開,做了顛倒工程應該是可行的:
- ObjectResourceToText源代碼可以(Classes.pas)。
- 轉換器(從二進制到文本,反之亦然)生成工具所需的輸入也可用。
問題是比你的評論前一年充分回答,它是什麼添加? – RichardTheKiwi 2016-05-05 22:49:18
- 1. Delphi Form閃爍
- 2. php form to javascript
- 3. 使用Delphi IDE搜索DFM文件
- 4. Text to Column change as Text to row
- 5. Text DFM上下文菜單選項的含義是什麼?
- 6. Codeigniter Form to Html
- 7. Form to mail tools
- 8. Delphi 5 to 2010
- 9. Delphi的源代碼轉換工具是否有任何Delphi DFM?
- 10. Speech to Text Android
- 11. Jdatechooser text to ally
- 12. Android text to image
- 13. Speech to text c#
- 14. SHELL text to html
- 15. AVSpeechSynthesizer Text-To-Speech
- 16. postscript to text
- 17. silverlight speech to text
- 18. Javascript onmouseover trying to add「to text
- 19. 我在哪裏可以找到delphi的Text-to-Speech組件?
- 20. form not not to iframe back
- 21. Delphi dcu to obj
- 22. Cobol to Delphi
- 23. Post form to other controller
- 24. html form entry data to my email
- 25. json text to c#dictionary
- 26. shape file(GIS)to text
- 27. Watson Speech to Text Latency
- 28. Aside text to circular image
- 29. text to binary conversion matlab
- 30. text to XML with xslt
提示:將* .DFM文件類型與CONVERT.EXE關聯。這樣,您可以在資源管理器中選擇多個DFM文件,並在上下文菜單中選擇「使用轉換打開」。 – 2010-08-17 10:15:29