You can use _com_error:
_com_error err(hr);
LPCTSTR errMsg = err.ErrorMessage();
If you don’t want to use _com_error
for whatever reason, you can still take a look at its source, and see how it’s done.
Don’t forget to include the header comdef.h
More Related Contents:
- How to get main window handle from process id?
- How to make thread sleep less than a millisecond on Windows
- Win32 API to enumerate dll export functions?
- How to read a value from the Windows registry
- How do I call ::CreateProcess in c++ to launch a Windows executable?
- Detecting Windows 10 version
- Win32 programming hiding console window
- Can I use CreateFile, but force the handle into a std::ofstream?
- updating a string table with UpdateResource
- Read process memory of a process does not return everything
- How can I get the path of a Windows “special folder” for a specific user?
- Using CreateWindowEx to Make a Message-Only Window
- How do I get the window handle of the desktop?
- How do I implement dragging a window using its client area?
- C++ Executing CMD Commands
- Detecting simulated keyboard/mouse input
- WinAPI Sleep() function call sleeps for longer than expected
- Best method for storing this pointer for use in WndProc
- How to programmatically create a shortcut using Win32
- How can I save HICON to an .ico file?
- Check the file-size without opening file in C++?
- Win32: How to hide 3rd party windows in taskbar by hWnd
- EnumDisplayDevices vs WMI Win32_DesktopMonitor, how to detect active monitors?
- Name of process for active window in Windows 8/10
- “APIENTRY _tWinMain” and “WINAPI WinMain” difference
- How to get the Executable name of a window
- Getting another process command line in Windows
- Visual Studio 2013: CL.exe exited with code -1073741515
- C++: What’s the simplest way to read and write BMP files using C++ on Windows?
- DoEvents equivalent for C++?