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..25228a9153808dd5a84489f0f19fe959d3204448 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,14 @@ HRESULT GetLastHResult() { |
return HRESULT_FROM_WIN32(error_code); |
} |
+string16 GetPortMonitorDllName() { |
+ if (IsSystem64Bit()) { |
+ return string16(L"gcp_portmon64.dll"); |
+ } else { |
+ return string16(L"gcp_portmon32.dll"); |
+ } |
+} |
+ |
HRESULT GetPrinterDriverDir(FilePath* path) { |
BYTE driver_dir_buffer[MAX_PATH * sizeof(wchar_t)]; |
DWORD needed = 0; |
@@ -49,5 +61,29 @@ 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); |
+} |
+ |
+string16 LoadLocalString(DWORD string_id) { |
+ static wchar_t dummy = L'\0'; |
+// We never expect strings longer than MAX_PATH characters. |
+ 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); |
+ CHECK_NE(0, count); |
+ return string16(buffer); |
+} |
} |