Changeset 63295 in vbox
- Timestamp:
- Aug 10, 2016 4:04:41 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxBugReport/VBoxBugReportWin.cpp
r62686 r63295 1 1 /* $Id$ */ 2 2 /** @file 3 * VBoxBugReportWin - VirtualBox command-line diagnostics tool, 4 * Windows-specific part. 3 * VBoxBugReportWin - VirtualBox command-line diagnostics tool, Windows-specific part. 5 4 */ 6 5 … … 225 224 public: 226 225 ErrorHandler(const char *pszFunction, int iLine) 227 : m_function(pszFunction), m_line(iLine) {}; 226 : m_function(pszFunction), m_line(iLine) 227 { } 228 228 229 void handleWinError(DWORD uError, const char *pszMsgFmt, ...) 230 { 231 if (uError != ERROR_SUCCESS) 229 232 { 230 if (uError != ERROR_SUCCESS)231 {232 va_list va;233 va_start(va, pszMsgFmt);234 RTCString msgArgs(pszMsgFmt, va); 235 va_end(va);236 LPSTR pBuf = NULL;237 DWORD cb = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,238 NULL, uError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&pBuf, 0, NULL);239 RTCStringFmt msg("%s at %s(%d): err=%u %s", msgArgs.c_str(), m_function, m_line, uError,pBuf);240 LocalFree(pBuf);241 throw RTCError(msg.c_str());242 243 }; 233 va_list va; 234 va_start(va, pszMsgFmt); 235 RTCString msgArgs(pszMsgFmt, va); 236 va_end(va); 237 238 LPSTR pBuf = NULL; 239 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 240 NULL, uError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&pBuf, 0, NULL); 241 RTCStringFmt msg("%s at %s(%d): err=%u %s", msgArgs.c_str(), m_function, m_line, uError, pBuf); 242 LocalFree(pBuf); 243 throw RTCError(msg.c_str()); 244 } 245 } 246 244 247 private: 245 248 const char *m_function; … … 254 257 BugReportUsbTreeWin(); 255 258 virtual ~BugReportUsbTreeWin(); 256 virtual PRTSTREAM getStream(void) { enumerate(); return BugReportStream::getStream(); } ;259 virtual PRTSTREAM getStream(void) { enumerate(); return BugReportStream::getStream(); } 257 260 private: 258 261 class AutoHandle { 259 262 public: 260 AutoHandle(HANDLE h) { m_h = h; } ;261 ~AutoHandle() { close(); } ;262 bool isValid() { return m_h != INVALID_HANDLE_VALUE; } ;263 operator HANDLE() { return m_h; } ;264 void close(void) { if (isValid()) { CloseHandle(m_h); m_h = INVALID_HANDLE_VALUE; } };263 AutoHandle(HANDLE h) { m_h = h; } 264 ~AutoHandle() { close(); } 265 bool isValid() { return m_h != INVALID_HANDLE_VALUE; } 266 operator HANDLE() { return m_h; } 267 void close(void) { if (isValid()) { CloseHandle(m_h); m_h = INVALID_HANDLE_VALUE; } } 265 268 private: 266 269 HANDLE m_h; … … 339 342 RTCString BugReportUsbTreeWin::getDeviceRegistryPropertyString(HDEVINFO hDev, PSP_DEVINFO_DATA pInfoData, DWORD uProperty) 340 343 { 341 DWORD cbString = 0;342 344 PWSTR pUnicodeString = (PWSTR)getDeviceRegistryProperty(hDev, pInfoData, uProperty, REG_SZ, NULL); 343 345 … … 489 491 void BugReportUsbTreeWin::enumerateController(PSP_DEVINFO_DATA pInfoData, PSP_DEVICE_INTERFACE_DATA pInterfaceData) 490 492 { 493 RT_NOREF(pInterfaceData); 491 494 RTCString strCtrlDesc = getDeviceRegistryPropertyString(m_hDevInfo, pInfoData, SPDRP_DEVICEDESC); 492 495 printf("%s\n", strCtrlDesc.c_str()); … … 561 564 void createBugReportOsSpecific(BugReport* report, const char *pszHome) 562 565 { 566 RT_NOREF(pszHome); 563 567 WCHAR szWinDir[MAX_PATH]; 564 568
Note:
See TracChangeset
for help on using the changeset viewer.