In the following code snipet, what does this code do? Where does it return a
bool to... OS? Does it import a User32.dll library? The code is part of
creating a singleton [tempate] instance of an appication. The complete code
is located at
http://www.c-sharpcorner.com/FAQ/Cre...tanceAppSC.asp
//the Process is the appl that's aready running -want ony one instance
public static void HandleRunningInstance(Process instance)
{
//Make sure the window is not minimized or maximized
ShowWindowAsync (instance.MainWindowHandle , WS_SHOWNORMAL);
//Set the real intance to foreground window
SetForegroundWindow (instance.MainWindowHandle);
}
[DllImport("User32.dll")]
private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
[DllImport("User32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
private const int WS_SHOWNORMAL = 1;
}