.NET Framework Bookmark and Share   
 index > .NET Base Class Library > Finding Guids...
 

Finding Guids...

I am just starting to learn all about the wonderful world of GUIDs and Com objects.
I am so confused on how to find the GUID of something.

I'm working with the WMPLIBand all I need to get the GUID so I can get
an interface using the QueryIdentifier to get to the house that Jack built.

And I am so throughly confused as is with Interfaces. I am reading up on them just confused lol.
Any help on the Guid and any extra info (bonus material) would be cool.

Take care everyone! - Stan

StanKnight
Short of examining the registry you can't. COM objects will generally ship with an IDL file or a .h file. Within these files the GUIDs are encoded to be usable in your app without having to hard code them. In general you'll be using something like IID_IMyInterface which maps to the GUID in the header file.

For .NET though you just need to add a reference to the COM object in your project and the IDE will hook up everything.

Finally note that we generally don't use GUIDs directly. Instead we normally use the progid to get to the underlying COM class (such as XmlDocument.1) and then use the IID_ interface macros directly.

Michael Taylor - 9/21/09
http://p3net.mvps.org
TaylorMichaelL
You'll next need to discover the wonders of a type library. There is one built into wmp.dll. You can see it with the OleView.exe utility, File + View Type library and navigate to c:\windows\system32\wmp.dll. A type library is actually binary data but OleView will decompile it into IDL. It describes the interfaces and coclasses available in a COM server, the GUIDs are included.

.NET tools can see this too, you'd either use Tlbimp.exe explicitly or in the IDE use Add Reference, COM tab. That generates a so-called interop library, an assembly that contains the type library info in a format that's friendly to the CLR. It generates .NET interface and class definitions, making the COM code directly usable from a .NET program. QueryInterface, for example, is automatically called when you cast an object to an interface. The other two IUnknown methods, AddRef and Release are automatically called by the CLR, saving you the trouble of getting that wrong.

Perhaps a bit unexciting, but a great way to get it working quickly and trouble-free.
Hans Passant.
nobugz

You can use google to search for other answers

Custom Search

More Threads

• How to open a text file, edit it and then save the changes??
• control .net apps with speech
• Custom Principal class with custom functions
• what is nullable ??, and int?
• Threading issues
• please rich the built-in class of .net framework4.0 about the PKI .
• Zip and Gz Files
• "Access denied " error while accessing windows service in web application
• using WMI Queries to get remote environment variables
• Behavior of LinkedList.Find method?