Delphi修改操作注冊表權限的代碼
更新時間:2011年09月29日 22:05:59 作者:
Delphi修改操作注冊表權限的代碼,使用Delphi的朋友可以參考下。
需要uses jclwin32, AccCtrl; 此文件需要安裝JCL
function AllowRegKeyForEveryone(Key: HKEY; Path: string): Boolean;
var
WidePath: PWideChar;
Len: Integer;
begin
case Key of
HKEY_LOCAL_MACHINE:
Path := 'MACHINE\' + Path;
HKEY_CURRENT_USER:
Path := 'CURRENT_USER\' + Path;
HKEY_CLASSES_ROOT:
Path := 'CLASSES_ROOT\' + Path;
HKEY_USERS:
Path := 'USERS\' + Path;
end;
Len := (Length(Path)+1)*SizeOf(WideChar);
GetMem(WidePath,Len);
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, PChar(Path), -1, WidePath, Len);
Result := SetNamedSecurityInfoW(WidePath, SE_REGISTRY_KEY,
DACL_SECURITY_INFORMATION, nil, nil, nil, nil) = ERROR_SUCCESS;
FreeMem(WidePath);
end;
復制代碼 代碼如下:
function AllowRegKeyForEveryone(Key: HKEY; Path: string): Boolean;
var
WidePath: PWideChar;
Len: Integer;
begin
case Key of
HKEY_LOCAL_MACHINE:
Path := 'MACHINE\' + Path;
HKEY_CURRENT_USER:
Path := 'CURRENT_USER\' + Path;
HKEY_CLASSES_ROOT:
Path := 'CLASSES_ROOT\' + Path;
HKEY_USERS:
Path := 'USERS\' + Path;
end;
Len := (Length(Path)+1)*SizeOf(WideChar);
GetMem(WidePath,Len);
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, PChar(Path), -1, WidePath, Len);
Result := SetNamedSecurityInfoW(WidePath, SE_REGISTRY_KEY,
DACL_SECURITY_INFORMATION, nil, nil, nil, nil) = ERROR_SUCCESS;
FreeMem(WidePath);
end;
您可能感興趣的文章:
相關文章
Delphi中使用ISuperObject解析Json數(shù)據(jù)的實現(xiàn)代碼
這篇文章主要介紹了Delphi中使用ISuperObject解析Json數(shù)據(jù)的實現(xiàn)代碼,需要的朋友可以參考下2017-09-09
delphi 判斷字符串是否包含漢字,正則版與非正則版實現(xiàn)
這篇文章主要介紹了delphi 判斷字符串是否包含漢字,正則版與非正則版實現(xiàn),需要的朋友可以參考下2022-12-12
Windows API GetLastError()函數(shù)返回值含義解釋
這篇文章主要介紹了Windows API GetLastError()函數(shù)返回值含義解釋,本文羅列了所有錯誤代碼及中文注釋,需要的朋友可以參考下2015-05-05

