Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I read HRESULTS

Status
Not open for further replies.

francisco

Programmer
Jun 20, 2000
8
DE
I find it a little dumm but I can´t not read an HRESULT as a <br>char value. For example, I have a function as <br><br>HRESULT Myfunction()<br><br>Which tries to make something, it has DI_OK return values for succes and different DIERR_... to describe errors, I would like to call Myfunction and then with a TRACE call perform an error description:<br><br>HRESULT hr;<br>hr=Myfunction();<br>TRACE(Something to return hr as a character);<br><br>Thank in advance<br><br><br>javi
 
javi,

Perhaps I am missing the point of your question, but I'll try to answer it as I understand it.

An HRESULT is just a long integer. If all you want is the value, you could use ltoa to convert it to an ascii value and then trace out

I have a feeling what you want is the &quot;hex&quot; representation of the HRESULT, in which case all you need to do is to set up a character buffer and sprintf the HRESULT into it using %lx as the format specification.

Or if you want to get fancy, you could set up a quick switch statement based on the HRESULT and using the text descriptions for the errors that you will find in dinput.h.

Hope this helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top