zoukankan      html  css  js  c++  java
  • DLL_Delphi动态调用

    1、动态调用DLL

    unit formMain;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;
    
    type
      TfrmMain = class(TForm)
        btnLoadLibrary: TButton;
        procedure btnLoadLibraryClick(Sender: TObject);
      private
        { Private declarations }
      public
        procedure LoadDllZ;
      end;
    
      TfnC_ExecJS = function(_pSvgFrm :Pointer; _pcJS :PChar):integer;stdcall;
      TfnD_PassStId = function(_Sender :Pointer; _pcStId :PChar):integer;stdcall;
    
    var
      frmMain: TfrmMain;
    // ***
      g_fnExecJS : TfnC_ExecJS;
      g_fnPassStId :TfnD_PassStId;
    
    implementation
    
    {$R *.dfm}
    
    { TfrmMain }
    
    procedure TfrmMain.LoadDllZ;
    var hDll :Cardinal;
        iRtn :integer;
    begin
      hDll := LoadLibrary(PChar('DrRemoteCall.dll'));
      if hDll = 0 then
      begin
        Exit;
      end;
      
      @g_fnExecJS := GetProcAddress(hDll, 'ExecJS');
      @g_fnPassStId := GetProcAddress(hDll, 'PassStId');
    
      if not Assigned( g_fnExecJS ) then
      begin
        FreeLibrary(hDll);
        Exit;
      end;
      if not Assigned( g_fnPassStId ) then
      begin
        FreeLibrary(hDll);
        Exit;
      end;
    
      // ZC: 调用函数
      iRtn := g_fnExecJS(nil, 'TestCC');
    
      FreeLibrary(hDll);
      ShowMessage('out');
    end;
    
    procedure TfrmMain.btnLoadLibraryClick(Sender: TObject);
    begin
      LoadDllZ;
    end;
    
    end.

    2、

    3、

    4、

    5、

  • 相关阅读:
    《JS权威指南学习总结--6.6属性getter和setter》
    《JS权威指南学习总结--6.5枚举属性》
    django的模板系统
    django额外参数的传递和url命名
    python在图片上画矩形
    当爬虫遇到js加密
    php基础-7
    php基础-6
    php基础-5
    php基础-4
  • 原文地址:https://www.cnblogs.com/CodeSkill/p/8250869.html
Copyright © 2011-2022 走看看