フォルダーのファイル作成権限をプログラムで確認するにはどうすればよいですか? ファイルのパーミッションを変更しますか? ファイル権限を削除しますか?
GetNamedSecurityInfo
書き込み可能なリターンが返されますC:\Program Files
が、UAC はAccess Denied (5)
アクセス許可を効果的に決定するにはどうすればよいですか?
私のコード:
function GetAccessRights(const FileName: String; ObjectType: SE_OBJECT_TYPE;
var Access: Cardinal): Cardinal;
var
SecDesc: PSECURITY_DESCRIPTOR;
pDacl: PACL;
Trusteee: TRUSTEE_;
begin
result := GetNamedSecurityInfo(PChar(FileName), ObjectType,
DACL_SECURITY_INFORMATION, nil, nil, @pDacl, nil, SecDesc);
if ERROR_SUCCESS = result then
begin
// the pDacl may be NULL if the object has unrestricted access
if pDacl <> nil then
begin
with Trusteee do
begin
pMultipleTrustee := nil;
MultipleTrusteeOperation := NO_MULTIPLE_TRUSTEE;
TrusteeForm := TRUSTEE_IS_NAME;
TrusteeType := TRUSTEE_IS_UNKNOWN;
ptstrName := 'CURRENT_USER';
end;
result := GetEffectiveRightsFromAcl(pDacl^, Trusteee, Access);
end
else
begin
Access := $FFFFFFFF;
result := ERROR_SUCCESS;
end;
if SecDesc <> nil then
LocalFree(Cardinal(SecDesc));
end;
end;