?
Solved

How to get GUID using WinAPI

Posted on 1998-05-15
7
Medium Priority
?
386 Views
Last Modified: 2013-12-03
I need to get the GUID of an object at "run-time".  I realize that most GUIDs are available in the header files provided in the Win32 SDK, but I need to get a GUID at run-time for a call to CoCreateInstance().

Essentially, I am attempting to call an OLE object from a non-object oriented language through Win32 API calls. I've got it working with the GUIDs generated by the macros in the SDK header files, but I can't seem to find a way to get a GUID at run-time.
0
Comment
Question by:dnavarro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 7

Expert Comment

by:galkin
ID: 1402078
GUID is static unique information specific to every server or interface. If you know what objects you want to call you can descover their CLSIDs or interface IDs.
0
 
LVL 1

Author Comment

by:dnavarro
ID: 1402079
Okay, so how do I get a CLSID at run-time?  For example, at run-time how do I get a CLSID for "iShellLink"?

Thanks for your help.


0
 
LVL 7

Expert Comment

by:galkin
ID: 1402080
This is global unique name. Object is identified by this number. How are you going to identify interface or object you want to create? you are saying you want to create IShellLink so you try to identify interface usig name. This is not supposed to be unique in space in time. That's why COM uses GUID instaed of names. if you are still going to do this by name you can create static map from name to GUID.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 1

Author Comment

by:dnavarro
ID: 1402081
What I want to do is call an OLE object at runtime.  I do not know the name of the object or the ID of the object, that is supplied by the user.

As a test, I thought I would try iShellLink.  My 'hope' was that I could pass the object name and file name to an API call and get back a CLSID compatible with CoCreateObject.

I've successfully used the CLSID during compile time from the win32 header fiiles, so I know the code works, but I don't know how to get a CLSID at run-time.

I haven't been able to read the CLSID's from the header file and "type them in" because they are actually created by pre-processor macros.
0
 
LVL 7

Accepted Solution

by:
galkin earned 450 total points
ID: 1402082
You can get CLSID from program ID and vice versa with CLSIDFromProgID. But not all servers implement ProgID but they do implement CLSID. Anyway CLSID is the only number you can locate server and it is fundamental of COM.
0
 
LVL 1

Author Comment

by:dnavarro
ID: 1402083
I was able to use CLSIDfromProgID with an OCX I've been testing, but not with iShellLink.  Apparently the objects built-in to Windows don't have CLSID's in the registry.  But I think I could use CLSIDfromString if I new what CLSID string to pass.  Any ideas?

Thank you for your answer.
0
 
LVL 7

Expert Comment

by:galkin
ID: 1402084
IShellLink is interface not server. when you creat object with CoCreateInstance the first parameter you supply is CLSID of the server. CLSIDFromString simply converts string representation of CLSID into 128bit number(more precisely structure that has four numbers and ocupies 128bit).
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question