Alguien tendrá una función que genere el codigo uuid() ?
Gracias por anticipado
//-------------------------
// GuID generieren
// Stefan Haupt, April 2005
//-------------------------
#include "FiveWin.ch"
PROCEDURE Main ()
MsgInfo ("GuID16: "+CreateGuID16(.t.)+CRLF+"GuID32: "+CreateGuID32(.t.),"GuID")
RETURN
//------------------------------------------------------------------
// short packed GUID ( 16 byte )
//------------------------------------------------------------------
FUNCTION CreateGuID16 (lNoBracket)
LOCAL nCnt := 1, nID := 0, cID := ""
LOCAL cGuID := ""
DEFAULT lNoBracket := .F.
cID := NewGuid16 ()
FOR nCnt := 1 TO Len(cID)
nID := SubStr(cID,nCnt,1)
cGuID := cGuID + FT_Byt2Hex (nID)
NEXT
cGuid := CharRem ("h",cGuid)
cGuid := PosIns (cGuid,"-",9)
cGuid := PosIns (cGuid,"-",14)
cGuid := PosIns (cGuid,"-",19)
cGuid := PosIns (cGuid,"-",24)
IF !lNoBracket
cGuid := "{"+cGuid+"}"
ENDIF
RETURN (cGuID)
//------------------------------------------------------------------
// standard 38 byte's M$ GuID
//------------------------------------------------------------------
FUNCTION CreateGuID32 (lNoBracket)
LOCAL cGuID := NewGuid()
DEFAULT lNoBracket := .F.
IF lNoBracket
cGuid := CharRem ("{",cGuid)
cGuid := CharRem ("}",cGuid)
ENDIF
RETURN (cGuID)
// Many thanks to Valerie for his help
// and these 2 functions
#pragma BEGINDUMP
#include <windows.h>
#include "hbapi.h"
//------------------------------------------------------------------
// short packed GUID for use in may program ( 16 byte )
//------------------------------------------------------------------
HB_FUNC( NEWGUID16 )
{
GUID mguid;
if ( CoCreateGuid(&mguid) != NULL )
memset(( LPVOID ) &mguid,'?',sizeof( mguid ));
hb_retclen(( LPVOID ) &mguid,sizeof( mguid ));
}
//------------------------------------------------------------------
// standard 38 byte's M$ guid
//------------------------------------------------------------------
HB_FUNC( NEWGUID )
{
GUID guid;
char obuff[38];
memset( obuff, 0x0, 38 );
if ( CoCreateGuid(&guid) == NULL )
{
OLECHAR tmpbuff[76];
StringFromGUID2(&guid,tmpbuff,76);
WideCharToMultiByte(CP_OEMCP,0,tmpbuff,-1,obuff,38,NULL,NULL);
}
hb_retclen(obuff,38);
}
#pragma ENDDUMP
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: No registered users and 47 guests