function FindNextFileNameW(
Handle:Cardinal;
var DatLänge:PDWORD;
var LinkName:PWChar): Boolean;
type
TFindNextFileNameW =
function(
Handle:Cardinal;
var DatLänge:PDWORD;
var LinkName:PWChar): Boolean;
stdcall;
var
kernel32: HModule;
_TFindNextFileNameW: TFindNextFileNameW;
begin
kernel32 := GetModuleHandle('
kernel32');
@_TFindNextFileNameW := GetProcAddress(kernel32, '
FindNextFileNameW');
Result := _TFindNextFileNameW(
Handle,DatLänge,LinkName);
end;
function FindFirstFileNameW(Dateiname:PWideChar;Marker:Cardinal;
var DatLänge:PDWORD;
var LinkName:PWChar): Cardinal;
type
TFindFirstFileNameW =
function(Dateiname:PWideChar;Marker:Cardinal;
var DatLänge:PDWORD;
var LinkName:PWChar): Cardinal;
stdcall;
var
kernel32: HModule;
_TFindFirstFileNameW: TFindFirstFileNameW;
begin
kernel32 := GetModuleHandle('
kernel32');
@_TFindFirstFileNameW := GetProcAddress(kernel32, '
FindFirstFileNameW');
Result := _TFindFirstFileNameW(Dateiname,0,DatLänge,LinkName);
end;
function CloseHFile(
Handle:Cardinal): Boolean;
type
TCloseHFile =
function(
Handle:Cardinal): Boolean;
stdcall;
var
kernel32: HModule;
_TCloseHFile: TCloseHFile;
begin
kernel32 := GetModuleHandle('
kernel32');
@_TCloseHFile := GetProcAddress(kernel32, '
FindClose');
Result := _TCloseHFile(
Handle);
end;
procedure TForm1.ZeigeHardlinks;
var
Dateiname : WideString;
DatLänge : Cardinal;
PDatLänge : PDWORD;
LinkName : WideChar;
PLinkName : PWideChar;
Handle : Cardinal;
begin
Dateiname := '
C:\Temp\Hardlink.JPG';
PLinkName := @LinkName;
PDatLänge := @DatLänge;
Handle := FindFirstFileNameW(PWideChar(Dateiname),0,PDatLänge,PLinkName);
If Handle = 4294967295
then Showmessage(SysErrorMessage(GetLastError));
Showmessage(WideCharToString(@PLinkName));
While FindNextFileNameW(
Handle,PDatLänge,PLinkName)
do
Showmessage(WideCharToString(@PLinkName));
CloseHFile(
Handle);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ZeigeHardlinks;
end;