如何偵測資料夾存取權限? |
尚未結案
|
MingLin
一般會員 發表:24 回覆:26 積分:10 註冊:2002-09-20 發送簡訊給我 |
|
aquarius
資深會員 發表:3 回覆:347 積分:330 註冊:2003-05-21 發送簡訊給我 |
|
MingLin
一般會員 發表:24 回覆:26 積分:10 註冊:2002-09-20 發送簡訊給我 |
|
qoo1234
版主 發表:256 回覆:1167 積分:659 註冊:2003-02-24 發送簡訊給我 |
http://www.delphitips.com/tipstext.cgi?tipsId=73
// When you create a file or directory, you become the owner of it. // With GetFileOwner you get the owner of a file. function GetFileOwner(FileName: string; var Domain, Username: string): Boolean; var SecDescr: PSecurityDescriptor; SizeNeeded, SizeNeeded2: DWORD; OwnerSID: PSID; OwnerDefault: BOOL; OwnerName, DomainName: PChar; OwnerType: SID_NAME_USE; begin GetFileOwner := False; GetMem(SecDescr,1024); GetMem(OwnerSID,SizeOf(PSID)); GetMem(OwnerName,1024); GetMem(DomainName,1024); try if not GetFileSecurity(PChar(FileName), OWNER_SECURITY_INFORMATION, SecDescr,1024,SizeNeeded) then Exit; if not GetSecurityDescriptorOwner(SecDescr, OwnerSID,OwnerDefault) then Exit; SizeNeeded := 1024; SizeNeeded2 := 1024; if not LookupAccountSID(nil,OwnerSID,OwnerName, SizeNeeded,DomainName,SizeNeeded2,OwnerType) then Exit; Domain := DomainName; Username := OwnerName; finally FreeMem(SecDescr); FreeMem(OwnerName); FreeMem(DomainName); end; GetFileOwner := True; end; procedure TForm1.Button1Click(Sender: TObject); var Domain, Username: string; begin GetFileOwner('YourFile.xyz',domain,username); ShowMessage(username '@' domain); end;網海無涯,唯學是岸! 因為擁有,所以分享! |
MingLin
一般會員 發表:24 回覆:26 積分:10 註冊:2002-09-20 發送簡訊給我 |
|
aquarius
資深會員 發表:3 回覆:347 積分:330 註冊:2003-05-21 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |