Groups | Blog | Home
all groups > dotnet interop > july 2003 >

dotnet interop : How to deal with HRESULT


Jeremy Cowles
7/25/2003 1:41:59 PM
An HRESULT is defined as the following:

typedef long HRESULT;


But for COM Interop, functions that return Long values cause my system to
crash (and show up as an Unsupported type in VB 6 Object Browser). So what
is the proper return value for a function that returns an HRESULT?

I was looking through the .NET docs, and I noticed, that when they convert
HRESULT functions, they do so as a Sub with no return value. How can this
be? Or does .NET automatically convert Exceptions to HRESULTs?

____________________

Nevermind, I just found my answer in the .NET docs, I am only posting this
for anyone else trying to solve this problem.

Here is the URL (HRESULTs and Exceptions):
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconhresultsexceptions.asp


Jeremy
a-davids NO[at]SPAM online.microsoft.com
7/25/2003 8:36:30 PM
A long in C/C++ is 32-bits. A long in C# (Long in VB.NET) is 64-bits so
these types are incompatible. An HRESULT is typically defined as int (C#),
Integer (VB.NET), or System.Int32 (C#, VB.NET, or any .NET language).

Change the type to something that is 32-bits instead of 64 and see if that
helps.

Dave Stucki
Microsoft Developer Support
AddThis Social Bookmark Button