U3Start.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include "stdafx.h"
  2. #include "U3Start.h"
  3. #ifdef _DEBUG
  4. #define new DEBUG_NEW
  5. #endif
  6. CU3StartApp theApp;
  7. CString GetFilePath(CString csFileName)
  8. {
  9. long lSlash = csFileName.ReverseFind('\\');
  10. if(lSlash > -1)
  11. {
  12. csFileName = csFileName.Left(lSlash + 1);
  13. }
  14. return csFileName;
  15. }
  16. BOOL CU3StartApp::InitInstance()
  17. {
  18. CWinApp::InitInstance();
  19. //if the device isn't available then just return, u3action will kill the process
  20. CString csAvailable = getenv("U3_IS_DEVICE_AVAILABLE");
  21. if(csAvailable != "true")
  22. return FALSE;
  23. //Load the ini file in the same dir as this is running
  24. CString sExeName;
  25. GetModuleFileName(NULL, sExeName.GetBuffer(_MAX_PATH),_MAX_PATH);
  26. sExeName.ReleaseBuffer();
  27. CString csPath = GetFilePath(sExeName);
  28. csPath += "DittohWnd.ini";
  29. //Load the running Ditto and send a close to it
  30. HWND hWnd = (HWND)GetPrivateProfileInt("Ditto", "MainhWnd", 0, csPath);
  31. CString cs;
  32. cs.Format("Ditto Stop sending WM_CLOSE to the hWnd = %d", hWnd);
  33. OutputDebugString(cs);
  34. SendMessage(hWnd, WM_CLOSE, 0, 0);
  35. OutputDebugString("Post Send Message");
  36. return FALSE;
  37. }