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