寫好庫文件后 在新單元里;uses一下庫文件單元名就可以使用了 在Delphi中可以用Ctrl+MOUSE左鍵快速轉到对的對應的属性、方法;資源文件 aa.rc//自己先寫好 brcc32 aa //生成aa.res 再另開新項目(新建dll) aa.dpr(大致內容如下)libraryaa; { ...} uses SysUtils, Classes;{$R aa.RES}begin end. 再BuildALl 就會造成aa.dll文件aa.dll就是我們最後所要的東西 在你項目中: {$IFDEF WIN32} const BadDllLoad = 0; {$ELSE} const BadDllLoad = 32; {$ENDIF} function TFmMain.LoadMsg: Boolean; var h : THandle; myp : pchar; i : integer; begin try Result := False; sMsg := TStringList.Create; 2: h := LoadLibrary(pchar(extractfilepath(paramstr(0)) + '\aa.dll')); end; if h <= BadDllLoad then Exit else begin getmem(myp, 255); for i := 1 to cMax do begin loadstring(h, i, myp, 255); sMsg.Append(myp); end; FreeLibrary(h); end; except Result := False; end; Result := True; end;
在新單元里;uses一下庫文件單元名就可以使用了
在Delphi中可以用Ctrl+MOUSE左鍵快速轉到对的對應的属性、方法;資源文件
aa.rc//自己先寫好
brcc32 aa //生成aa.res
再另開新項目(新建dll) aa.dpr(大致內容如下)libraryaa;
{ ...}
uses
SysUtils,
Classes;{$R aa.RES}begin
end.
再BuildALl 就會造成aa.dll文件aa.dll就是我們最後所要的東西
在你項目中:
{$IFDEF WIN32}
const
BadDllLoad = 0;
{$ELSE}
const
BadDllLoad = 32;
{$ENDIF}
function TFmMain.LoadMsg: Boolean;
var
h : THandle;
myp : pchar;
i : integer;
begin
try
Result := False; sMsg := TStringList.Create; 2: h := LoadLibrary(pchar(extractfilepath(paramstr(0)) + '\aa.dll'));
end; if h <= BadDllLoad then
Exit
else
begin
getmem(myp, 255);
for i := 1 to cMax do
begin
loadstring(h, i, myp, 255);
sMsg.Append(myp);
end;
FreeLibrary(h);
end;
except
Result := False;
end;
Result := True;
end;