Chromium Code Reviews| Index: cloud_print/virtual_driver/win/virtual_driver_helpers.cc |
| diff --git a/cloud_print/virtual_driver/win/virtual_driver_helpers.cc b/cloud_print/virtual_driver/win/virtual_driver_helpers.cc |
| index 19d557411bc50d892c0070cf448890f6aa1795fa..5633c33cc6a89dab17c534db8ffc4a181f5bf344 100644 |
| --- a/cloud_print/virtual_driver/win/virtual_driver_helpers.cc |
| +++ b/cloud_print/virtual_driver/win/virtual_driver_helpers.cc |
| @@ -6,13 +6,17 @@ |
| #include <windows.h> |
| #include <winspool.h> |
| #include "base/file_util.h" |
| -#include "cloud_print/virtual_driver/win/virtual_driver_consts.h" |
| +#include "base/logging.h" |
| +#include "base/string16.h" |
| +#include "base/win/windows_version.h" |
| namespace cloud_print { |
| const size_t kMaxMessageLen = 100; |
| -void DisplayWindowsMessage(HWND hwnd, HRESULT message_id) { |
| +void DisplayWindowsMessage(HWND hwnd, |
| + HRESULT message_id, |
| + const string16 &caption) { |
| wchar_t message_text[kMaxMessageLen + 1] = L""; |
| ::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, |
| @@ -22,7 +26,7 @@ void DisplayWindowsMessage(HWND hwnd, HRESULT message_id) { |
| message_text, |
| kMaxMessageLen, |
| NULL); |
| - ::MessageBox(hwnd, message_text, kVirtualDriverName, MB_OK); |
| + ::MessageBox(hwnd, message_text, caption.c_str(), MB_OK); |
| } |
| HRESULT GetLastHResult() { |
| @@ -30,6 +34,15 @@ HRESULT GetLastHResult() { |
| return HRESULT_FROM_WIN32(error_code); |
| } |
| +void GetPortMonitorDllName(FilePath* path) { |
| + string16 dll_name; |
| + if (IsSystem64Bit()) { |
| + *path = FilePath(L"gcp_portmon64.dll"); |
| + } else { |
| + *path = FilePath(L"gcp_portmon32.dll"); |
| + } |
| +} |
| + |
| HRESULT GetPrinterDriverDir(FilePath* path) { |
| BYTE driver_dir_buffer[MAX_PATH * sizeof(wchar_t)]; |
| DWORD needed = 0; |
| @@ -49,5 +62,28 @@ HRESULT GetPrinterDriverDir(FilePath* path) { |
| *path = path->Append(L"3"); |
| return S_OK; |
| } |
| + |
| +bool IsSystem64Bit() { |
| + base::win::OSInfo::WindowsArchitecture arch = |
| + base::win::OSInfo::GetInstance()->architecture(); |
| + return (arch == base::win::OSInfo::X64_ARCHITECTURE) || |
| + (arch == base::win::OSInfo::IA64_ARCHITECTURE); |
| +} |
| + |
| +void LoadLocalString(DWORD string_id, string16* target) { |
| + static wchar_t dummy = L'\0'; |
| + static wchar_t buffer[MAX_PATH]; |
| + HMODULE module = NULL; |
| + GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | |
| + GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, |
| + &dummy, |
| + &module); |
| + int count = LoadString(module, |
| + string_id, |
| + buffer, |
| + MAX_PATH); |
| + DCHECK_NE(0, count); |
|
sanjeevr
2011/05/10 16:18:47
Can you change the DCHECK to a CHECK? And also wri
Albert Bodenhamer
2011/05/11 21:46:12
Done.
|
| + *target = string16(buffer); |
| +} |
| } |