我现在编写一个动态连接库,使别人能通过它进行.Ini文件的读写。初始代码如下:
//ReadResource.dprlibrary ReadResource;{ 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,
ExportUnit in 'ExportUnit.pas',
ReadInif in 'ReadInif.pas';{$R *.RES}begin
end.//ExportUnit.pasunit ExportUnit;interfacefunction ERInitFileName(const AFileName: String): Boolean; stdcall;
function ERReadString(const AFileName, Section, Ident, Default: string): string; stdcall;
function ERReadInteger(const AFileName, Section, Ident: String; Default: Longint): Longint; stdcall;
function ERReadBool(const AFileName, Section, Ident: String; Default: Boolean): Boolean; stdcall;
function ERReLoadResource(AFileName: String): Boolean; stdcall;
exports
ERInitFileName,
ERReadString,
ERReadInteger,
ERReadBool,
ERReLoadResource;implementationfunction ERInitFileName(const AFileName: String): Boolean; stdcall;
beginend;function ERReadString(const AFileName, Section, Ident, Default: string): string; stdcall;
begin
end;function ERReadInteger(const AFileName, Section, Ident: String; Default: Longint): Longint; stdcall;
begin
end;function ERReadBool(const AFileName, Section, Ident: String; Default: Boolean): Boolean; stdcall;
begin
end;function ERReLoadResource(AFileName: String): Boolean; stdcall;
begin
end;end.//ReadInif.pasunit ReadInif;interfaceuses
Windows;{ TMsgServer }type
TIniInfo = class
private { Private declarations }
// ------ 私有数据 ------
protected { Protected declarations }
//
public { public declarations }
// 构造函数和析构函数
constructor Create;
destructor Destroy; override; end;implementation{ TMsgServer }// ---------------- 构造函数和析构函数 ----------------
// 构造函数
constructor TIniInfo.Create;
begin
// 初始化
end;// 析构函数
destructor TIniInfo.Destroy;
begin
// 释放 // 继承
inherited;
end;end.
//ReadResource.dprlibrary ReadResource;{ 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,
ExportUnit in 'ExportUnit.pas',
ReadInif in 'ReadInif.pas';{$R *.RES}begin
end.//ExportUnit.pasunit ExportUnit;interfacefunction ERInitFileName(const AFileName: String): Boolean; stdcall;
function ERReadString(const AFileName, Section, Ident, Default: string): string; stdcall;
function ERReadInteger(const AFileName, Section, Ident: String; Default: Longint): Longint; stdcall;
function ERReadBool(const AFileName, Section, Ident: String; Default: Boolean): Boolean; stdcall;
function ERReLoadResource(AFileName: String): Boolean; stdcall;
exports
ERInitFileName,
ERReadString,
ERReadInteger,
ERReadBool,
ERReLoadResource;implementationfunction ERInitFileName(const AFileName: String): Boolean; stdcall;
beginend;function ERReadString(const AFileName, Section, Ident, Default: string): string; stdcall;
begin
end;function ERReadInteger(const AFileName, Section, Ident: String; Default: Longint): Longint; stdcall;
begin
end;function ERReadBool(const AFileName, Section, Ident: String; Default: Boolean): Boolean; stdcall;
begin
end;function ERReLoadResource(AFileName: String): Boolean; stdcall;
begin
end;end.//ReadInif.pasunit ReadInif;interfaceuses
Windows;{ TMsgServer }type
TIniInfo = class
private { Private declarations }
// ------ 私有数据 ------
protected { Protected declarations }
//
public { public declarations }
// 构造函数和析构函数
constructor Create;
destructor Destroy; override; end;implementation{ TMsgServer }// ---------------- 构造函数和析构函数 ----------------
// 构造函数
constructor TIniInfo.Create;
begin
// 初始化
end;// 析构函数
destructor TIniInfo.Destroy;
begin
// 释放 // 继承
inherited;
end;end.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货