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

    unit Unit1;

    interface

    uses

      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,

      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

    type

      TForm1 = class(TForm)

        Edit1: TEdit;

        Label1: TLabel;

        Button1: TButton;

        procedure Button1Click(Sender: TObject);

      private

        { Private declarations }

      public

        { Public declarations }

      end;

      SendPatientInfo = procedure(sParam:ansistring); stdcall;//无回参用procedure,有回参用function,我也不知道为什么

    var

      Form1: TForm1;

    implementation

    {$R *.dfm}

    var

      FDLL130Handle: THandle;

      DLL130Name: string = 'D:demodelphiMetabolism.dll';

      bStop: boolean;

    procedure TForm1.Button1Click(Sender: TObject);

    var

      sendPInf:SendPatientInfo;

    begin

      FDLL130Handle := Loadlibrary(Pchar(DLL130Name));

      if FDLL130Handle = 0 then

      begin

        ShowMessage(DLL130Name+'不存在');

      Exit;

      end;

      @sendPInf := GetProcAddress(FDLL130Handle, 'SendPatientInfo');

      if @sendPInf = nil then

      begin

        ShowMessage('SendPatientInfo 函数无法获得!');

      end else

      begin

        sendPInf(pchar(Edit1.Text));

      end;

    end;

    end.

  • 相关阅读:
    Java随笔
    Java随笔
    Java随笔
    CF1271D Portals(反悔贪心)
    CF938D Buy a Ticket(最短路)
    CF1117C Magic Ship(二分)
    HDU6820 Tree(树形dp)
    P2393 美味(主席树+贪心)
    HDU6831 Fragrant numbers(区间dp)
    HDU6832 A Very Easy Graph Problem(生成树)
  • 原文地址:https://www.cnblogs.com/zhaisd/p/13516818.html
Copyright © 2011-2022 走看看