2 * Dumb Windows program to put up a message box
3 * containing the command line. Any leading and
4 * trailing quotes are stripped.
12 int WINAPI
WinMain(HINSTANCE hInstance
, HINSTANCE hPrevInstance
,
13 PSTR szCmdLine
, int iCmdShow
)
15 int len
= strlen(szCmdLine
);
18 // Funny things happen with the command line if the
19 // execution comes from c:/Program Files/apcupsd/apcupsd.exe
20 // We get a command line like: Files/apcupsd/apcupsd.exe" options
21 // I.e. someone stops scanning command line on a space, not
22 // realizing that the filename is quoted!!!!!!!!!!
23 // So if first character is not a double quote and
24 // the last character before first space is a double
25 // quote, we throw away the junk.
27 while (*wordPtr
&& *wordPtr
!= ' ')
29 if (wordPtr
> szCmdLine
) // backup to char before space
31 // if first character is not a quote and last is, junk it
32 if (*szCmdLine
!= '"' && *wordPtr
== '"') {
34 while (*wordPtr
&& *wordPtr
== ' ')
35 wordPtr
++; /* strip leading spaces */
37 len
= strlen(szCmdLine
);
41 if (*szCmdLine
== '"' && len
> 0 && szCmdLine
[len
-1] == '"') {
46 // Now display the popup
47 MessageBox(NULL
, msg
, "Apcupsd message", MB_OK
);