读书人

DLL工程里 全局变量该怎么声明(只在本

发布时间: 2012-02-13 17:20:26 作者: rapoo

DLL工程里 全局变量该如何声明(只在本DLL两个函数中使用)
例如下面一个DLL工程,我想在Triple 和 Double 使用一个全局的变量,那么这个变量应该声明在哪里?

library Project1;

{ 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. }

{$S-}
uses
SysUtils,
Classes,
Dialogs,
windows,
CommCtrl;

function Triple(N:Integer):integer;stdcall;
begin
result:=N+3;
end;

function Double(N:Integer):integer;stdcall;
begin
result:=N+2;
end;

function Triple1(N:Integer):integer;stdcall;
begin
showmessage('计算N+3');
result:=N+3;
end;

function Double1(N:Integer):integer;stdcall;
begin
messagebox(0,'计算N+2','计算N+2',mb_ok);
result:=N+2;
end;

function ListViewColumnCount(mHandle: THandle): Integer;
begin
Result := Header_GetItemCount(ListView_GetHeader(mHandle));
end; { ListViewColumnCount }

exports
Triple name 'Tr',
Double name 'Do',
Triple1 name 'TrM',
Double1 name 'DoM',

begin
end.

[解决办法]
{$S-}
uses
SysUtils,
Classes,
Dialogs,
windows,
CommCtrl;
[解决办法]
提示是[Hint]类型的,肯定可以编译通过的,又不是[Error]
编译器只不过是提示你一下而已:b这个变量已经定义了,但没有使用过。

读书人网 >.NET

热点推荐