在dll Delphi中创建VCL表单

时间:2017-06-05 15:02:30

标签: delphi dll vcl

我有这个代码只是试图在DLL中创建一个表单。我通过RAD studio Berlin IDE创建了DLL和表单。我想只是张贴一个空白表单以确保它正常工作,不幸的是它崩溃了EAcess违规(或者是EResNotFound异常,消息"资源TSigForm无法找到"),我无法弄清楚遗漏了什么。

DLL代码:

unit SignatureForm;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

type
  TSigForm = class(TForm)
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  SigForm: TSigForm;

implementation

{$R *.dfm}

end.

SigForm代码:

unit SigDllHost;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

  procedure PrepareSigDLL(handle: HWND); stdcall; external 'SigDll.dll';

type
  TForm2 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);
begin
  PrepareSigDLL(Self.Handle);
end;

end.

DLL的通用主机应用程序:

cmd = r'H:/path/to/openssl.exe x509 -in H:/path/to/cert.pem -noout -subject'
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out = p.communicate()
print(out[0]) #for std out
print(out[1]) # for std err

0 个答案:

没有答案