Solved

Switch User in Windows XP

Posted on 2002-03-21
4
831 Views
Last Modified: 2012-05-04
I would like to know how to use Windows XP's new Fast User Switching feature to switch user in VB code.
0
Comment
Question by:SimonORorke
  • 2
4 Comments
 
LVL 5

Expert Comment

by:RainUK
ID: 6889038
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
 

Author Comment

by:SimonORorke
ID: 6890214
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
 
LVL 3

Accepted Solution

by:
jbil earned 200 total points
ID: 6891598
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
 

Author Comment

by:SimonORorke
ID: 6893382
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now