Task

If your system has a means to generate random numbers involving not only a software algorithm   (like the /dev/urandom devices in Unix),   then:

show how to obtain a random 32-bit number from that mechanism.

Related task
 Random_number_generator_(included)


 
program Random_number_generator;
 
{$APPTYPE CONSOLE}
 
uses
  System.SysUtils,
  Winapi.WinCrypt;
 
var
  hCryptProv: NativeUInt;
  i: Byte;
  UserName: PChar;
 
function Random: UInt64;
var
  pbData: array[0..7] of byte;
  i: integer;
begin
  if not CryptGenRandom(hCryptProv, 8, @pbData[0]) then
    exit(0);
  Result := 0;
  for i := 0 to 7 do
    Result := Result + (pbData[i] shl (8 * i));
end;
 
procedure Randomize;
begin
  CryptAcquireContext(hCryptProv, UserName, nil, PROV_RSA_FULL, 0);
end;
 
begin
  Randomize;
  for i := 0 to 9 do
    Writeln(Random);
  Readln;
end.