Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Unified Diff: cloud_print/virtual_driver/win/virtual_driver_helpers.cc

Issue 6930019: Added resources. (Closed)
Patch Set: Dealing with git stupidity Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cloud_print/virtual_driver/win/virtual_driver_helpers.h ('k') | tools/grit/resource_ids » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+}
}
« no previous file with comments | « cloud_print/virtual_driver/win/virtual_driver_helpers.h ('k') | tools/grit/resource_ids » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698