OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cloud_print/service/win/service_controller.h" | 5 #include "cloud_print/service/win/service_controller.h" |
6 | 6 |
7 #include <atlbase.h> | 7 #include <atlbase.h> |
8 #include <atlcom.h> | 8 #include <atlcom.h> |
9 #include <atlctl.h> | 9 #include <atlctl.h> |
10 | 10 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 } | 293 } |
294 | 294 |
295 DWORD config_size = 0; | 295 DWORD config_size = 0; |
296 ::QueryServiceConfig(service.Get(), NULL, 0, &config_size); | 296 ::QueryServiceConfig(service.Get(), NULL, 0, &config_size); |
297 if (!config_size) | 297 if (!config_size) |
298 return; | 298 return; |
299 | 299 |
300 std::vector<uint8> buffer(config_size, 0); | 300 std::vector<uint8> buffer(config_size, 0); |
301 QUERY_SERVICE_CONFIG* config = | 301 QUERY_SERVICE_CONFIG* config = |
302 reinterpret_cast<QUERY_SERVICE_CONFIG*>(&buffer[0]); | 302 reinterpret_cast<QUERY_SERVICE_CONFIG*>(&buffer[0]); |
303 if (!::QueryServiceConfig(service.Get(), config, | 303 if (!::QueryServiceConfig(service.Get(), config, buffer.size(), |
304 static_cast<DWORD>(buffer.size()), | |
305 &config_size) || | 304 &config_size) || |
306 config_size != buffer.size()) { | 305 config_size != buffer.size()) { |
307 return; | 306 return; |
308 } | 307 } |
309 | 308 |
310 command_line_ = base::CommandLine::FromString(config->lpBinaryPathName); | 309 command_line_ = base::CommandLine::FromString(config->lpBinaryPathName); |
311 if (!command_line_.HasSwitch(kServiceSwitch)) { | 310 if (!command_line_.HasSwitch(kServiceSwitch)) { |
312 state_ = STATE_NOT_FOUND; | 311 state_ = STATE_NOT_FOUND; |
313 return; | 312 return; |
314 } | 313 } |
315 is_logging_enabled_ = command_line_.HasSwitch(switches::kEnableLogging); | 314 is_logging_enabled_ = command_line_.HasSwitch(switches::kEnableLogging); |
316 user_ = config->lpServiceStartName; | 315 user_ = config->lpServiceStartName; |
317 } | 316 } |
318 | 317 |
319 bool ServiceController::is_logging_enabled() const { | 318 bool ServiceController::is_logging_enabled() const { |
320 return command_line_.HasSwitch(switches::kEnableLogging); | 319 return command_line_.HasSwitch(switches::kEnableLogging); |
321 } | 320 } |
OLD | NEW |