Better instance checking

Hey,

When allow only one instance is enabled, I think that if smartftp is launched and an other instance is open, that the existing instance should be focused!

I've done the same thing, but this code is in Delphi (although it uses WinAPI which is the same in VC)



  WM_INSTANCE_CHECK := RegisterWindowMessage('SmartFTP_Instance_Check');



  Mutex := CreateMutex(nil, True, 'SmartFTP_Instance_Mutex');



  if (Mutex = 0) OR (GetLastError = ERROR_ALREADY_EXISTS) then



  begin



    SendMessage(HWND_BROADCAST, WM_INSTANCE_CHECK, 0, 0);



  end



  else



  begin



     // Load program ..



  end;




The app should handle WM_INSTANCE_CHECK messages and use maximize the main form and then use SetForegroundWindow(AppHandle)