Delphi修改操作注册表权限的代码
Delphi修改操作注册表权限的代码
发布时间:2016-12-28 来源:查字典编辑
摘要:需要usesjclwin32,AccCtrl;此文件需要安装JCL复制代码代码如下:functionAllowRegKeyForEveryo...

需要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;

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Delphi学习
热门Delphi学习
编程开发子分类