📄 18.htm
字号:
<!-- saved from url=(0022)http://internet.e-mail -->
<html>
<head>
<title>可获得管理员权限的登录方法 </title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="inc.css">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#000000" vlink="195434" alink="195434">
<table width="621" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="621"><a href="http://www.CoDelphi.com"><img src="images/logo.gif" border="0" width="153" height="60"><img src="images/bigbanner.gif" border="0" width="468" height="60"></a></td>
</tr>
</table><br>
<br>
<table width="621" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="left" valign="top" class="font9" height="155">
<div align="center" class="btitle">可获得管理员权限的登录方法 <br>
<br>
</div>
<div align="center"><strong>CoDelphi.com </strong></div>
<b><br>
摘 要</b>:我如何登录才能获得管理员权限? <br>
<b> 关键字</b>:OpenThreadToken GetTokenInformation 管理员 <br>
<b> 类 别</b>:系统控制
<hr size="1" width="100%">
<span class="content">const <Br> SECURITY_NT_AUTHORITY: TSIDIdentifierAuthority = <Br> (Value: (0, 0, 0, 0, 0, 5)); <Br> SECURITY_BUILTIN_DOMAIN_RID = $00000020; <Br> DOMAIN_ALIAS_RID_ADMINS = $00000220; <Br><Br>function IsAdmin: Boolean; <Br>var <Br> hAccessToken: THandle; <Br> ptgGroups: PTokenGroups; <Br> dwInfoBufferSize: DWORD; <Br> psidAdministrators: PSID; <Br> x: Integer; <Br> bSuccess: BOOL; <Br>begin <Br> Result := False; <Br> bSuccess := OpenThreadToken(GetCurrentThread, TOKEN_QUERY, True, <Br> hAccessToken); <Br> if not bSuccess then <Br> begin <Br> if GetLastError = ERROR_NO_TOKEN then <Br> bSuccess := OpenProcessToken(GetCurrentProcess, TOKEN_QUERY, <Br> hAccessToken); <Br> end; <Br> if bSuccess then <Br> begin <Br> GetMem(ptgGroups, 1024); <Br> bSuccess := GetTokenInformation(hAccessToken, TokenGroups, <Br> ptgGroups, 1024, dwInfoBufferSize); <Br> CloseHandle(hAccessToken); <Br> if bSuccess then <Br> begin <Br> AllocateAndInitializeSid(SECURITY_NT_AUTHORITY, 2, <Br> SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, <Br> 0, 0, 0, 0, 0, 0, psidAdministrators); <Br> {$R-} <Br> for x := 0 to ptgGroups.GroupCount - 1 do <Br> if EqualSid(psidAdministrators, ptgGroups.Groups[x].Sid) then <Br> begin <Br> Result := True; <Br> Break; <Br> end; <Br> {$R+} <Br> FreeSid(psidAdministrators); <Br> end; <Br> FreeMem(ptgGroups); <Br> end; <Br>end; <Br><Br>procedure TForm1.Button1Click(Sender: TObject); <Br>begin <Br> if isAdmin then <Br> begin <Br> ShowMessage('以系统管理员身份登录'); <Br> end; <Br>end.<Br></span>
<table border="0" cellspacing="0" cellpadding="1" class="font9" align="center" width="100%">
<tr align="left" valign="middle" bgcolor="195434">
<td height="1"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#C9C9C6" height="2"></td>
</tr>
</table>
<div align="center"><br>
中文开发在线<a href="http://www.codelphi.com" target="_blank">www.codelphi.com</a>授权使用。
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -