views:

685

answers:

1

I'm working with the new Windows 7 audio APIs, and I've hit a wall.

Basically, I need to take an IAudioSessionControl2* and get an ISimpleAudioVolume* out of it.

Now, it looks like I can call on IAudioSessionManager->GetSimpleAudioVolume() using the value of IAudioSessionControl2->GetSessionInstanceIdentifier(...). Note that this isn't exactly spelled out as such in the docs, but it seems like a reasonable behavior.

The problem, GetSimpleAudioVolume() takes a GUID* and GetSessionInstanceIdentifier() spits out a LPWSTR. Through debugging I've confirmed that the return'd value from GetSessionInstanceIdentifier() at least looks like a GUID.

So, the actual question is how would I convert the LPWSTR I've got into a GUID? I realise this is pretty trivial if I marshal across into some managed code and use built-in GUID, but there's got to be a C++ way of doing this.


Ok, these APIs definately do not work the way I say they do in the above text dump. However, the basic question of String -> GUID is answered so I'm not going to delete the question.

+5  A: 

Try CLSIDFromString. A CLSID is actually defined as:

typedef GUID CLSID;

therefore you can use CLSIDFromString to generate a GUID. Here's some sample code:

LPWSTR guidstr;
GUID guid;

...

HRESULT hr = CLSIDFromString(guidstr, (LPCLSID)&guid);
if (hr != S_OK) {
    // bad GUID string...
    ...
}
Jared Oberhaus