请教各位 在关闭WIN2000/WIN NT 时是使用的那个参数是什么参数。
请教各位 在关闭WIN200/WIN NT 时是使用的那个参数是什么参数,我试了几个都不型啊。 问题点数:20、回复次数:9Top
1 楼ilikeff8(迷茫)回复于 2003-02-03 16:17:49 得分 0
?
WM_CLOSETop
2 楼huzhangyou(信仰(http://www.libing.net.cn))回复于 2003-02-05 13:08:10 得分 0
他需要adjusttoken
参数你可以看看msdn旧可以了
网上有很多这样的资料Top
3 楼yeahchang(Studying PKI)回复于 2003-02-05 15:07:54 得分 5
先要:
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
OpenProcessToken (GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,& hToken);
LookupPrivilegeValue (NULL,SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
tkp.PrivilegeCount =1;
tkp.Privileges[0].Attributes =SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken,FALSE,&tkp,0,(PTOKEN_PRIVILEGES)NULL,0);Top
4 楼szbug(深圳虫)回复于 2003-02-05 16:20:25 得分 0
SHUTDOWNTop
5 楼usingpete(迷失自我)回复于 2003-02-05 16:35:51 得分 0
先要获得管理权限
Privileges
A privilege is the right of an account, such as a user or group account, to perform various system-related operations on the local computer, such as shutting down the system, loading device drivers, or changing the system time. Privileges differ from access rights in two ways:
Privileges control access to system resources and system-related tasks, whereas access rights control access to securable objects.
A system administrator assigns privileges to user and group accounts, whereas the system grants or denies access to a securable object based on the access rights granted in the ACEs in the object's DACL.
Each Windows NT/Windows 2000/Windows XP system has an account database that stores the privileges held by user and group accounts. When a user logs on, the system produces an access token that contains a list of the user's privileges, including those granted to the user or to groups to which the user belongs. Note that the privileges apply only to the local computer; a domain account can have different privileges on different computers.
When the user tries to perform a privileged operation, the system checks the user's access token to determine whether the user holds the necessary privileges, and if so, it checks whether the privileges are enabled. If the user fails these tests, the system does not perform the operation. For a table of the privileges defined by Windows, see Windows NT Privileges.
To determine the privileges held in an access token, call the GetTokenInformation function, which also indicates which privileges are enabled. Most privileges are disabled by default.
Before you can perform a privileged operation, you must first enable the necessary privileges in your access token. To do this, call the OpenThreadToken function to get a handle to your primary or impersonation access token, then call the AdjustTokenPrivileges function to enable the necessary privileges. After performing the privileged operation, call AdjustTokenPrivileges again to disable the privileges. For sample code that enables and disables a token's privileges, see Enabling and Disabling Privileges.
The GetTokenInformation and AdjustTokenPrivileges functions use a TOKEN_PRIVILEGES structure to specify an array of privileges and their attributes. This structure contains an array of LUID_AND_ATTRIBUTES structures, each of which specifies the LUID of a privilege and a set of bit flags that indicate the attributes of the privilege, such as whether the privilege is enabled.
The Windows API defines a set of string constants to identify the various privileges. These constants are the same on all Windows NT/Windows 2000/Windows XP systems. However, the functions that get and adjust the privileges in an access token use the LUID type to identify privileges. The LUID values for a privilege can differ from one computer to another, and from one boot to another on the same computer. To get the current LUID that corresponds to one of the string constants, use the LookupPrivilegeValue function. Use the LookupPrivilegeName function to convert a LUID to its corresponding string constant.
The system provides a set of strings that describe each of the Windows NT privileges defined in Winnt.h. These are useful when you need to display a description of a privilege to the user. Use the LookupPrivilegeDisplayName function to retrieve a description string that corresponds to the string constant for a privilege. For example, on systems that use U.S. English, the display name for the SE_SYSTEMTIME_NAME privilege is "Change the system time".
You can use the PrivilegeCheck function to determine whether an access token holds a specified set of privileges. This is useful primarily to server applications that are impersonating a client.
A system administrator can use administrative tools, such as User Manager, to add or remove privileges for user and group accounts. Administrators can programmatically use the Lsa functions to work with privileges. The LsaAddAccountRights and LsaRemoveAccountRights functions add or remove privileges from an account. The LsaEnumerateAccountRights function enumerates the privileges held by a specified account. The LsaEnumerateAccountsWithUserRight function enumerates the accounts that hold a specified privilege.
摘自msdn
再用ExitWindowsExTop
6 楼Behard(我爱天安门)回复于 2003-02-08 10:15:46 得分 10
DWORD dwVersion = GetVersion();
if (dwVersion < 0x80000000) //NT and 2000
{
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken);
LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,&tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,(PTOKEN_PRIVILEGES)NULL,0);
//ExitWindowsEx(EWX_SHUTDOWN|EWX_FORCE|EWX_POWEROFF,0);
ExitWindowsEx(EWX_SHUTDOWN|EWX_POWEROFF,0);
}
else //9X
ExitWindowsEx(EWX_SHUTDOWN|EWX_POWEROFF,0);
Top
7 楼tccsdn(紫乐)回复于 2003-02-08 21:32:50 得分 0
同意楼上的Top
8 楼2wuliao(无疗)回复于 2003-02-09 10:34:33 得分 5
HANDLE hToken;TOKEN_PRIVILEGES tkp;HANDLE getHandle;
getHandle=GetCurrentProcess();
OpenProcessToken(getHandle ,TOKEN_ADJUST_PRIVILEGES,&hToken);
LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,&tkp.Privileges[0].Luid);
tkp.PrivilegeCount =1;
tkp.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken,false,&tkp,NULL,NULL,NULL);
ExitWindowsEx(EWX_POWEROFF,0);Top
9 楼zihan(子寒)回复于 2003-02-10 16:04:27 得分 0
搜索吧,肯定一大堆Top




