»áÔ±£º ÃÜÂ룺 ¡¡Ãâ·Ñ×¢²á | Íü¼ÇÃÜÂë | »áÔ±µÇ¼ ÍøÒ³¹¦ÄÜ£º ¼ÓÈëÊÕ²Ø ÉèΪÊ×Ò³ ÍøÕ¾ËÑË÷  
 °²È«¼¼Êõ¼¼ÊõÎĵµ
  ¡¤ °²È«ÅäÖÆ
  ¡¤ ¹¤¾ß½éÉÜ
  ¡¤ ºÚ¿Í½Ìѧ
  ¡¤ ·À»ðǽ
  ¡¤ Â©¶´·ÖÎö
  ¡¤ ÆƽâרÌâ
  ¡¤ ºÚ¿Í±à³Ì
  ¡¤ ÈëÇÖ¼ì²â
 °²È«¼¼ÊõÂÛ̳
  ¡¤ °²È«ÅäÖÆ
  ¡¤ ¹¤¾ß½éÉÜ
  ¡¤ ·À»ðǽ
  ¡¤ ºÚ¿ÍÈëÇÖ
  ¡¤ Â©¶´¼ì²â
  ¡¤ Æƽⷽ·¨
  ¡¤ É±¶¾×¨Çø
 °²È«¼¼Êõ¹¤¾ßÏÂÔØ
  ¡¤ É¨Ã蹤¾ß
  ¡¤ ¹¥»÷³ÌÐò
  ¡¤ ºóÃÅľÂí
  ¡¤ ¾Ü¾ø·þÎñ
  ¡¤ ¿ÚÁîÆƽâ
  ¡¤ ´úÀí³ÌÐò
  ¡¤ ·À»ðǽ
  ¡¤ ¼ÓÃܽâÃÜ
  ¡¤ ÈëÇÖ¼ì²â
  ¡¤ ¹¥·ÀÑÝʾ
¼¼ÊõÎĵµ > VBÎĵµ > APIº¯Êý
ÔÚWIN2000ÏÂʵÏÖ³ÌÐòµÄ¹Ø»ú
·¢±íÈÕÆÚ£º2002-06-27 00:00:00×÷ÕߣºÀ ³ö´¦£º  

ÔÚWin2000ϱȽÏÄÑÓã¬Ä㻹Ҫ»ñµÃϵͳȨÏÞµÄ

ÄãÐëÒªÒýÓÃÏÂÃæµÄAPI

Public Const EWX_FORCE = 4

Public Const TOKEN_ADJUST_PRIVILEGES = &H20

Public Const TOKEN_QUERY = &H8

Public Const SE_PRIVILEGE_ENABLED = &H2

Public Const ANYSIZE_ARRAY = 1

Type LUID

  lowpart As Long

  highpart As Long

End Type

Type LUID_AND_ATTRIBUTES

  pLuid As LUID

  Attributes As Long

End Type

Type TOKEN_PRIVILEGES

  PrivilegeCount As Long

  Privileges(ANYSIZE_ARRAY) As LUID_AND_ATTRIBUTES

End Type

Declare Function GetCurrentProcess Lib "kernel32" () As Long

Declare Function LookupPrivilegeValue Lib "advapi32.dll" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, lpLuid As LUID) As Long

Declare Function AdjustTokenPrivileges Lib "advapi32.dll" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, PreviousState As TOKEN_PRIVILEGES, ReturnLength As Long) As Long

Declare Function OpenProcessToken Lib "advapi32.dll" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long

Sub AdjustTokenPrivilegesForNT()

  Dim hdlProcessHandle As Long

  Dim hdlTokenHandle As Long

  Dim tmpLuid As LUID

  Dim tkp As TOKEN_PRIVILEGES

  Dim tkpNewButIgnored As TOKEN_PRIVILEGES

  Dim lBufferNeeded As Long

 

  hdlProcessHandle = GetCurrentProcess()

  OpenProcessToken hdlProcessHandle, (TOKEN_ADJUST_PRIVILEGES Or _

           TOKEN_QUERY), hdlTokenHandle

  LookupPrivilegeValue "", "SeShutdownPrivilege", tmpLuid

  tkp.PrivilegeCount = 1

  tkp.Privileges(0).pLuid = tmpLuid

  tkp.Privileges(0).Attributes = SE_PRIVILEGE_ENABLED

  AdjustTokenPrivileges hdlTokenHandle, False, tkp, _

             Len(tkpNewButIgnored), tkpNewButIgnored, _

             lBufferNeeded

End Sub

¹Ø»úʱÓÃÏÂÃæµÄ´úÂë

  AdjustTokenPrivilegesForNT

  ExitWindowsEx uFlags, 0

 

¡¾·µ»Ø¶¥²¿¡¿ ¡¾´òÓ¡±¾Ò³¡¿ ¡¾¹Ø±Õ´°¿Ú¡¿

¹ØÓÚÎÒÃÇ / ¸øÎÒÁôÑÔ / °æȨ¾Ù±¨ / Òâ¼û½¨Òé / ÍøÕ¾±à³ÌQQȺ   
Copyright ©2003- 2024 Lihuasoft.net webmaster(at)lihuasoft.net ¼ÓÔØʱ¼ä 0.0018