Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Uniqueness of SYS(2015)
Message
From
27/06/2007 22:30:47
Walter Nicholls
Cornerstone Software Ltd
Auckland, New Zealand
 
 
To
27/06/2007 21:52:33
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01235219
Message ID:
01236180
Views:
17
> >Does this require Windows Scripting Host?
> Yes.

This doesn't:
function GenerateGUID()
	declare integer CoCreateGuid in ole32.dll string @guid

	declare integer StringFromGUID2 in ole32.dll ;
		string @cCLSID, string @cUnicodeString, integer nLen
		
	local sGUIDBuffer, sTextBuffer, sGUID, nLength
	sGUIDBuffer = replicate(chr(0),16)	&& 128 bit buffer
	if CoCreateGuid( @sGUIDBuffer) != 0
		return null && error
	endif
	sTextBuffer = replicate(chr(0),80) && 39 unicode chars + null terminator
	nLength = StringFromGUID2( @sGUIDBuffer, @sTextBuffer, 40 )

	if m.nLength = 0
		return null  && error, probably buffer too small
	endif

	sGUID = strconv( left( m.sTextBuffer, nLength*2-1),10)
	return sGUID
endfunc
The result is an up-to-39 character string of the form like {093A8107-E749-456E-9379-B2CCE2793694}

If you want another format, sGUIDBuffer is the raw binary form.
Previous
Reply
Map
View

Click here to load this message in the networking platform