使用Reflector将Delphi vcl.net应用程序转换为c#

Vib*_*nRC 0 c# delphi reflector

我用反射器直到试用期结束

我已成功解码了许多应用程序.通过我最近的帖子,我能够识别它还可以解码delphi.net vcl应用程序(d2007).

我可以解码delphi.net vcl并将其转换为ac#应用程序,可以使用visual studio完全编译成功.

RRU*_*RUZ 6

这个问题的答案Can i decode delphi.net vcl app and translate it to a c# application which can be compiled success fully using visual studio ?否定的

这就是为什么.

当您使用delphi(8),2005,2006或2007创建vcl net应用程序时,delphi编译器会创建一个.NET应用程序,该应用程序对内部类具有很多依赖性,这些内部类是包装器和帮助器,用于调用真正的.net类,这些类创建(wrappers)以便于为现有的delphi win32开发人员创建.net应用程序.

考虑这个样本.

这是一个delphi .net应用程序

program DelphiNetConsole;

{$APPTYPE CONSOLE}    

uses
  SysUtils;    
begin
  try
    Writeln('Hello From Delphi 2007.Net');
  except
    on E:Exception do
      Writeln(E.Classname, ': ', E.Message);
  end;
end.
Run Code Online (Sandbox Code Playgroud)

如果您将此代码手动翻译为C#

using System;
using System.Text;

namespace ConsoleApplication8
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Hello From Delphi 2007.Net");
            }
            catch (System.Exception E)
            {
                Console.WriteLine(E.Message);
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但是使用反射器可以获得第一个片段

public static void DelphiNetConsole()

{
    System.IsConsole = true;
    try
    {
        TextOutput.Output.WriteWideString("Hello From Delphi 2007.Net", 0).WriteLn();
        System.@_IOTest();
    }
    catch (Exception exception1)
    {
        Exception exception2 = System.@ExceptObject = exception1;
        Exception E = exception1;
        TextOutput.Output.WriteWideString(TObjectHelper.ClassName(System.@GetMetaFromObject(E)), 0).WriteWideString(": ", 0).WriteWideString(E.Message, 0).WriteLn();
        System.@_IOTest();
        System.@ExceptObject = null;
    }
}
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,最后一个代码调用了许多辅助类和函数(例如TextOutput),它们不是标准.net框架的一部分,而是它们是Borland.Delphi.System命名空间的一部分.

Reflector可以帮助您以自动方式翻译一些代码片段而不是完整的应用程序.