views:

446

answers:

3

Is there a ready-to-use API (C / C++) in Windows Mobile ecosystem that I could use to generate a GUID? I am looking for simple one-shot API to do this. If there is a need to write a whole algorithm or use some extra 3rd-party modules, I will do away without this.

Background. To display notification to the user I use SHNotificationAdd, which requires a GUID for it. Examples in MSDN and other sources show that GUID is hard-coded. However, I want to wrap the SHNotification* within a class that blends well within the overall design of my application. MSDN is very shy on details on what SHNOTIFICATIONDATA->clsid represents. The "class" mentioned raise more questions than it answers.

+5  A: 

Use CoCreateGUID() for Windows Mobile...

jeffamaphone
+1  A: 

You don't need to generate a GUID for SHNOTIFICATIONDATA.

You only set the clsid if you want WM to notify a COM object that implements IshellNotificationCallback interface.

Quote from MSDN:

When loading up the SHNOTIFICATIONDATA structure, you can specify either the notification class (clsid), the window to receive command choices (hwndSink), or both. If you specify the clsid, your COM component must implement IshellNotificationCallback. If you specify the clsid and an hwndSink, both COM and Window Message-style callbacks will be generated.

I've never personally used the COM callback, I always use the windows message callback. It's a lot easier to setup and use and you don't need to generate a GUID.

Shane Powell
A: 

You could also use UuidCreate (which CoCreateGuid eventually calls).

Igor Zevaka