mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-11-04 01:19:38 +01:00 
			
		
		
		
	+ Implementation of CreateGUID
git-svn-id: trunk@27 -
This commit is contained in:
		
							parent
							
								
									99de6df34e
								
							
						
					
					
						commit
						99658cf4d6
					
				@ -171,6 +171,8 @@ type
 | 
			
		||||
   procedure Beep;
 | 
			
		||||
   function SysErrorMessage(ErrorCode: Integer): String;
 | 
			
		||||
 | 
			
		||||
   Function  CreateGUID(out GUID : TGUID) : Integer;
 | 
			
		||||
 | 
			
		||||
type
 | 
			
		||||
  TTerminateProc = Function: Boolean;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -496,6 +496,27 @@ begin
 | 
			
		||||
    end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
Procedure GetRandomBytes(Var Buf; NBytes : Integer);
 | 
			
		||||
 | 
			
		||||
Var
 | 
			
		||||
  I : Integer;
 | 
			
		||||
  P : PByte;
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
  P:=@Buf;
 | 
			
		||||
  Randomize;
 | 
			
		||||
  For I:=0 to NBytes-1 do
 | 
			
		||||
    P[i]:=Random(256);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{$IFNDEF HASCREATEGUID}
 | 
			
		||||
Function CreateGUID(out GUID : TGUID) : Integer;
 | 
			
		||||
begin
 | 
			
		||||
  Result:=0;
 | 
			
		||||
  GetRandomBytes(GUID,SizeOf(Guid));  
 | 
			
		||||
end;
 | 
			
		||||
{$ENDIF}
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  Revision 1.1  2003/10/06 21:01:06  peter
 | 
			
		||||
 | 
			
		||||
@ -26,6 +26,7 @@ interface
 | 
			
		||||
{$DEFINE HAS_OSCONFIG}
 | 
			
		||||
{$DEFINE HAS_TEMPDIR}
 | 
			
		||||
{$DEFINE HASUNIX}
 | 
			
		||||
{$DEFINE HASCREATEGUID}
 | 
			
		||||
 | 
			
		||||
uses
 | 
			
		||||
  Unix,errors,sysconst,Unixtype;
 | 
			
		||||
@ -64,6 +65,11 @@ Type
 | 
			
		||||
{ Include platform independent implementation part }
 | 
			
		||||
{$i sysutils.inc}
 | 
			
		||||
 | 
			
		||||
{ Include CreateGUID function } 
 | 
			
		||||
 | 
			
		||||
{$i uuid.inc}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Const
 | 
			
		||||
{Date Translation}
 | 
			
		||||
  C1970=2440588;
 | 
			
		||||
@ -1089,6 +1095,7 @@ begin
 | 
			
		||||
    Result:=IncludeTrailingPathDelimiter(Result);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{****************************************************************************
 | 
			
		||||
                              Initialization code
 | 
			
		||||
****************************************************************************}
 | 
			
		||||
 | 
			
		||||
@ -36,6 +36,7 @@ uses
 | 
			
		||||
{$DEFINE HAS_SLEEP}
 | 
			
		||||
{$DEFINE HAS_OSERROR}
 | 
			
		||||
{$DEFINE HAS_OSCONFIG}
 | 
			
		||||
{$DEFINE HAS_CREATEGUID}
 | 
			
		||||
{ Include platform independent interface part }
 | 
			
		||||
{$i sysutilh.inc}
 | 
			
		||||
 | 
			
		||||
@ -64,7 +65,13 @@ implementation
 | 
			
		||||
{ Include platform independent implementation part }
 | 
			
		||||
{$i sysutils.inc}
 | 
			
		||||
 | 
			
		||||
function CoCreateGuid(out guid: TGUID): HResult; stdcall; external 'ole32.dll' name 'CoCreateGuid';
 | 
			
		||||
 | 
			
		||||
function CreateGUID(out Guid: TGUID): HResult;
 | 
			
		||||
begin
 | 
			
		||||
  Result := CoCreateGuid(Guid);
 | 
			
		||||
end;
 | 
			
		||||
  
 | 
			
		||||
{****************************************************************************
 | 
			
		||||
                              File Functions
 | 
			
		||||
****************************************************************************}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user