FAQ
for [no.it.programmering.c++]
På API-nivået via funksjonen FormatMessage. Se
Microsoft dokumentasjonen.
I Visual C++ kan du alternativt bruke hjelperklassen
_com_error, f.eks.
#include <iostream> // std::cout
#include <string> // std::string
#define STRICT
#define NOMINMAX
#include <windows.h> // ERROR_CANNOT_COPY
#include <comdef.h> // _com_error
std::string toString( HRESULT code )
{
return _com_error( code ).ErrorMessage();
}
int main()
{
std::cout << toString( ERROR_CANNOT_COPY ) << std::endl;
}
som gir (skal gi) utskriften
The copy functions cannot be used.