OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/virtual_driver/win/virtual_driver_helpers.h" | 5 #include "cloud_print/virtual_driver/win/virtual_driver_helpers.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <winspool.h> | 8 #include <winspool.h> |
9 | 9 |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 #include "base/win/windows_version.h" | 13 #include "base/win/windows_version.h" |
14 #include "cloud_print/common/win/cloud_print_utils.h" | 14 #include "cloud_print/common/win/cloud_print_utils.h" |
15 | 15 |
16 namespace cloud_print { | 16 namespace cloud_print { |
17 | 17 |
18 void DisplayWindowsMessage(HWND hwnd, | 18 void DisplayWindowsMessage(HWND hwnd, |
19 HRESULT hr, | 19 HRESULT hr, |
20 const base::string16& caption) { | 20 const base::string16& caption) { |
21 ::MessageBox(hwnd, GetErrorMessage(hr).c_str(), caption.c_str(), MB_OK); | 21 ::MessageBox(hwnd, GetErrorMessage(hr).c_str(), caption.c_str(), MB_OK); |
22 } | 22 } |
23 | 23 |
| 24 base::string16 GetPortMonitorDllName() { |
| 25 if (IsSystem64Bit()) { |
| 26 return base::string16(L"gcp_portmon64.dll"); |
| 27 } else { |
| 28 return base::string16(L"gcp_portmon.dll"); |
| 29 } |
| 30 } |
| 31 |
24 HRESULT GetPrinterDriverDir(base::FilePath* path) { | 32 HRESULT GetPrinterDriverDir(base::FilePath* path) { |
25 BYTE driver_dir_buffer[MAX_PATH * sizeof(wchar_t)]; | 33 BYTE driver_dir_buffer[MAX_PATH * sizeof(wchar_t)]; |
26 DWORD needed = 0; | 34 DWORD needed = 0; |
27 if (!GetPrinterDriverDirectory(NULL, NULL, 1, driver_dir_buffer, | 35 if (!GetPrinterDriverDirectory(NULL, NULL, 1, driver_dir_buffer, |
28 MAX_PATH * sizeof(wchar_t), &needed)) { | 36 MAX_PATH * sizeof(wchar_t), &needed)) { |
29 // We could try to allocate a larger buffer if needed > MAX_PATH | 37 // We could try to allocate a larger buffer if needed > MAX_PATH |
30 // but that really shouldn't happen. | 38 // but that really shouldn't happen. |
31 return cloud_print::GetLastHResult(); | 39 return cloud_print::GetLastHResult(); |
32 } | 40 } |
33 *path = base::FilePath(reinterpret_cast<wchar_t*>(driver_dir_buffer)); | 41 *path = base::FilePath(reinterpret_cast<wchar_t*>(driver_dir_buffer)); |
34 | 42 |
35 // The XPS driver is a "Level 3" driver | 43 // The XPS driver is a "Level 3" driver |
36 *path = path->Append(L"3"); | 44 *path = path->Append(L"3"); |
37 return S_OK; | 45 return S_OK; |
38 } | 46 } |
| 47 |
| 48 bool IsSystem64Bit() { |
| 49 base::win::OSInfo::WindowsArchitecture arch = |
| 50 base::win::OSInfo::GetInstance()->architecture(); |
| 51 return (arch == base::win::OSInfo::X64_ARCHITECTURE) || |
| 52 (arch == base::win::OSInfo::IA64_ARCHITECTURE); |
39 } | 53 } |
| 54 } // namespace cloud_print |
OLD | NEW |