通常我们在查看 Windows 的 DLL 的时候,总是能看到一些隐含函数,这些函数即使在MS的文档中也没有说明,当然有些高手则可以通过 index 来调用某些未公开函数。那么我们有办法在 delphi 中生成没函数名的 dll 吗?当然可以。
library Project2;
{ 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;
{$R *.res}
procedure a; begin
end;
procedure b; begin
end;
exports a index 1 name '', b index 2 name '';
begin end.
注意,a和b两个函数在生成了 dll 后都看不到名字。如果把他们后面的 name ''去掉的话,编译后的 dll 将能看到a和b两个函数。