Вниз
Скачать: CL | DM;

Как определить кем создан файл?   Найти похожие ветки 

← →
NAU   (2002-09-04 05:48) [0]

Подскажите, как определить имя пользователя создавшего файл, владельца файла?


← →
Ученик ©   (2002-09-04 09:30) [1]

function GetFileOwner(const FileName : string; var Domain, UserName : string) : Boolean;
var
bOwnerDefaulted : Bool;
psd : PSECURITY_DESCRIPTOR;
sid : PSID;
dwDomainSize, dwUserNameSize, dwSize, dwUse : DWord;
begin
Result := False;
if not GetFileSecurity(PChar(FileName), OWNER_SECURITY_INFORMATION, nil,
0, dwSize) and (GetLastError = ERROR_INSUFFICIENT_BUFFER) then begin
psd := HeapAlloc(GetProcessHeap, 8, dwSize);
if psd <> nil then try
if GetFileSecurity(PChar(FileName), OWNER_SECURITY_INFORMATION,
psd, dwSize, dwSize) and GetSecurityDescriptorOwner(psd, sid, bOwnerDefaulted) then begin
dwUserNameSize := 0;
dwDomainSize := 0;
if not LookupAccountSid(nil, sid, nil, dwUserNameSize, nil, dwDomainSize, dwUse) and
(GetLastError = ERROR_INSUFFICIENT_BUFFER) then begin
SetLength(Domain, dwDomainSize);
SetLength(UserName, dwUserNameSize);
Result := LookupAccountSid(nil, sid, PChar(UserName), dwUserNameSize,
PChar(Domain), dwDomainSize, dwUse);
if Result then begin
SetLength(Domain, dwDomainSize);
SetLength(UserName, dwUserNameSize)
end
end
end
finally
HeapFree(GetProcessHeap, 0, psd)
end
end
end;



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.44 MB
Время: 0.014 c
4-51024
Cobalt
2002-07-20 12:08
2002.09.16
Глючит RegEnumValues


14-50912
~Rand~
2002-08-19 23:38
2002.09.16
WinXP на Р2


1-50743
AFrolov
2002-09-05 16:18
2002.09.16
Как у StringGrid спрятать колонку?


3-50619
Igoryan
2002-08-26 17:40
2002.09.16
Работа С ODBC


1-50690
Masa
2002-09-04 16:55
2002.09.16
TreeView




   Наверх