Ctrl+Alt+Del Simultuniously ( Continue)

Dear Expert
  From Mr. Deighton answer me, it can use with Windows 95 only( This program is written with VB5.)  And when I test with Windows NT, it is not applicable...

  Why it is not applicable? Pls asnwer me
u3520384Asked:
Who is Participating?
 
hesConnect With a Mentor Commented:
To usetheshutdown in NT use the following:

In a module:

Option Explicit

Private Type LUID
   LowPart As Long
   HighPart As Long
End Type
Private Type LUID_AND_ATTRIBUTES
        pLuid As LUID
        Attributes As Long
End Type
Private Type TOKEN_PRIVILEGES
    PrivilegeCount As Long
    Privileges(1) As LUID_AND_ATTRIBUTES
End Type

Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
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

Private Const EWX_LOGOFF = 0
Private Const EWX_SHUTDOWN = 1
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

In the program:

Private Sub Form_Load()
Dim MyFlag As Long, Ret As Boolean
' Always execute a force shutdown if a shutdown is required
MyFlag = EWX_FORCE
 ' Grab the shutdown privilege - else reboot will fail
SetShutDownPrivilege
' Do the required action
Ret = ExitWindowsEx(EWX_FORCE Or EWX_LOGOFF Or EWX_SHUTDOWN Or EWX_REBOOT, 0)
Form1.Caption = "RC = " & Ret
End Sub



Private Sub SetShutDownPrivilege()
Dim Phndl As Long, Thndl As Long
Dim MyLUID As LUID
Dim MyPriv As TOKEN_PRIVILEGES, MyNewPriv As TOKEN_PRIVILEGES
Phndl = GetCurrentProcess()
OpenProcessToken Phndl, TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY, Thndl
LookupPrivilegeValue "", "SeShutdownPrivilege", MyLUID
MyPriv.PrivilegeCount = 1
MyPriv.Privileges(0).Attributes = SE_PRIVILEGE_ENABLED
MyPriv.Privileges(0).pLuid = MyLUID
' Now to set shutdown privilege for my app
AdjustTokenPrivileges Thndl, False, MyPriv, 4 + (12 * MyPriv.PrivilegeCount), MyNewPriv, 4 + (12 * MyNewPriv.PrivilegeCount)
End Sub

0
 
RuchiCommented:
It is not applicable because of Windows NT's protection.
0
 
mcriderCommented:
Read the following microsoft KB Article:


HOWTO: Block CTRL+ALT+DEL and ALT+TAB in Windows 95 or Windows 98
http://support.microsoft.com/support/kb/articles/q161/1/33.asp?LNG=ENG&SA=MSDN 
 

Cheers!
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
RuchiCommented:
I think in your Windows NT, one function is missing -- RegisterServiceProcess.
0
 
u3520384Author Commented:
From Mr. Deighton ;
Call ExitWindowsEx(EWX_SHUTDOWN Or EWX_FORCE, 0)

or

Call ExitWindowsEx(EWX_REBOOT Or EWX_FORCE, 0)

or

Call ExitWindowsEx(EWX_SHUTDOWN, 0)

or

Call ExitWindowsEx(EWX_REBOOT, 0)

Chose one of the above to either shutdown or reboot eith force or not.

then


in a .bas module

'Api function and the constants required for ExitWindowsEx
Declare Function ExitWindowsEx& Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long)
Public Const EWX_FORCE = 4
Public Const EWX_LOGOFF = 0
Public Const EWX_REBOOT = 2
Public Const EWX_SHUTDOWN = 1


======================
From Above answer, It is applicable with Windows 95 only , If I want my application is applicable on win NT and Win 98 also..

How do I do?

 
 

 

0
 
u3520384Author Commented:
Adjusted points to 100
0
All Courses

From novice to tech pro — start learning today.