OSDN Git Service

PATCH: [ 1738567 ] Include command line in configuration log
authorGal Hammer <galh@users.sourceforge.net>
Tue, 7 Aug 2007 17:21:08 +0000 (17:21 +0000)
committerGal Hammer <galh@users.sourceforge.net>
Tue, 7 Aug 2007 17:21:08 +0000 (17:21 +0000)
Src/ConfigLog.cpp

index 70ff3f2..3384958 100644 (file)
@@ -412,6 +412,34 @@ BOOL CConfigLog::DoFile(bool writing, CString &sError)
        FileWriteString(_T("\n Build config: "));
        FileWriteString(text);
 
+       LPCTSTR szCmdLine = ::GetCommandLine();
+       ASSERT(szCmdLine != NULL);
+
+       // Skip the quoted executable file name.
+       if (szCmdLine != NULL)
+       {
+               szCmdLine = _tcschr(szCmdLine, '"');
+               if (szCmdLine != NULL)
+               {
+                       szCmdLine += 1; // skip the opening quote.
+                       szCmdLine = _tcschr(szCmdLine, '"');
+                       if (szCmdLine != NULL)
+                       {
+                               szCmdLine += 1; // skip the closing quote.
+                       }
+               }
+       }
+
+       // The command line include a space after the executable file name,
+       // which mean that empty command line will have length of one.
+       if (lstrlen(szCmdLine) < 2)
+       {
+               szCmdLine = _T(" none");
+       }
+
+       FileWriteString(_T("\n Command Line: "));
+       FileWriteString(szCmdLine);
+
        FileWriteString(_T("\n Windows: "));
        text = GetWindowsVer();
        FileWriteString(text);