1
0

main.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // feedback.cpp : Defines the entry point for the application.
  2. //
  3. #include ".\main.h"
  4. #include <commctrl.h>
  5. #include <strsafe.h>
  6. Settings settings;
  7. int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmdLine, int nCmdShow)
  8. {
  9. wchar_t *argv[2] = {0};
  10. int argc = 0;
  11. if (lpszCmdLine && wcslen(lpszCmdLine) >0) argc = ParseCommandLine(lpszCmdLine, NULL);
  12. if (argc != 1)
  13. {
  14. MSGBOXPARAMSW msgbx = {sizeof(MSGBOXPARAMS),0};
  15. msgbx.lpszText = L"Winamp Error Reporter\nCopyright © 2005-2014 Winamp SA";
  16. msgbx.lpszCaption = L"About...";
  17. msgbx.lpszIcon = MAKEINTRESOURCEW(ICON_XP);
  18. msgbx.hInstance = GetModuleHandle(0);
  19. msgbx.dwStyle = MB_USERICON;
  20. MessageBoxIndirectW(&msgbx);
  21. return 0;
  22. }
  23. ParseCommandLine(lpszCmdLine, argv);
  24. settings.SetPath(argv[0]);
  25. if (!settings.Load())
  26. {
  27. MessageBox(NULL, L"Unable to load settings.", L"Error", MB_OK);
  28. return 0;
  29. }
  30. INITCOMMONCONTROLSEX icex = {sizeof(icex), ICC_WIN95_CLASSES};
  31. InitCommonControlsEx(&icex);
  32. DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_DLG_SILENT), NULL, (DLGPROC)SilentDlgProc, (LPARAM)hInstance);
  33. return 0;
  34. }
  35. static int ParseCommandLine(wchar_t *cmdline, wchar_t **argv)
  36. {
  37. wchar_t *bufp;
  38. int argc;
  39. argc = 0;
  40. for ( bufp = cmdline; *bufp; )
  41. {
  42. /* Skip leading whitespace */
  43. while ( isspace(*bufp) ) ++bufp;
  44. /* Skip over argument */
  45. if ( *bufp == L'"' )
  46. {
  47. ++bufp;
  48. if ( *bufp )
  49. {
  50. if ( argv ) argv[argc] = bufp;
  51. ++argc;
  52. }
  53. /* Skip over word */
  54. while ( *bufp && (*bufp != L'"') ) ++bufp;
  55. }
  56. else
  57. {
  58. if ( *bufp )
  59. {
  60. if ( argv ) argv[argc] = bufp;
  61. ++argc;
  62. }
  63. /* Skip over word */
  64. while ( *bufp && ! isspace(*bufp) ) ++bufp;
  65. }
  66. if ( *bufp )
  67. {
  68. if ( argv ) *bufp = L'\0';
  69. ++bufp;
  70. }
  71. }
  72. if ( argv ) argv[argc] = NULL;
  73. return(argc);
  74. }