+ Implementation of CreateGUID

git-svn-id: trunk@27 -
This commit is contained in:
michael 2005-05-19 17:31:25 +00:00
parent 99de6df34e
commit 99658cf4d6
4 changed files with 37 additions and 0 deletions

View File

@ -171,6 +171,8 @@ type
procedure Beep;
function SysErrorMessage(ErrorCode: Integer): String;
Function CreateGUID(out GUID : TGUID) : Integer;
type
TTerminateProc = Function: Boolean;

View File

@ -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

View File

@ -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
****************************************************************************}

View File

@ -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
****************************************************************************}