We help IT Professionals succeed at work.

Explorer

mravell
mravell asked
on
Medium Priority
523 Views
Last Modified: 2008-02-01
I'm playing around with controlling access to a PC (W2k) by replacing the registry Shell entry with a VB program. This is done so that I can time the use of the PC (It's for a LAN gaming site) as well as billing, access control etc. The VB prog in turn launches explorer.exe.

Now this seems to work fine until I get to the stage where I wish to kill off explorer. i.e Log out.

I'm using :

    Call SendMessage(glHandle, WM_CLOSE, 0&, 0&)

Now when this is tried on explorer.exe I get the "What do you want the computer to do?" Screen that is what you normally receive when you do a Start Menu -> Shutdown.

Any idea how I can get explorer.exe to die more gracefully?



Regards
Marty
Comment
Watch Question

Did you try WM_DESTROY message instead of WM_CLOSE?

You may try
call SendMessage(gIHandle, WM_DESTROY, 0, 0)


From MSDN:
An application can prompt the user for confirmation, prior to destroying a window, by processing the WM_CLOSE message and calling the DestroyWindow function only if the user confirms the choice.

Author

Commented:
Ark
CERTIFIED EXPERT

Commented:
Shell "RUNDLL32.EXE shell32SHExitWindowsEx -1"
CERTIFIED EXPERT
Commented:
Oops, sorry, missed comma:
Should be
Shell "RUNDLL32.EXE shell32,SHExitWindowsEx -1"

Cheers
Ark
CERTIFIED EXPERT

Commented:
PS
Or, you can call ExitWindowsEx through API with this undoc flag

Author

Commented:
Would need a little more info. What does the

Shell "RUNDLL32.EXE shell32,SHExitWindowsEx -1"

actually do?

Exactly what do I need in my VB prog. Assume I know nothing (always a pretty good bet).



Regards
Marty
Ark
CERTIFIED EXPERT

Commented:
'Restart explorer without rebooting machine
Shell "RUNDLL32.EXE shell32,SHExitWindowsEx -1"
'/* In the General Declarations Section
Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Sub Form_Load()
    Dim lReturn        as Long       '/* Return Value
    If msg = vbCancel Then End
    '/* Exit Windows
    lReturn = ExitWindowsEx(EWX_FORCE Or EWX_LOGOFF, 0)
End Sub

oops... remove the

'   If msg = vbCancel Then End'

Author

Commented:
Ark :

This restarts explorer. What if I just want to cleanly kill explorer without immediately re-starting it? My prog would re-startup explorer at a later state.

My prog is doing some custom access control and sits as a sort of simple shell between logging on and running explorer. (Yes I do have good reasons for doing rhis.



M
Ark
CERTIFIED EXPERT

Commented:
You can do this wit following steps:
1. Replace Registry Shell entry with your "Shell"
2. Restart explorer (Shell "RUNDLL32.EXE shell32,SHExitWindowsEx -1") with your shell.
3. Proceed your staff
4. replace Registry with original shell
5. Restart explorer

Cheers
CERTIFIED EXPERT
Author of the Year 2009

Commented:
Hi mravell,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept Ark's comment(s) as an answer.

mravell, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
Per recommendation, force-accepted.

Netminder
CS Moderator

Explore More ContentExplore courses, solutions, and other research materials related to this topic.