H
hpretty
Unregistered / Unconfirmed
GUEST, unregistred user!
function GetHDDSerioNum: string;
var
proc: function: PChar; stdcall;
hMod: THandle;
begin
Result := '';
hMod := LoadLibrary('syswin60.DLL');
if (hMod = 0) then Exit;
try
@proc := GetProcAddress(hMod, 'GetNumber');
if (@proc <> nil) then
begin
Result := proc;
end;
finally
FreeLibrary(hMod);
end;
end;
这个方法调用没问题,
function GetHexString(const s :string): string;
var
proc: function(const s char): PChar; stdcall;
hMod: THandle;
begin
Result := '';
hMod := LoadLibrary('syswin60.DLL');
if (hMod = 0) then Exit;
try
@proc := GetProcAddress(hMod, 'StringToHex');
if (@proc <> nil) then
begin
Result := proc(pchar(s));
//Form1.caption := proc(s);
end;
finally
FreeLibrary(hMod);
end;
end;
这个就不行了。
下面是这两个函数的原码!
function StringToHex(const s: pchar): Pchar;
var
hex: string;
i: Integer;
begin
hex := '';
for i := 1 to Length(s) do
begin
hex := hex + IntToHex(Ord(s), 2);
end;
Result := pchar(Hex);
end;
function GetNumber: PChar;
var
proc: function: PChar; stdcall;
hMod: THandle;
begin
Result := '';
hMod := LoadLibrary('syswin60.DLL');
if (hMod = 0) then Exit;
try
@proc := GetProcAddress(hMod, 'GetNumber');
if (@proc <> nil) then
begin
Result := proc;
end;
finally
FreeLibrary(hMod);
end;
end;
这个方法调用没问题,
function GetHexString(const s :string): string;
var
proc: function(const s char): PChar; stdcall;
hMod: THandle;
begin
Result := '';
hMod := LoadLibrary('syswin60.DLL');
if (hMod = 0) then Exit;
try
@proc := GetProcAddress(hMod, 'StringToHex');
if (@proc <> nil) then
begin
Result := proc(pchar(s));
//Form1.caption := proc(s);
end;
finally
FreeLibrary(hMod);
end;
end;
这个就不行了。
下面是这两个函数的原码!
function StringToHex(const s: pchar): Pchar;
var
hex: string;
i: Integer;
begin
hex := '';
for i := 1 to Length(s) do
begin
hex := hex + IntToHex(Ord(s), 2);
end;
Result := pchar(Hex);
end;
function GetNumber: PChar;