Access������--
ËùÊô·ÖÀࣺ ʵÓôúÂë ×÷Õߣº esmile ¸üÐÂÈÕÆÚ£º2003-11-14 8:32:00 ÔĶÁ´ÎÊý£º290

ÕæÕýʵÏÖÔÚwindows2000ϹػúµÄÔ´´úÂë


Option Compare Database
Option Explicit

Private Const EWX_LOGOFF = 0
Public Const EWX_SHUTDOWN = 1
Public Const EWX_POWEROFF = 8 '´Ë²ÎÊýÔÚVB×Ô´øAPIä¯ÀÀÆ÷²¢Î´Ìṩ£¬ÖµµÃ×¢Ò⣬Èç¹ûûÓд˲ÎÊýÔÚWin2kServer»áËÀÔڹػúÆÁÄ»ÏÂ
Private Const EWX_REBOOT = 2
Private Const EWX_FORCE = 4
Private Const TOKEN_ADJUST_PRIVILEGES = &H20;
Private Const TOKEN_QUERY = &H8;
Private Const SE_PRIVILEGE_ENABLED = &H2;
Private Const ANYSIZE_ARRAY = 1
Private Const VER_PLATFORM_WIN32_NT = 2

Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type

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

Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function OpenProcessToken Lib "advapi32" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long
Private Declare Function LookupPrivilegevalue Lib "advapi32" Alias "LookupPrivilegevalueA" (ByVal lpSystemName As String, ByVal lpName As String, lpLuid As LUID) As Long
Private Declare Function AdjustTokenPrivileges Lib "advapi32" (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
Public Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (ByRef lpVersionInformation As OSVERSIONINFO) As Long


'Detect if the program is running under Windows NT ¼ì²âÊÇ·ñΪNT
Public Function IsWinNT() As Boolean
Dim myOS As OSVERSIONINFO
myOS.dwOSVersionInfoSize = Len(myOS)
GetVersionEx myOS
IsWinNT = (myOS.dwPlatformId = VER_PLATFORM_WIN32_NT)
End Function


'set the shut down privilege for the current application Ϊµ±Ç°Ó¦ÓóÌÐòÉèÖùػúȨÏÞ
Private Sub EnableShutDown()
Dim hProc As Long
Dim hToken As Long
Dim mLUID As LUID
Dim mPriv As TOKEN_PRIVILEGES
Dim mNewPriv As TOKEN_PRIVILEGES
hProc = GetCurrentProcess()
OpenProcessToken hProc, TOKEN_ADJUST_PRIVILEGES + TOKEN_QUERY, hToken
LookupPrivilegevalue "", "SeShutdownPrivilege", mLUID
mPriv.PrivilegeCount = 1
mPriv.Privileges(0).Attributes = SE_PRIVILEGE_ENABLED
mPriv.Privileges(0).pLuid = mLUID
' enable shutdown privilege for the current application ¸³Ó赱ǰӦÓóÌÐò¹Ø»úȨÏÞ
AdjustTokenPrivileges hToken, False, mPriv, 4 + (12 * mPriv.PrivilegeCount), mNewPriv, 4 + (12 * mNewPriv.PrivilegeCount)
End Sub


' Shut Down PC ¹Ø±ÕPC
Public Sub ShutDownPC(Force As Boolean)
Dim ret As Long
Dim Flags As Long
Flags = EWX_SHUTDOWN Or EWX_POWEROFF
If Force Then Flags = Flags + EWX_FORCE
If IsWinNT Then EnableShutDown
ExitWindowsEx Flags, 0
End Sub


'Restart PC ÖØÆðPC
Public Sub RebootPC(Force As Boolean)
Dim ret As Long
Dim Flags As Long
Flags = EWX_REBOOT
If Force Then Flags = Flags + EWX_FORCE
If IsWinNT Then EnableShutDown
ExitWindowsEx Flags, 0
End Sub


'Log off the current user ×¢Ïû£¨µÇ³ö£©µ±Ç°Óû§
Public Sub LogOff(Force As Boolean)
Dim ret As Long
Dim Flags As Long
Flags = EWX_LOGOFF
If Force Then Flags = Flags + EWX_FORCE
ExitWindowsEx Flags, 0
End Sub


'×Ô¶¯¿ª»ú˵Ã÷£º£¨ÒÔCMOS Setup Utility - Copyright (C) 1984-2001 Award Software ΪÀý)
'¿ª»ú°´Delete¼ü½øÈëCMOS Setup³ÌÐò
'°ÑÑ¡ÔñÒƵ½Power Management Setup£¨µçÔ´¹ÜÀíÉèÖÃ), °´»Ø³µ
'È»ºó°ÑÑ¡ÔñÒƵ½Resume by Alarm,°´PageDown¼üÑ¡ÔñEnable
'ÒƵ½ÏÂÒ»ÐаÑDate(of Month) Alarm ÉèΪ0
'ÒƵ½ÏÂÒ»ÐаÑTime(hh:mm:ss) Alarm ÉèΪ[×Ô¼ºµÄ¿ª»úʱ¼ä],ÀýÈ磺8:0:0(ÔçÉÏ8µã¿ª»ú£©

'ÓÉÓÚ¸÷³§¼ÒCMOSÉèÖóÌÐò²»Í¬£¬Çë²ÎÕÕÖ÷°åÅäÌ×˵Ã÷Êé¡£


--------------------------------------------------------------------------------
Ïà¹ØÎÄÕÂ

ÈçºÎÕï¶Ï/ÐÞ¸´Ëð»µµÄ Jet 4.0 Êý¾Ý¿â 2003-10-14 8:31:26


ϵͳÓÅ»¯
¿Ø¼þʹÓÃ
Êý¾Ý¿âÉè¼Æ
Êý¾Ý¿âÁ¬½Ó
ϵͳ°²È«
OLE×Ô¶¯»¯
³£¼ûÎÊÌâ
ʵÓôúÂë
ÊôÐÔÏê½â
ÍøÂçÏà¹Ø
ʵÓÃAPI
¾­Ñé·ÖÏí
¾«Ñ¡½Ì³Ì
×Ö·û´¦Àí
ADPÏà¹Ø



ÎÄÕÂËÑË÷



ÖÆ×÷ά»¤£ºÀîÑ°»¶     Mail:[email protected]

¹ØÓÚ±¾Õ¾ -- ÍøÕ¾·þÎñ -- °æȨÌõ¿î -- ÁªÏµ·½·¨ -- ÍøÕ¾°ïÖú
Access°®ºÃÕß°æȨËùÓÐ Copyright 2003-2005 All Rights Reserved δ¾­Ðí¿É²»µÃµÁÁ´