Victor
Victor

Reputation: 14593

Show the SwitchUser Screen

I am working on an application to cutomize the switch user and logon screen of Windows 7.

My application is built as a wizard,a dn on the last step, I want the user to be able to view the Switch User screen by pressing a button, like he/she would do by Start menu:

enter image description here

Upvotes: 0

Views: 396

Answers (1)

bwdeng
bwdeng

Reputation: 358

Lifted from Shortcut to Switch User in Windows Vista:

using System;
using System.Runtime.InteropServices;
using System.ComponentModel;

class Program
{
  [DllImport("wtsapi32.dll", SetLastError = true)]
  static extern bool WTSDisconnectSession(IntPtr hServer, int sessionId, bool bWait);

  const int WTS_CURRENT_SESSION = -1;
  static readonly IntPtr WTS_CURRENT_SERVER_HANDLE = IntPtr.Zero;

  static void Main(string[] args)
  {
    if (!WTSDisconnectSession(WTS_CURRENT_SERVER_HANDLE,
         WTS_CURRENT_SESSION, false))
      throw new Win32Exception();
  }
}

Upvotes: 1

Related Questions