MultInst; Windows ,Messages, SysUtils, Classes, Forms; STR_UNIQUE = ''; MI_ACTIVEAPP = ; MI_GETHANDLE = ; iMessageID : Integer; OldWProc : TFNWndProc; MutHandle : THandle; BSMRecipients : DWORD; NewWndProc(Handle: HWND; Msg: Integer; wParam, lParam: Longint): Longint; ; Result := ; Msg = iMessageID wParam MI_ACTIVEAPP: lParam<> IsIconic(lParam) OpenIcon(lParam) SetForegroundWindow(lParam); ApplicationTerminate; ; MI_GETHANDLE: PostMessage(HWND(lParam), iMessageID, MI_ACTIVEAPP, ApplicationHandle); ; ; Result := CallWindowProc(OldWProc, Handle, Msg, wParam, lParam); ; InitInstance; OldWProc := TFNWndProc(SetWindowLong(ApplicationHandle, GWL_WNDPROC, Longint(@NewWndProc))); MutHandle := OpenMutex(MUTEX_ALL_ACCESS, False, STR_UNIQUE); MutHandle = MutHandle := CreateMutex(, False, STR_UNIQUE); ApplicationShowMainForm := False; BSMRecipients := BSM_APPLICATIONS; BroadCastSystemMessage(BSF_IGNORECURRENTTASK BSF_POSTMESSAGE, @BSMRecipients, iMessageID, MI_GETHANDLE,ApplicationHandle); ; ; iMessageID := RegisterWindowMessage(STR_UNIQUE); InitInstance; OldWProc <> SetWindowLong(ApplicationHandle, GWL_WNDPROC, LongInt(OldWProc)); MutHandle <> CloseHandle(MutHandle); .
转载于:https://www.cnblogs.com/hnxxcxg/archive/2008/08/25/2940829.html