Create GUID from Harbour

Create GUID from Harbour

Postby don lowenstein » Fri Jan 31, 2014 6:56 pm

Does anyone know how to create a GUID from Harbour?
Don Lowenstein
www.laapc.com
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Re: Create GUID from Harbour

Postby Enrico Maria Giordano » Fri Jan 31, 2014 8:59 pm

Don,

don lowenstein wrote:Does anyone know how to create a GUID from Harbour?


Code: Select all  Expand view  RUN
#include "Fivewin.ch"


FUNCTION MAIN()

    ? CREATEOBJECT( "Scriptlet.TypeLib" ):Guid

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Create GUID from Harbour

Postby carlos vargas » Sat Feb 01, 2014 1:42 am

Code: Select all  Expand view  RUN

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)
User avatar
carlos vargas
 
Posts: 1721
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: Create GUID from Harbour

Postby manuelcalerosolis » Wed Jun 21, 2017 4:55 pm

Carlos,

Intento usar su función de generación de GUID de 32 bits pero me devuelve una cadena vacía.

Alguna idea?

Saludos.
User avatar
manuelcalerosolis
 
Posts: 149
Joined: Mon Oct 10, 2005 9:30 am
Location: Huelva - Spain

Re: Create GUID from Harbour

Postby rhlawek » Wed Jun 21, 2017 5:27 pm

In the hbwin contrib library harbour has the function win_uuidcreatestring()
User avatar
rhlawek
 
Posts: 194
Joined: Sun Jul 22, 2012 7:01 pm

Re: Create GUID from Harbour

Postby manuelcalerosolis » Thu Jun 22, 2017 8:12 am

Rhlawek thanks.
User avatar
manuelcalerosolis
 
Posts: 149
Joined: Mon Oct 10, 2005 9:30 am
Location: Huelva - Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 32 guests