//得到office2007安装目录
ARegistry := TRegistry.Create;
ARegistry.RootKey:=HKEY_LOCAL_MACHINE;
if ARegistry.KeyExists('SOFTWARE\Microsoft\Office\12.0\Common\InstallRoot') then
begin if ARegistry.OpenKey('SOFTWARE\Microsoft\Office\12.0\Common\InstallRoot',false) then
begin
ARegistry.OpenKey('SOFTWARE\Microsoft\Office\12.0\Common\InstallRoot',false) ;
officepath:=ARegistry.ReadString('Path');
//showmessage(officepath) ;
end;
ARegistry.CloseKey;
else
begin
showmessage('office2007没有安装');
Application.Terminate;
end;
ARegistry.Destroy;请教如何才能得到权限?
ARegistry := TRegistry.Create;
ARegistry.RootKey:=HKEY_LOCAL_MACHINE;
if ARegistry.KeyExists('SOFTWARE\Microsoft\Office\12.0\Common\InstallRoot') then
begin if ARegistry.OpenKey('SOFTWARE\Microsoft\Office\12.0\Common\InstallRoot',false) then
begin
ARegistry.OpenKey('SOFTWARE\Microsoft\Office\12.0\Common\InstallRoot',false) ;
officepath:=ARegistry.ReadString('Path');
//showmessage(officepath) ;
end;
ARegistry.CloseKey;
else
begin
showmessage('office2007没有安装');
Application.Terminate;
end;
ARegistry.Destroy;请教如何才能得到权限?
解决方案 »
- 使用adoquery,删除记录,但同时删除多个记录了,怎么办?
- 手机发短信的非一般问题!!!
- 请问整型和浮点型如何互相转换?
- 请问如何在delphi脚码k正常输入俄文字符
- 全局變量的聲明方法問題
- fireMonkey的HD程序可以用ADO组件在MAC系统连接数据库吗?
- 请问,如何使 textout() 输出的字符的背景色,与form的颜色一致!(在线求教!!)
- 急救。。语句错在哪?adoquery1.SQL.add('select ygdm,ygxm from user where ygdm='''+edit1.text+'''');
- 怎么样将一个文本和图片混合的文件中的图片流数据提取出来并且保存到一个图片文件中
- 关于用QUERY打开表到DBGRID的问题(HIGH SCORE)
- 发布自画TlistView带进度条的Item 源码
- 需要TMS INTRAWEB 9.0.15 for D2007 的源码文件。
在程序中判断运行权限const
SECURITY_BUILTIN_DOMAIN_RID:Cardinal = $00000020;
DOMAIN_ALIAS_RID_ADMINS:Cardinal = $00000220;
var
SECURITY_NT_AUTHORITY:SID_IDENTIFIER_AUTHORITY;
function IsAdmin: Boolean;
var
hAccessToken: THandle;
ptgGroups: PTokenGroups;
dwInfoBufferSize: DWORD;
psidAdministrators: PSID;
x: Integer;
bSuccess: BOOL;
begin
Result := False;
bSuccess := OpenThreadToken(GetCurrentThread, TOKEN_QUERY, True, hAccessToken);
if not bSuccess then begin
if GetLastError = ERROR_NO_TOKEN then
bSuccess := OpenProcessToken(GetCurrentProcess, TOKEN_QUERY, hAccessToken);
end;
if bSuccess then begin
GetMem(ptgGroups, 1024);
bSuccess := GetTokenInformation(hAccessToken, TokenGroups, ptgGroups, 1024, dwInfoBufferSize);
CloseHandle(hAccessToken);
if bSuccess then begin
SECURITY_NT_AUTHORITY.Value[5] := 5;
AllocateAndInitializeSid(SECURITY_NT_AUTHORITY, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, psidAdministrators);
{$R-}
for x := 0 to ptgGroups.GroupCount - 1 do
if EqualSid(psidAdministrators, ptgGroups.Groups[x].Sid) then begin
Result := True;
Break;
end;
{$R+}
FreeSid(psidAdministrators);
end;
FreeMem(ptgGroups);
end;
end;//////////////////////////////////////////////////if not IsAdmin then begin
MessageBox(Self.Handle, Pchar('本程序需要管理员权限才能正常运行!'), nil, 0);
Close;
end;
不过不合我的要求
我的程序要求:不管用户权限,能够得到相应的值
后来如此解决,调用regedit,导出相应的值再差别
再生成相应的reg文件,导入
user权限HKEY_CURRENT_USER下面的项能正常读写