I
ili
Unregistered / Unconfirmed
GUEST, unregistred user!
DLL文件代码:
library Project2;
uses
ShareMem,
SysUtils,
Classes;
{$R *.res}
function GetRegInfo: string
stdcall;
begin
Result := 'aaa';
end;
exports
GetRegInfo;
begin
end.
EXE文件代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
RegInfo: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TGetRegInfo = function : string;
var
Form1: TForm1;
CurrentDir: string
{当前绝对路径}
theHandle: THandle;
GetRegIf: TGetRegInfo;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
CurrentDir := GetCurrentDir
{取得当前绝对路径}
{获取注册信息}
theHandle := LoadLibrary(PChar(CurrentDir + '/Project2.dll'));
if theHandle >= 32 then
begin
GetRegIf := GetProcAddress(theHandle, 'GetRegInfo');
RegInfo.Caption := TGetRegInfo(GetRegIf);
FreeLibrary(theHandle);
end;
end
// <-单步运行到这儿出错:Project E:/MyPro/Temp/Project1.exe faulted with message:'access violation at 0x00e60bb4:read of address 0x00e60bb4'.Process Stopped.Use Step or Run to continu.
end.
[red]大哥们救命那!!很急的![/red]
library Project2;
uses
ShareMem,
SysUtils,
Classes;
{$R *.res}
function GetRegInfo: string
stdcall;
begin
Result := 'aaa';
end;
exports
GetRegInfo;
begin
end.
EXE文件代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
RegInfo: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TGetRegInfo = function : string;
var
Form1: TForm1;
CurrentDir: string
{当前绝对路径}
theHandle: THandle;
GetRegIf: TGetRegInfo;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
CurrentDir := GetCurrentDir
{取得当前绝对路径}
{获取注册信息}
theHandle := LoadLibrary(PChar(CurrentDir + '/Project2.dll'));
if theHandle >= 32 then
begin
GetRegIf := GetProcAddress(theHandle, 'GetRegInfo');
RegInfo.Caption := TGetRegInfo(GetRegIf);
FreeLibrary(theHandle);
end;
end
// <-单步运行到这儿出错:Project E:/MyPro/Temp/Project1.exe faulted with message:'access violation at 0x00e60bb4:read of address 0x00e60bb4'.Process Stopped.Use Step or Run to continu.
end.
[red]大哥们救命那!!很急的![/red]