Create GUID from Harbour
- don lowenstein
- Posts: 196
- Joined: Mon Oct 17, 2005 9:09 pm
- Contact:
Create GUID from Harbour
Does anyone know how to create a GUID from Harbour?
Don Lowenstein
www.laapc.com
www.laapc.com
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: Create GUID from Harbour
Don,
EMG
don lowenstein wrote:Does anyone know how to create a GUID from Harbour?
Code: Select all
#include "Fivewin.ch"
FUNCTION MAIN()
? CREATEOBJECT( "Scriptlet.TypeLib" ):Guid
RETURN NIL
- carlos vargas
- Posts: 1421
- Joined: Tue Oct 11, 2005 5:01 pm
- Location: Nicaragua
Re: Create GUID from Harbour
Code: Select all
FUNCTION CreateGuID32( lNoBracket )
LOCAL cGuID := NewGuid()
DEFAULT lNoBracket := .F.
IF lNoBracket
cGuid := CharRem ("{", cGuid )
cGuid := CharRem ("}", cGuid )
ENDIF
RETURN ( cGuID )
/*-------------------------------------------------------------------------------------------------*/
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 + DecToHex( nID )
NEXT
cGuid := CharRem ( "h", cGuid )
cGuid := PosIns( cGuid, "-", 09 )
cGuid := PosIns( cGuid, "-", 14 )
cGuid := PosIns( cGuid, "-", 19 )
cGuid := PosIns( cGuid, "-", 24 )
IF !lNoBracket
cGuid := "{" + cGuid + "}"
ENDIF
RETURN ( cGuID )
#pragma BEGINDUMP
/*llamada a encabezados de api de xharbour y windows SDK*/
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbapierr.h"
#include "shlobj.h"
#include "windows.h"
/*funcion wrapper para obtener una cadena GUID de 16 bits*/
HB_FUNC( NEWGUID16 )
{
GUID mguid;
if( !CoCreateGuid(&mguid) )
{
memset( ( LPVOID ) &mguid,'?',sizeof( mguid ));
}
hb_retclen( (char *) &mguid,sizeof( mguid ) );
}
/*-------------------------------------------------------------------------------------------------*/
/*funcion wrapper para obtener una cadena GUID de 32 bits*/
HB_FUNC( NEWGUID )
{
GUID guid;
char obuff[38];
memset( obuff, 0x0, 38 );
if( CoCreateGuid( &guid ) )
{
OLECHAR tmpbuff[ 76 ];
StringFromGUID2( &guid, tmpbuff, 76 );
WideCharToMultiByte( CP_OEMCP, 0, tmpbuff, -1, obuff, 38, NULL, NULL );
}
hb_retclen( obuff, 38 );
}
#pragma ENDDUMP
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
Carlos Vargas
Desde Managua, Nicaragua (CA)
- manuelcalerosolis
- Posts: 149
- Joined: Mon Oct 10, 2005 9:30 am
- Location: Huelva - Spain
Re: Create GUID from Harbour
Carlos,
Intento usar su función de generación de GUID de 32 bits pero me devuelve una cadena vacía.
Alguna idea?
Saludos.
Intento usar su función de generación de GUID de 32 bits pero me devuelve una cadena vacía.
Alguna idea?
Saludos.
Re: Create GUID from Harbour
In the hbwin contrib library harbour has the function win_uuidcreatestring()
- manuelcalerosolis
- Posts: 149
- Joined: Mon Oct 10, 2005 9:30 am
- Location: Huelva - Spain
Re: Create GUID from Harbour
Rhlawek thanks.