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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
RuchiCommented:
I think in your Windows NT, one function is missing -- RegisterServiceProcess.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

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
hesCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.