Everything went very well except for the error handling. When adding my counters a COMException may be thrown. The Exception's message has the hex error code while the ErrorCode property has the value as an integer. I used the following code to convert the ErrorCode to be comparable against hex values provided by MSDN.
Update, an easier way to do this is comException.ErrorCode.ToString("X");
I didn't end up using this method as it was my own application. I thought about using a uint enumeration to store all the error codes and then a dictionary to go lookup the user friendly error messages provided by MSDN, but since it is just a scrap app I didn't bother.
No comments:
Post a Comment