Windows API

ID #1035

How to get unique identifier GUID?

  PROGRAM
  MAP
    MODULE('winapi')
CoCreateGuid(*?),UNSIGNED,PASCAL,RAW,DLL(1),NAME('CoCreateGuid')
StringFromGUID2(*?,*?,LONG cchMax),UNSIGNED,PASCAL,RAW,NAME('StringFromGUID2')
WideCharToMultiByte(UNSIGNED CodePage=0,USHORT dwFlags=0,|
*? lpWideCharStr,LONG cchWideChar,*? lpMultiByteStr,|
LONG cbMultiByte,? lpDefaultChar,|
BYTE lpUsedDefaultChar), |
UNSIGNED,PASCAL,RAW,NAME('WideCharToMultiByte')
    END
  END
pGuid  STRING(16)
buf    STRING(128)
buf2   STRING(64)
cbSize LONG
  CODE
  IF CoCreateGuid(pGUID)
    MESSAGE('','GUID is not received.')
  ELSE
    IF StringFromGuid2(pGuid,buf,SIZE(buf)/2)
      cbSize = WideCharToMultiByte(, , buf, -1, buf2, SIZE(buf2), 0,0)
      IF cbSize > 0
        buf2 = buf2[1 : cbSize]
        SETCLIPBOARD(CLIP(buf2))
        MESSAGE(buf2,'GUID is received and placed into clipboard.')
      END
    ELSE
      MESSAGE('Buffer is too small for accepted value.')
    END
  END
Categories for this entry

Tags: COM, GUID

Related entries: -

Last update: 2007-07-17 10:59
Author: Sergey Artyushenkov
Revision: 1.0

Digg it! Print this record Send to a friend Show this as PDF file
Propose a translation for Propose a translation for
Please rate this entry:

Average rating: 5 out of 5 (3 Votes )

completely useless 1 2 3 4 5 most valuable

You can comment on this entry