diff options
author | Pierre Ossman <ossman@cendio.se> | 2015-03-03 16:41:29 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2015-03-03 16:41:29 +0100 |
commit | ba6fbfe368bc2f02a2947138fda0c0d170ae1cf3 (patch) | |
tree | 47e82d73d3dbf7d720b72d638c591968b9424f4c /win | |
parent | 9450b9c142231a3d73ec670a12981db1e8333655 (diff) | |
download | tigervnc-ba6fbfe368bc2f02a2947138fda0c0d170ae1cf3.tar.gz tigervnc-ba6fbfe368bc2f02a2947138fda0c0d170ae1cf3.zip |
Give CharArray a printf style method to ease automatic allocation
Diffstat (limited to 'win')
-rw-r--r-- | win/winvnc/VNCServerService.cxx | 5 | ||||
-rw-r--r-- | win/winvnc/winvnc.cxx | 8 |
2 files changed, 6 insertions, 7 deletions
diff --git a/win/winvnc/VNCServerService.cxx b/win/winvnc/VNCServerService.cxx index 1a2a8e93..481df217 100644 --- a/win/winvnc/VNCServerService.cxx +++ b/win/winvnc/VNCServerService.cxx @@ -97,9 +97,8 @@ HANDLE LaunchProcessWin(DWORD dwSessionId) if (GetSessionUserTokenWin(&hToken)) { ModuleFileName filename; - static const char cmdLineFmt[] = "\"%s\" -noconsole -service_run"; - TCharArray cmdLine(_tcslen(filename.buf) + sizeof(cmdLineFmt)/sizeof(cmdLineFmt[0])); - _stprintf(cmdLine.buf, cmdLineFmt, filename.buf); + TCharArray cmdLine; + cmdLine.format("\"%s\" -noconsole -service_run", filename.buf); STARTUPINFO si; ZeroMemory(&si, sizeof si); si.cb = sizeof si; diff --git a/win/winvnc/winvnc.cxx b/win/winvnc/winvnc.cxx index c2abd892..8fba9dcd 100644 --- a/win/winvnc/winvnc.cxx +++ b/win/winvnc/winvnc.cxx @@ -148,11 +148,11 @@ static void processParams(int argc, char** argv) { } else if (strcasecmp(argv[i], "-status") == 0) { printf("Querying service status...\n"); runServer = false; + CharArray result; DWORD state = rfb::win32::getServiceState(VNCServerService::Name); - CharArray stateStr(rfb::win32::serviceStateName(state)); - const char* stateMsg = "The %s Service is in the %s state."; - CharArray result(strlen(stateStr.buf) + _tcslen(VNCServerService::Name) + strlen(stateMsg) + 1); - sprintf(result.buf, stateMsg, (const char*)CStr(VNCServerService::Name), stateStr.buf); + result.format("The %s Service is in the %s state.", + (const char*)CStr(VNCServerService::Name), + rfb::win32::serviceStateName(state)); MsgBoxOrLog(result.buf); } else if (strcasecmp(argv[i], "-service") == 0) { printf("Run in service mode\n"); |