Browse Source

AddIn: Code cleanup.

pull/1317/head
Andreas Weizel 7 years ago
parent
commit
83759eed37
  1. 26
      ILSpy.AddIn/ILSpyInstance.cs
  2. 14
      ILSpy/NativeMethods.cs

26
ILSpy.AddIn/ILSpyInstance.cs

@ -66,22 +66,18 @@ namespace ICSharpCode.ILSpy.AddIn @@ -66,22 +66,18 @@ namespace ICSharpCode.ILSpy.AddIn
do {
NativeMethods.EnumWindows(
(hWnd, lParam) => {
uint processId = NativeMethods.GetProcessIdFromWindow(hWnd);
//if (processId == ilspyProcess.Id) {
Debug.WriteLine("Found {0:x4} for process {1}", hWnd, processId);
string windowTitle = NativeMethods.GetWindowText(hWnd, 100);
if (windowTitle.StartsWith("ILSpy", StringComparison.Ordinal)) {
Debug.WriteLine("Found {0:x4}: {1}", hWnd, windowTitle);
IntPtr result = Send(hWnd, message);
Debug.WriteLine("WM_COPYDATA result: {0:x8}", result);
if (result == (IntPtr)1) {
if (activate)
NativeMethods.SetForegroundWindow(hWnd);
success = true;
return false; // stop enumeration
}
string windowTitle = NativeMethods.GetWindowText(hWnd, 100);
if (windowTitle.StartsWith("ILSpy", StringComparison.Ordinal)) {
Debug.WriteLine("Found {0:x4}: {1}", hWnd, windowTitle);
IntPtr result = Send(hWnd, message);
Debug.WriteLine("WM_COPYDATA result: {0:x8}", result);
if (result == (IntPtr)1) {
if (activate)
NativeMethods.SetForegroundWindow(hWnd);
success = true;
return false; // stop enumeration
}
//}
}
return true; // continue enumeration
}, IntPtr.Zero);

14
ILSpy/NativeMethods.cs

@ -50,20 +50,6 @@ namespace ICSharpCode.ILSpy @@ -50,20 +50,6 @@ namespace ICSharpCode.ILSpy
[DllImport("user32.dll", CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool SetForegroundWindow(IntPtr hWnd);
//HANDLE WINAPI GetProcessHandleFromHwnd(
// _In_ HWND hwnd
//);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.I4)]
internal static extern uint GetWindowThreadProcessId(IntPtr hWnd, [MarshalAs(UnmanagedType.I4)] out uint processId);
public static uint GetProcessIdFromWindow(IntPtr hWnd)
{
GetWindowThreadProcessId(hWnd, out uint processId);
return processId;
}
}
[return: MarshalAs(UnmanagedType.Bool)]

Loading…
Cancel
Save