Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reverse a GUID? Fastest way?
Message
From
22/03/2008 21:05:34
 
 
To
22/03/2008 10:58:11
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01304506
Message ID:
01304643
Views:
11
>PROCEDURE GuidFormat3
>LPARAMETERS m.lcBuffer
>LOCAL m.lcPK,m.i,m.lnHex,m.lnUpper,m.lnLower
>m.lcPK=SPACE(0)
>FOR m.i=1 TO 16
>	m.lnHex = ASC(SUBSTR(m.lcBuffer,m.i,1))
>	m.lnUpper = INT(m.lnHex/16)
>	m.lnLower = m.lnHex - (m.lnUpper*16)
>	m.lcPK = m.lcPK + SUBSTR('0123456789ABCDEF',m.lnUpper + 1,1) + ;
>		SUBSTR('0123456789ABCDEF',m.lnLower + 1,1)
>ENDFOR
>RETURN m.lcPK
GuidFormat3: This is not reversing the string, and its not the standard character representation of a guid, I wonder what are you trying to do here.

It's not equivalent to StringFromGUID2 either, so you are not trying to emulate that... or are you?

The fastest way I know of converting a 128 bit uuid to a string of printable chars is:
Local m.lcGuid As String, m.lnPointer As Integer

m.lcGuid = Replicate(Chr(0xFF), 16)
apiUuidCreate(@m.lcGuid)

m.lnPointer = 0
apiUuidToString(m.lcGuid, @m.lnPointer)

?Sys(2600, m.lnPointer, 36)

********************************************************************************
Function apiUuidCreate(m.Uuid)
********************************************************************************
	Declare Integer UuidCreate In rpcrt4.Dll As apiUuidCreate ;
		String @Uuid
	Return apiUuidCreate(@m.Uuid)
Endfunc

********************************************************************************
Function apiUuidToString(m.Uuid, m.StringUuid)
********************************************************************************
	Declare Integer UuidToString In rpcrt4.Dll As apiUuidToString ;
		String  Uuid, ;
		Integer @StringUuid
	Return apiUuidToString(m.Uuid, @m.StringUuid)
Endfunc
This returns something like this:

a67563fd-4134-4741-80fa-e5a64fabee2a

Carlos
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform