PlanetSquires Forums

Support Forums => José Roca Software => Topic started by: Richard Kelly on May 13, 2026, 07:10:48 AM

Title: GUID's
Post by: Richard Kelly on May 13, 2026, 07:10:48 AM
I had some old code below for creating guid's when I needed them. Is there something in Afx that is equivalent?

#Include once "windows.bi"
#Include once "win/uuids.bi"
#Include once "win/ole2.bi"

Dim guid As GUID
Dim wstrGUID As LPOLESTR
Dim strGUID As ZString * 260

    CoCreateGuid (@guid)
    If(StringFromCLSID (@guid, @wstrGUID) = S_OK) THEN
       WideCharToMultiByte (CP_ACP, 0, Cast(WString Ptr,wstrGUID), -1, strGUID, MAX_PATH, NULL, NULL)
        Print strGUID
     EndIf
    CoTaskMemFree(@wstrGUID)
Title: Re: GUID's
Post by: Paul Squires on May 13, 2026, 07:14:42 PM
Check out AfxCOM.inc

PRIVATE FUNCTION AfxGuid (BYVAL pwszGuidText AS WSTRING PTR = NULL) AS GUID
PRIVATE FUNCTION AfxGuidText OVERLOAD (BYVAL classID AS CLSID PTR) AS STRING
PRIVATE FUNCTION AfxGuidText OVERLOAD (BYVAL classID AS CLSID) AS STRING
PRIVATE FUNCTION AfxGuidText OVERLOAD (BYVAL riid AS REFIID) AS STRING


Title: Re: GUID's
Post by: Richard Kelly on May 13, 2026, 07:54:42 PM
I knew Jose had something somewhere and, while I looked in a lot of Afx includes, I didn't look in AfxCOM.

The code below works perfectly.

DIM uGUID AS GUID
uGUID = AfxGuid()
print AfxGuidText(@uGUID)