mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 13:29:14 +02: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;
|
procedure Beep;
|
||||||
function SysErrorMessage(ErrorCode: Integer): String;
|
function SysErrorMessage(ErrorCode: Integer): String;
|
||||||
|
|
||||||
|
Function CreateGUID(out GUID : TGUID) : Integer;
|
||||||
|
|
||||||
type
|
type
|
||||||
TTerminateProc = Function: Boolean;
|
TTerminateProc = Function: Boolean;
|
||||||
|
|
||||||
|
@ -496,6 +496,27 @@ begin
|
|||||||
end;
|
end;
|
||||||
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
|
Revision 1.1 2003/10/06 21:01:06 peter
|
||||||
|
@ -26,6 +26,7 @@ interface
|
|||||||
{$DEFINE HAS_OSCONFIG}
|
{$DEFINE HAS_OSCONFIG}
|
||||||
{$DEFINE HAS_TEMPDIR}
|
{$DEFINE HAS_TEMPDIR}
|
||||||
{$DEFINE HASUNIX}
|
{$DEFINE HASUNIX}
|
||||||
|
{$DEFINE HASCREATEGUID}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Unix,errors,sysconst,Unixtype;
|
Unix,errors,sysconst,Unixtype;
|
||||||
@ -64,6 +65,11 @@ Type
|
|||||||
{ Include platform independent implementation part }
|
{ Include platform independent implementation part }
|
||||||
{$i sysutils.inc}
|
{$i sysutils.inc}
|
||||||
|
|
||||||
|
{ Include CreateGUID function }
|
||||||
|
|
||||||
|
{$i uuid.inc}
|
||||||
|
|
||||||
|
|
||||||
Const
|
Const
|
||||||
{Date Translation}
|
{Date Translation}
|
||||||
C1970=2440588;
|
C1970=2440588;
|
||||||
@ -1089,6 +1095,7 @@ begin
|
|||||||
Result:=IncludeTrailingPathDelimiter(Result);
|
Result:=IncludeTrailingPathDelimiter(Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{****************************************************************************
|
{****************************************************************************
|
||||||
Initialization code
|
Initialization code
|
||||||
****************************************************************************}
|
****************************************************************************}
|
||||||
|
@ -36,6 +36,7 @@ uses
|
|||||||
{$DEFINE HAS_SLEEP}
|
{$DEFINE HAS_SLEEP}
|
||||||
{$DEFINE HAS_OSERROR}
|
{$DEFINE HAS_OSERROR}
|
||||||
{$DEFINE HAS_OSCONFIG}
|
{$DEFINE HAS_OSCONFIG}
|
||||||
|
{$DEFINE HAS_CREATEGUID}
|
||||||
{ Include platform independent interface part }
|
{ Include platform independent interface part }
|
||||||
{$i sysutilh.inc}
|
{$i sysutilh.inc}
|
||||||
|
|
||||||
@ -64,7 +65,13 @@ implementation
|
|||||||
{ Include platform independent implementation part }
|
{ Include platform independent implementation part }
|
||||||
{$i sysutils.inc}
|
{$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
|
File Functions
|
||||||
****************************************************************************}
|
****************************************************************************}
|
||||||
|
Loading…
Reference in New Issue
Block a user