program Kocom_Homenet; uses Windows, Messages, SysUtils, Forms, kocomHomenet in 'kocomHomenet.pas' {Form1}; {$R *.res} function EnumWindowsProc(wnd: HWND; lParam: LPARAM): BOOL; stdcall; var msgID: Cardinal; className, winText: array[0..255] of Char; begin msgID := Cardinal(lParam); GetClassName(wnd, className, 255); GetWindowText(wnd, winText, 255); if (StrPos(className, 'TForm1') <> nil) or (StrPos(className, 'TApplication') <> nil) or (StrPos(winText, '코콤홈넷미세먼지') <> nil) or (StrPos(winText, 'Kocom_Homenet') <> nil) then begin PostMessage(wnd, msgID, 0, 0); end; Result := True; end; var hMutex: THandle; restoreMsgID: Cardinal; begin hMutex := CreateMutex(nil, True, 'Kocom_Homenet_Dust_SingleInstance_Mutex'); if (hMutex <> 0) and (GetLastError = ERROR_ALREADY_EXISTS) then begin CloseHandle(hMutex); restoreMsgID := RegisterWindowMessage('KOCOM_HOMENET_RESTORE_MSG'); if restoreMsgID <> 0 then begin PostMessage(HWND_BROADCAST, restoreMsgID, 0, 0); EnumWindows(@EnumWindowsProc, LPARAM(restoreMsgID)); end; Exit; end; try Application.Initialize; Application.Title := 'Kocom_Homenet'; Application.CreateForm(TForm1, Form1); Application.Run; finally if hMutex <> 0 then CloseHandle(hMutex); end; end.