Delphi修改操作注冊表權(quán)限的代碼
更新時(shí)間:2011年09月29日 22:05:59 作者:
Delphi修改操作注冊表權(quán)限的代碼,使用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;
復(fù)制代碼 代碼如下:
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;
您可能感興趣的文章:
相關(guān)文章
Delphi實(shí)現(xiàn)圖像文本旋轉(zhuǎn)特效完整實(shí)例代碼
這篇文章主要介紹了Delphi實(shí)現(xiàn)圖像文本旋轉(zhuǎn)特效完整實(shí)例代碼,對于幫助讀者進(jìn)一步理解Delphi圖形及文字特效的處理有一定的借鑒價(jià)值,需要的朋友可以參考下2014-07-07Delphi實(shí)現(xiàn)Listbox中的item根據(jù)內(nèi)容顯示不同顏色的方法
這篇文章主要介紹了Delphi實(shí)現(xiàn)Listbox中的item根據(jù)內(nèi)容顯示不同顏色的方法,需要的朋友可以參考下2014-07-07截取指定符號之間的字符串(隨機(jī)讀取)delphi實(shí)例代碼
這篇文章主要介紹了截取指定符號之間的字符串(隨機(jī)讀取)delphi實(shí)例代碼,有需要的朋友可以參考一下2013-12-12delphi7連接mysql5的實(shí)現(xiàn)方法
這篇文章主要介紹了delphi7連接mysql5的實(shí)現(xiàn)方法,需要的朋友可以參考下2014-07-07Delphi實(shí)現(xiàn)限定軟件使用時(shí)間的方法
這篇文章主要介紹了Delphi實(shí)現(xiàn)限定軟件使用時(shí)間的方法,商業(yè)軟件開發(fā)中非常實(shí)用的功能,需要的朋友可以參考下2014-07-07Delphi實(shí)現(xiàn)讀取系統(tǒng)時(shí)間與日期完整實(shí)例
這篇文章主要介紹了Delphi實(shí)現(xiàn)讀取系統(tǒng)時(shí)間與日期完整實(shí)例,需要的朋友可以參考下2014-07-07Delphi用TActionList實(shí)現(xiàn)下載文件的方法
這篇文章主要介紹了Delphi用TActionList實(shí)現(xiàn)下載文件的方法,需要的朋友可以參考下2014-07-07