Page 1 of 1

Data Statement Support for GUID's and CLSID's

Posted: Mon Aug 06, 2007 11:24 pm
by akj
Please add a new Data statement type so that

Code: Select all

DataSection 
Data.l $332C4425 
Data.w $26CB,$11D0 
Data.b $B4,$83,$00,$C0,$4F,$D9,$01,$19
EndDataSection
can be shortened to:

Code: Select all

DataSection
Data.g {332C4425-26CB-11D0-B483-00C04FD90119}
EndDataSection
and/or to:

Code: Select all

DataSection
Data.g 332C4425-26CB-11D0-B483-00C04FD90119
EndDataSection

Posted: Tue Aug 07, 2007 1:22 am
by Rescator
Actually a "virtual" function to do that would be much better as you could then use it sort of directly when using API calls as well.
Like: SomeApiCallHere_(GUID("{332C4425-26CB-11D0-B483-00C04FD90119}"))
GUID() basically turns the string into 16byte binary and returns a pointer.

Or something similar to that.

Or even a

#SomeGUID=GUID("{332C4425-26CB-11D0-B483-00C04FD90119}")

So you could do:
SomeApiCallHere_(#SomeGUID) ;basically a pointer to the 16byte data.

Or even maybe:

Define someguid.guid
someguid=GUID("{332C4425-26CB-11D0-B483-00C04FD90119}")

So you could do:
SomeApiCallHere_(someguid) ;basically someguid would be a pointer in this case I guess.

Question is, how common is GUID's on Linux or Mac?
And if it's only used on Windows is it worth the effort adding it?

http://en.wikipedia.org/wiki/Globally_U ... [quote]The term GUID usually refers to Microsoft's implementation of the Universally Unique Identifier (UUID) standard; however, many other pieces of software use the term GUID including Oracle Database, dBase and Novell eDirectory. The GUID is also the basis of the GUID Partition Table, Intel's replacement for Master Boot Records under EFI.[/quote]

Edit: more info
http://en.wikipedia.org/wiki/Universall ... Identifier
A Universally Unique Identifier is an identifier standard used in software construction, standardized by the Open Software Foundation (OSF) as part of the Distributed Computing Environment (DCE).
Even Atom and some RSS feeds use them.
So maybe some UUID support is warranted?

Re: Data Statement Support for GUID's and CLSID's

Posted: Tue Aug 07, 2007 5:07 am
by helpy
akj wrote:Please add a new Data statement type so that

Code: Select all

DataSection 
Data.l $332C4425 
Data.w $26CB,$11D0 
Data.b $B4,$83,$00,$C0,$4F,$D9,$01,$19
EndDataSection
can be shortened to...[/code]
You could use a macro:

Code: Select all

Macro GUID(__name, __l, __w1, __w2, __b1, __b2, __b3, __b4, __b5, __b6, __b7, __b8)
DataSection
__name:
  Data.l $__l
  Data.w $__w1, $__w2
  Data.b $__b1, $__b2, $__b3, $__b4, $__b5, $__b6, $__b7, $__b8
EndDataSection
EndMacro

GUID(CLSID_Test,332C4425,26CB,11D0,B4,83,00,C0,4F,D9,01,19)

Re: Data Statement Support for GUID's and CLSID's

Posted: Tue Aug 07, 2007 5:28 am
by PB
> You could use a macro

True, but I'm guessing akj wants to be able to copy-and-paste the GUID
into his code, because they're such a hassle to type manually, and a macro
doesn't help because it still requires manual typing of each component.

Alternatively, akj could write an add-in tool that takes the GUID and puts
it into 3 data statements automatically for him, and then auto-types it into
the editor, or puts it in the clipboard. ;)

[Edit] Had the wrong user name in my post.

Posted: Tue Aug 07, 2007 8:30 am
by ts-soft
Many of guid, clsid, iid can you simple import:

Code: Select all

Import "uuid.lib"
  CLSID_TaskbarList
  IID_ITaskbarList
EndImport

Procedure HideFromTaskBar(hWnd.l, Flag.l)
  Protected TBL.ITaskbarList

  CoInitialize_(0)
  If CoCreateInstance_(@CLSID_TaskBarList, 0, 1, @IID_ITaskBarList, @TBL) = #S_OK
    TBL\HrInit()
    If Flag
      TBL\DeleteTab(hWnd)
    Else
      TBL\AddTab(hWnd)
    EndIf
    TBL\Release()
  EndIf
  CoUninitialize_()

EndProcedure

; DataSection
;   CLSID_TaskBarList:
;   Data.l $56FDF344
;   Data.w $FD6D, $11D0
;   Data.b $95, $8A, $00, $60, $97, $C9, $A0, $90
;   IID_ITaskBarList:
;   Data.l $56FDF342
;   Data.w $FD6D, $11D0
;   Data.b $95, $8A, $00, $60, $97, $C9, $A0, $90
; EndDataSection

If OpenWindow(0, #PB_Ignore, #PB_Ignore, 640, 480, "test")
  HideFromTaskBar(WindowID(0), #True)
  While WaitWindowEvent() <> 16 : Wend 
EndIf

Posted: Tue Aug 07, 2007 8:42 am
by Flype
ts-soft wrote:Many of guid, clsid, iid can you simple import:

Code: Select all

Import "uuid.lib"
  CLSID_TaskbarList
  IID_ITaskbarList
EndImport
whaoo that's great tip. i didn't know that. thanks you ts-soft.

Posted: Tue Aug 07, 2007 10:57 am
by ts-soft
Here an importfile with over 3000 imports of CLSID, GUID and IID
It's autogenerated but should work

http://ts-soft.eu/dl/GUID_CLID_IID_Import.zip

Posted: Tue Aug 07, 2007 1:24 pm
by freak
I would not include the whole list all the time, as then all the imported GUIDs will
get linked even if not used in the code. (just check the exe size,
its about 50k larger with the full list compared to a single import)

A nice little macro can be helpful here:

Code: Select all

Macro ImportGUID(name)
  CompilerIf Defined(name, #PB_Variable) = 0
    Import "uuid.lib"
      name
    EndImport
  CompilerEndIf
EndMacro

ImportGUID(IID_IXMLElementCollection)
x = @IID_IXMLElementCollection
With the compilerif, even multiple use with the same name is no error.

To further the number of possibilities, here are two ways from me to define
such values (in case one is not contained in the above list):

There is my GUIDViewer tool that exist since a while that has all the GUIDs from
the MS headers and generates the PB datasections:
http://freak.purearea.net/tools/GuidViewer.zip

My prefered way however is included in my COM Framework (here: http://freak.purearea.net/tools/ComFramework.zip)
It includes a resident called "GuidList.res", which contains a macro to
automatically define the GUIDs from the GUIDViewer tool.
There you can just do this and it automatically inserts the needed datasection:

Code: Select all

DefineKnownGuid(IID_IXMLElementCollection)
x = ?IID_IXMLElementCollection
So... do you still think a spechial compiler feature is needed for this ? ;)

Posted: Tue Aug 07, 2007 2:03 pm
by ts-soft
very nice macro, thanks