Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to get the PC serial number or LAN Card Mac Address
Message
De
27/05/2003 04:14:33
Michael Ouellette
Australian Technical Services (VIC) Pty
Australie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00792969
Message ID:
00792979
Vues:
16
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
Fil
Voir

Click here to load this message in the networking platform