zoukankan      html  css  js  c++  java
  • Delphi动态链接库学习

    Demo

    环境 delphi 6

    1、新建DLL 文件,File—New—Other—OK。

    代码为:

    library ProTestDLL;

    { Important note about DLL memory management: ShareMem must be the   first unit in your library's USES clause AND your project's (select   Project-View Source) USES clause if your DLL exports any procedures or   functions that pass strings as parameters or function results. This   applies to all strings passed to and from your DLL--even those that   are nested in records and classes. ShareMem is the interface unit to   the BORLNDMM.DLL shared memory manager, which must be deployed along   with your DLL. To avoid using BORLNDMM.DLL, pass string information   using PChar or ShortString parameters. }

    uses   SysUtils,   Classes,   Dialogs;

    {$R *.res}

    Procedure  PrintHanYu; begin   ShowMessage('动态连接库文件'); end;

    exports   PrintHanYu;

    begin

    end.

    2、调用DLL文件,编译DLL文件,新建窗体文件,键入代码。

    unit Unit1;

    interface

    uses   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,   Dialogs;

    type   TForm1 = class(TForm)     procedure FormCreate(Sender: TObject);   private     { Private declarations }   public     { Public declarations }   end;

    var   Form1: TForm1;

    implementation

    {$R *.dfm}

    procedure PrintHanYu;external 'proTestDLL.dll';

    procedure TForm1.FormCreate(Sender: TObject); begin   PrintHanYu; end;

    end.

    注意:DLL文件必须和主项目文件在同一文件夹下

  • 相关阅读:
    【转】C# 注册表简单操作
    [转]VC++之随父窗口变化调整控件大小/位置
    [转]vc 汉字汉语拼音首字母如何获取
    [转]浅析ActiveX控件的CAB压缩
    [转]VC6.0中使用MFC开发ActiveX及简单验证
    ElasticSearch增加索引字段
    单词缩写
    linux命令
    使用PR插件Twixtor Pro对视频补帧
    Linux创建脚本服务
  • 原文地址:https://www.cnblogs.com/rongxiaoya/p/2796343.html
Copyright © 2011-2022 走看看