Skip to content
This repository has been archived by the owner on Sep 2, 2019. It is now read-only.

Commit

Permalink
블럭 방지.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZCube committed Apr 17, 2017
1 parent dd97a18 commit ea6c0cd
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ACTWebSocket.Core/Native.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,15 @@ public static List<string> SearchForWindow(string title)

public static bool EnumProc(IntPtr hWnd, ref SearchData data)
{
// 종료 과정 중 자신의 프로세스 체크시 정지되는 경우 있음.
// 만악의 근원
uint id = 0;
GetWindowThreadProcessId(hWnd, out id);
if(GetCurrentProcessId() == id)
{
return true;
}

StringBuilder sb = new StringBuilder(1024);
int ret = GetClassName(hWnd, sb, sb.Capacity);
if(ret == 0)
Expand All @@ -221,6 +230,12 @@ public class SearchData

private delegate bool EnumWindowsProc(IntPtr hWnd, ref SearchData data);

[DllImport("user32.dll", SetLastError = true)]
static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);

[DllImport("kernel32.dll")]
static extern uint GetCurrentProcessId();

[DllImport("kernel32.dll", SetLastError = true)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[SuppressUnmanagedCodeSecurity]
Expand Down

0 comments on commit ea6c0cd

Please sign in to comment.