Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / July 2006

Tip: Looking for answers? Try searching our database.

IRunningObjectTable.Register

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
lgs.lgs - 27 Jul 2006 01:19 GMT
Could someone take a look at the docs for this method?

http://windowssdk.msdn.microsoft.com/en-us/library/system.runtime.interopservice
s.comtypes.irunningobjecttable.register.aspx


In particular, I'm interested in the return value.  The docs say it is an
HRESULT.  However, I sincerely doubt this.  If I'm not mistaken, what it is
actually returning is the cookie needed to do the
IRunningObjectTable.Revoke.

When you think about it, if there were an error, wouldn't you expect an
exception rather than an HRESULT?

However, I'm not 100% certain, and a double-check would be appreciated.
Dmytro Lapshyn [MVP] - 27 Jul 2006 10:30 GMT
Hi,

It's a COM trick :) A _physical_ return value of the Register method *is* an
HRESULT. Here's the raw definition:

HRESULT Register(DWORD grfFlags, IUnknown * punkObject, IMoniker *
pmkObjectName, DWORD * pdwRegister);

As you can see, the cookie is physically the last output parameter.

However, in the .NET world, the Interop layer makes things simplier for you.
It hides the HRESULT and pretends that the cookie is *the* return value.
Should the returned HRESULT indicate failure, the Interop layer throws an
exception that, in particular, contains the actual HRESULT value.

Still with me? :) Feel free to follow up, I know it's not a straightforward
topic.

Signature

Regards,
Dmytro Lapshyn [MVP]
http://blogs.vbcity.com/DmytroL

> Could someone take a look at the docs for this method?
>
[quoted text clipped - 10 lines]
>
> However, I'm not 100% certain, and a double-check would be appreciated.
lgs.lgs - 27 Jul 2006 21:30 GMT
> It's a COM trick :)

Thanks for the response.

Yes, I am familiar with the [PreserveSig] trick.  And in general, this is a
good thing in .NET.  However, since IRunningObjectTable is compiled code, I
can't change its behavior.  So, this tells me that it will NOT, under any
circumstances, return an HRESULT to my c# code.

However, the docs which describe using this method specifically say that the
return value *is* an HRESULT.  And they *don't* make any reference at all to
a cookie (which is essential to using ROT).

In short then, the docs are simply wrong.  Which is what I suspected.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.