Information générale
Catégorie:
Fonctions Windows API
I think I got this from UT or maybe Tek-tips.
Can't remember who to credit though...
*This is where a UUID (Univerally Unique ID)comes in. UUID's are a IEEE standard method of generating Universally Unique values. What this means is the values returned are unique across time and space. The code below calls the Windows API and returns a UUID.
Function getUUID
*-- The UUID Create function is in this library
* was C:\Windows\System\RPCRT4.DLL
DECLARE Integer UuidCreate IN RPCRT4.DLL ;
String @ UUID && note that mixed case is important for UuidCreate
*-- Create a buffer
lcUUID = Space(16)
*-- generate the key
=UUIDCreate(@lcUUID)
*-- Convert the binaries to hex values
lcPart1 = BinAsHex(Substr(lcUUID,1,4))
lcPart2 = BinAsHex(Substr(lcUUID,5,4))
lcPart3 = BinAsHex(Substr(lcUUID,8,4))
lcPart4 = BinAsHex(Substr(lcUUID,13,4))
Local lcRetVal
lcRetVal = lcPart1 + lcPart2 + lcPart3 + lcPart4
Return Left(lcRetVal,8) + "-" + substr(lcRetVal,9,4) + "-" + substr(lcRetVal,13,4) + "-" + ;
substr(lcRetVal,17,4) + "-" + Right(lcRetVal,12)
PROCEDURE binashex
Parameters lcBin
* translates a binary string into character string of hex
LOCAL lcChars, lnBin
lcChars = ""
FOR lnDigit = 1 TO LEN(lcBin)
lnBin = ASC(SUBSTR(lcBin, lnDigit, 1))
lcChars = lcChars + Hex2Char(INT(lnBin/16)) + ;
Hex2Char(MOD(lnBin,16))
ENDFOR
RETURN(lcChars)
PROCEDURE hex2char
* takes a hex digit value and returns a character from 0-9 & A-F
LPARAMETERS lnHex
DO CASE
CASE BETWEEN(lnHex,0,9) && 0-9 maps to numbers where asc 48 = '0'
lnAsc = 48 + lnHex
CASE BETWEEN(lnHex,10,15) && 10-15 maps to letters where asc 65 = 'A'
lnAsc = 65 + lnHex - 10
ENDCASE
RETURN(CHR(lnAsc))
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement