Changeset 37670 in vbox for trunk/src/VBox
- Timestamp:
- Jun 28, 2011 6:17:16 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/win/svcmain.cpp
r37667 r37670 16 16 */ 17 17 18 #include <Windows.h> 18 19 #include <stdio.h> 20 #include <stdlib.h> 19 21 20 22 #include "VBox/com/defs.h" … … 30 32 31 33 #include <VBox/err.h> 34 #include <iprt/buildconfig.h> 35 #include <iprt/initterm.h> 36 #include <iprt/string.h> 37 #include <iprt/uni.h> 38 #include <iprt/path.h> 32 39 #include <iprt/getopt.h> 33 #include <iprt/initterm.h>34 #include <iprt/path.h>35 40 36 41 #include <atlbase.h> … … 150 155 ///////////////////////////////////////////////////////////////////////////// 151 156 // 152 extern "C" int WINAPI _tWinMain(HINSTANCE hInstance, 153 HINSTANCE /*hPrevInstance*/, LPTSTR lpCmdLine, int /*nShowCmd*/) 154 { 155 lpCmdLine = GetCommandLine(); /* this line necessary for _ATL_MIN_CRT */ 157 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*nShowCmd*/) 158 { 159 LPCTSTR lpCmdLine = GetCommandLine(); /* this line necessary for _ATL_MIN_CRT */ 156 160 157 161 /* Need to parse the command line before initializing the VBox runtime. */ … … 229 233 230 234 RTGETOPTSTATE GetOptState; 231 int vrc = RTGetOptInit(&GetOptState, argc,argv, &s_aOptions[0], RT_ELEMENTS(s_aOptions), 1, 0 /*fFlags*/);235 int vrc = RTGetOptInit(&GetOptState, __argc, __argv, &s_aOptions[0], RT_ELEMENTS(s_aOptions), 1, 0 /*fFlags*/); 232 236 AssertRC(vrc); 233 237 … … 280 284 281 285 case 'h': 286 { 282 287 TCHAR txt[]= L"Options:\n\n" 283 288 L"/RegServer:\tregister COM out-of-proc server\n" … … 288 293 fRun = false; 289 294 MessageBox(NULL, txt, title, MB_OK); 290 break; 295 return 0; 296 } 291 297 292 298 case 'V': 299 { 293 300 char *psz = NULL; 294 301 RTStrAPrintf(&psz, "%sr%s\n", RTBldCfgVersion(), RTBldCfgRevisionStr()); 295 TCHAR *txt;296 RTStrToU ni(psz, &txt);302 PRTUTF16 txt = NULL; 303 RTStrToUtf16(psz, &txt); 297 304 TCHAR title[]=_T("Version"); 298 305 fRun = false; 299 306 MessageBox(NULL, txt, title, MB_OK); 300 307 RTStrFree(psz); 301 RTUniFree(txt); 302 break; 308 RTUtf16Free(txt); 309 return 0; 310 } 303 311 304 312 default: 305 313 /** @todo this assumes that stderr is visible, which is not 306 314 * true for standard Windows applications. */ 307 return RTGetOptPrintError(vrc, &ValueUnion); 308 } 309 } 310 311 if (!pszLogFile) 312 { 313 char szLogFile[RTPATH_MAX]; 314 vrc = com::GetVBoxUserHomeDirectory(szLogFile, sizeof(szLogFile)); 315 if (RT_SUCCESS(vrc)) 316 vrc = RTPathAppend(szLogFile, sizeof(szLogFile), "VBoxSVC.log"); 317 if (RT_SUCCESS(vrc)) 318 pszLogFile = RTStrDup(szLogFile); 319 } 315 /* continue on command line errors... */ 316 RTGetOptPrintError(vrc, &ValueUnion); 317 } 318 } 319 320 320 /* Only create the log file when running VBoxSVC normally, but not when 321 321 * registering/unregistering or calling the helper functionality. */ 322 322 if (fRun) 323 { 324 if (!pszLogFile) 325 { 326 char szLogFile[RTPATH_MAX]; 327 vrc = com::GetVBoxUserHomeDirectory(szLogFile, sizeof(szLogFile)); 328 if (RT_SUCCESS(vrc)) 329 vrc = RTPathAppend(szLogFile, sizeof(szLogFile), "VBoxSVC.log"); 330 if (RT_SUCCESS(vrc)) 331 pszLogFile = RTStrDup(szLogFile); 332 } 323 333 VBoxSVCLogRelCreate(pszLogFile, cHistory, uHistoryFileTime, uHistoryFileSize); 334 } 324 335 325 336 int nRet = 0; … … 342 353 nRet = _Module.RegisterServer(TRUE); 343 354 } 344 if ( !pszPipeName)355 if (pszPipeName) 345 356 { 346 357 Log(("SVCMAIN: Processing Helper request (cmdline=\"%s\")...\n", pszPipeName)); 347 358 348 if (!*p ipeName)359 if (!*pszPipeName) 349 360 vrc = VERR_INVALID_PARAMETER; 350 361 … … 353 364 /* do the helper job */ 354 365 SVCHlpServer server; 355 vrc = server.open(p ipeName.c_str());366 vrc = server.open(pszPipeName); 356 367 if (RT_SUCCESS(vrc)) 357 368 vrc = server.run();
Note:
See TracChangeset
for help on using the changeset viewer.