信息发布→ 登录 注册 退出

Delphi修改操作注册表权限的代码

发布时间:2026-01-11

点击量:
需要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;
标签:# Len  # HKEY_CURRENT_USER  # AllowRegKeyForEveryone  # function  # Key  # Path  # HKEY  # AccCtrl  # JCL  # span  # BR  # Integer  # Delphi  # case  # MACHINE  # HKEY_LOCAL_MACHINE  # Boolean  # string  # var  # PWideChar  # WidePath  # Delphi 常见文件处理及注册表文件的使用实例  # 注册表  
在线客服
服务热线

服务热线

4008888355

微信咨询
二维码
返回顶部
×二维码

截屏,微信识别二维码

打开微信

微信号已复制,请打开微信添加咨询详情!