1. Create a global external function
FUNCTION long uuidCreate(ref s_uuid astr_uuid) LIBRARY "Rpcrt4.dll" ALIAS FOR "UuidCreate"
*********************************************************************************************************************
2. Create a global function f_generate_uuid
Function f_generate_uuid(String as_type)
Long ll_rc
s_uuid lstr_uuid
string ls_guid = ""
constant long RPC_S_OK = 0
constant long RPC_S_UUID_LOCAL_ONLY = 1824
constant long RPC_S_UUID_NO_ADDRESS = 1739
ll_rc = uuidCreate(lstr_uuid)
// returns
// RPC_S_OK - The call succeeded.
// RPC_S_UUID_LOCAL_ONLY -
// The UUID is guaranteed to be unique to this computer only.
// RPC_S_UUID_NO_ADDRESS -
// Cannot get Ethernet/token-ring hardware address for this computer.
IF ll_rc <> RPC_S_OK THEN
setNull(ls_GUID)
// MessageBox("", "uuid create not ok ?!?")
ELSE
If as_type = 'F' Then
ls_GUID = right("00000000" + of_hex(lstr_uuid.data1), 8)
ls_GUID += "-" + right("0000" + of_hex(lstr_uuid.data2), 4)
ls_GUID += "-" + right("0000" + of_hex(lstr_uuid.data3), 4)
ls_GUID += "-" + right("0000" + of_hex(lstr_uuid.data4[1]), 4)
ls_GUID += "-" + right("0000" + of_hex(lstr_uuid.data4[2]), 4) &
+ right("0000" + of_hex(lstr_uuid.data4[3]), 4) &
+ right("0000" + of_hex(lstr_uuid.data4[4]), 4)
ls_GUID = upper(ls_GUID)
// MessageBox("", ls_guid)
// output example : 00003B93-2641-477A-C99E-A2FFEBEB214A
Elseif as_type = 'R' Then
ls_GUID = right("00000000" + of_hex(lstr_uuid.data1), 8)
ls_GUID += right("0000" + of_hex(lstr_uuid.data2), 4)
ls_GUID += right("0000" + of_hex(lstr_uuid.data3), 4)
ls_GUID += right("0000" + of_hex(lstr_uuid.data4[1]), 4)
ls_GUID += right("0000" + of_hex(lstr_uuid.data4[2]), 4) &
+ right("0000" + of_hex(lstr_uuid.data4[3]), 4) &
+ right("0000" + of_hex(lstr_uuid.data4[4]), 4)
ls_GUID = upper(ls_GUID)
End If
End If
Return ls_guid
**************************************************************************
3. Call the above function
ls_uuid = f_generate_uuid('R') // Without hypen in between
OR
ls_uuid = f_generate_uuid('F') // With hypen in between
Use this resultant value the way you want.
*********************************************************************
HTH
Happiness Always
BKR Sivaprakash