[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 842
  • Last Modified:

Switch User in Windows XP

I would like to know how to use Windows XP's new Fast User Switching feature to switch user in VB code.
0
SimonORorke
Asked:
SimonORorke
  • 2
1 Solution
 
RainUKCommented:
Have you looked on MSDN? Although I have not had a look in MSDN lately I assume it is a set of Win32 APIs, probably similar to something like Win2Ks LogonUser, LoadUSerProfile, SwitchDesktop etc.
0
 
SimonORorkeAuthor Commented:
I've scoured MSDN!  I did find what what looks like a way of doinng it with MFC, which is no good for VB.  I could not see how to do it with API, though that must be possible.
0
 
jbilCommented:
See KB Q310153 to do in in c++

"HOW TO: Write an Application That Supports Fast User Switching in Windows XP (Q310153)"

Here is cheesy way to do it in vb by kebd_event...

Private Const VK_RWIN = &H5C
Private Const VK_LWIN = &H5B
Const KEYEVENTF_EXTENDEDKEY = &H1
Const KEYEVENTF_KEYUP = &H2

Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Private Sub Form_Click()
keybd_event VK_LWIN, 0, 0, 0
   
    keybd_event vbKeyL, 0, 0, 0
   
    keybd_event VK_LWIN, 0, KEYEVENTF_KEYUP, 0
    keybd_event vbKeyL, 0, KEYEVENTF_KEYUP, 0

End Sub
0
 
SimonORorkeAuthor Commented:
Hello jbil

Q310153 has much interesting info about coding to support user switching in applications, but does not, as far as I can see, actually tell me how to switch users.  However, your "cheesy" VB solution will do nicely!  Thanks.

Simon
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now