uuidof

Everything else that doesn't fall into one of the other PB categories.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

uuidof

Post by Polo »

Hi,

Do you know if there is any equivalent of the function "uuidof" for Purebasic?
It is used on an interface.

Thanks !
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: uuidof

Post by ts-soft »

I think you can use this:

Code: Select all

Procedure StringToBStr(string.s)
  Protected *Buffer = AllocateMemory(StringByteLength(string, #PB_Unicode) + 2)
  Protected bstr_string.i
  If *Buffer
    PokeS(*Buffer, string, -1, #PB_Unicode)
    bstr_string = SysAllocString_(*Buffer)
    FreeMemory(*Buffer)
  EndIf
  ProcedureReturn bstr_string
EndProcedure

Define.GUID UUID

uidstr.i = StringToBStr("{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}")
CLSIDFromString_(uidstr, @UUID)
SysFreeString_(uidstr)
Debug UUID
not tested, only to illustrate

greetings
Thomas
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: uuidof

Post by srod »

You might also want to look at the function COMate_GetIIDFromName() from the COMatePLUS source which will search your registry for an interface's 'friendly name' (e.g. iUnknown) and, if found, will return the appropriate GUID etc.
I may look like a mule, but I'm not a complete ass.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: uuidof

Post by Polo »

Thanks a lot for the quick replies, I will try what you suggested!
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: uuidof

Post by Polo »

ts-soft wrote:I think you can use this:

Code: Select all

Procedure StringToBStr(string.s)
  Protected *Buffer = AllocateMemory(StringByteLength(string, #PB_Unicode) + 2)
  Protected bstr_string.i
  If *Buffer
    PokeS(*Buffer, string, -1, #PB_Unicode)
    bstr_string = SysAllocString_(*Buffer)
    FreeMemory(*Buffer)
  EndIf
  ProcedureReturn bstr_string
EndProcedure

Define.GUID UUID

uidstr.i = StringToBStr("{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}")
CLSIDFromString_(uidstr, @UUID)
SysFreeString_(uidstr)
Debug UUID
not tested, only to illustrate

greetings
Thomas
After testing this was exactly what I needed, thank you Thomas!
Post Reply