diff --git a/trunk/ProcessHacker/Forms/HackerWindow.cs b/trunk/ProcessHacker/Forms/HackerWindow.cs
index 832747c15..bedfcb5f2 100644
--- a/trunk/ProcessHacker/Forms/HackerWindow.cs
+++ b/trunk/ProcessHacker/Forms/HackerWindow.cs
@@ -2338,6 +2338,16 @@ namespace ProcessHacker
}
catch
{ }
+
+ // If it's Vista and we're elevated, we should allow certain window message to allow
+ // Allow only one instance to work.
+ if (Program.WindowsVersion == "Vista" &&
+ Program.ElevationType == Win32.TOKEN_ELEVATION_TYPE.TokenElevationTypeFull)
+ {
+ Win32.ChangeWindowMessageFilter(Win32.WindowMessage.ShowWindow, Win32.UipiFilterFlag.Add);
+ Win32.ChangeWindowMessageFilter(Win32.WindowMessage.SysCommand, Win32.UipiFilterFlag.Add);
+ Win32.ChangeWindowMessageFilter((Win32.WindowMessage)0x9991, Win32.UipiFilterFlag.Add);
+ }
}
private void HackerWindow_Load(object sender, EventArgs e)
diff --git a/trunk/ProcessHacker/ProcessHacker.csproj b/trunk/ProcessHacker/ProcessHacker.csproj
index d48456125..88cdae343 100644
--- a/trunk/ProcessHacker/ProcessHacker.csproj
+++ b/trunk/ProcessHacker/ProcessHacker.csproj
@@ -15,7 +15,7 @@
ProcessHacker.ico
ProcessHacker.Program
app.manifest
- OnOutputUpdated
+ OnBuildSuccess
true
diff --git a/trunk/ProcessHacker/Program.cs b/trunk/ProcessHacker/Program.cs
index c7c7eb7ce..65dc2938d 100644
--- a/trunk/ProcessHacker/Program.cs
+++ b/trunk/ProcessHacker/Program.cs
@@ -264,8 +264,8 @@ namespace ProcessHacker
if (Win32.SendMessage(hWnd, (Win32.WindowMessage)0x9991, IntPtr.Zero, IntPtr.Zero).ToInt32() ==
0x1119)
{
- Win32.ShowWindow(hWnd, Win32.ShowWindowType.Restore);
- Win32.ShowWindow(hWnd, Win32.ShowWindowType.Show);
+ Win32.SendMessage(hWnd, Win32.WindowMessage.SysCommand, new IntPtr(0xf120), IntPtr.Zero);
+ Win32.SendMessage(hWnd, Win32.WindowMessage.ShowWindow, IntPtr.Zero, IntPtr.Zero);
Win32.SetForegroundWindow(hWnd);
found = true;
return false;
diff --git a/trunk/ProcessHacker/Win32/API/Enums.cs b/trunk/ProcessHacker/Win32/API/Enums.cs
index 55d234aea..11e8dfda6 100644
--- a/trunk/ProcessHacker/Win32/API/Enums.cs
+++ b/trunk/ProcessHacker/Win32/API/Enums.cs
@@ -989,6 +989,12 @@ namespace ProcessHacker
TokenImpersonation
}
+ public enum UipiFilterFlag : int
+ {
+ Add = 1,
+ Remove = 2
+ }
+
public enum UDP_TABLE_CLASS : int
{
UDP_TABLE_BASIC,
diff --git a/trunk/ProcessHacker/Win32/API/Functions.cs b/trunk/ProcessHacker/Win32/API/Functions.cs
index 5b9b25adc..9556f5990 100644
--- a/trunk/ProcessHacker/Win32/API/Functions.cs
+++ b/trunk/ProcessHacker/Win32/API/Functions.cs
@@ -1,4 +1,4 @@
-/*
+ /*
* Process Hacker -
* windows API functions
*
@@ -875,6 +875,15 @@ namespace ProcessHacker
#region Windows
+ [DllImport("user32.dll")]
+ public static extern bool ChangeWindowMessageFilter(WindowMessage message, UipiFilterFlag flag);
+
+ [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
+ public static extern IntPtr SendMessage(IntPtr windowHandle, WindowMessage msg, IntPtr w, IntPtr l);
+
+ [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
+ public static extern IntPtr PostMessage(IntPtr windowHandle, WindowMessage msg, IntPtr w, IntPtr l);
+
[DllImport("user32.dll")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
@@ -996,9 +1005,6 @@ namespace ProcessHacker
public static extern bool AdjustWindowRect(ref System.Drawing.Rectangle rect, WindowStyles style,
[MarshalAs(UnmanagedType.Bool)]bool menu);
- [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
- public static extern IntPtr SendMessage(IntPtr windowHandle, WindowMessage msg, IntPtr w, IntPtr l);
-
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr RegisterClass(ref WindowClass wndClass);