| 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..6c174a95ad385f2fd43f4f52e530fbfe950afc01 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/win/windows_version.h"
|
| +#include "cloud_print/virtual_driver/win/virtual_driver_common_resources.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,20 @@ HRESULT GetLastHResult() {
|
| return HRESULT_FROM_WIN32(error_code);
|
| }
|
|
|
| +void GetPortMonitorDllName(FilePath* path) {
|
| + wchar_t dll_name[MAX_PATH];
|
| + if (IsSystem64Bit()) {
|
| + LoadLocalString(IDS_PORT_MON_DLL_NAME_64,
|
| + dll_name,
|
| + MAX_PATH);
|
| + } else {
|
| + LoadLocalString(IDS_PORT_MON_DLL_NAME_32,
|
| + dll_name,
|
| + MAX_PATH);
|
| + }
|
| + *path = FilePath(dll_name);
|
| +}
|
| +
|
| HRESULT GetPrinterDriverDir(FilePath* path) {
|
| BYTE driver_dir_buffer[MAX_PATH * sizeof(wchar_t)];
|
| DWORD needed = 0;
|
| @@ -49,5 +67,26 @@ 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, wchar_t* target, DWORD target_size) {
|
| + static wchar_t dummy = L'\0';
|
| + 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,
|
| + target,
|
| + target_size);
|
| + DCHECK_NE(0, count);
|
| +}
|
| }
|
|
|
|
|