I'm trying to pull a WinForms application through the Windows App Certification Kit and gets a fail on this test:
<TEST INDEX="17" NAME="Multi user session test" DESCRIPTION="Multi User checks Application invocation in multiple sessions." EXECUTIONTIME="00h:00m:24s.22ms">
<RESULT><![CDATA[FAIL]]></RESULT>
<MESSAGES />
I guess that this is because I only allow one instance of the application to run, like this:
using ( var p = System.Diagnostics.Process.GetCurrentProcess() )
if ( System.Diagnostics.Process.GetProcessesByName( p.ProcessName ).Length > 1 )
{
MessageBox.Show(
"An instance of xxx is already running!",
Title,
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation );
return;
}
It is a tray-application activated by a hot-key combination, registered with this function:
[DllImport( "user32", EntryPoint = "RegisterHotKey", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true )]
public static extern int RegisterHotkey( IntPtr hWnd, int id, int fsModifiers, int vk );
So I guess I have two questions:
1) How can I correctly prevent multiple sessions being run within the same user session but allow several instances across multiple user sessions?
2) Will I be able to register the same hot-key in different user sessions? Or must I somehow unregister and re-register the hot-key when user sessions are switched?
TIA