The following demonstrates how to use VB.NET language to download random data from SwiftRNG device when used with 64 bit Windows. Before using the following examples, make sure your VB.NET project is targeted for Windows 64 bit platform and the SwiftRNG device is plugged into one of USB ports available. A thread-safe and process-safe 64 bit SwiftRNG.dll is included in the software kit.

Note: The following methods are deprecated. Please use alternative methods as described at this location.

A sample source code for retrieving one byte from SwiftRNG device

Module Module1
    ' Include the exact path to the SwiftRNG.dll (it uses additional dependencies from same location) available with the software kit.
    Declare Ansi Function getRandomByte Lib "C:\tools\windows-x64\x64\Release\SwiftRNG.dll" Alias "swftGetEntropyByteSynchronized" () As Integer
    Sub Main()
        Dim rnd As Integer = getRandomByte()
        If rnd < 256 Then
            'Successfully generated a random byte value
            Console.Write("Random byte: ")
            Console.WriteLine(rnd)
        Else
            'Number greater than 255 means error
            'Generator not present or generation error
            Console.WriteLine("SwiftRNG Not connected Or device Error")
        End If
    End Sub

End Module

A sample source code for retrieving primitive type random values from SwiftRNG device

Imports System.Runtime.InteropServices

Module Module1
    Declare Ansi Function getRandomDouble Lib "C:\tools\windows-x64\x64\Release\SwiftRNG.dll" _
        Alias "swftGetEntropySynchronized" (ByRef d As Double, ByVal byteCount As Integer) As Integer

    Declare Ansi Function getRandomInt Lib "C:\tools\windows-x64\x64\Release\SwiftRNG.dll" _
        Alias "swftGetEntropySynchronized" (ByRef i As Integer, ByVal byteCount As Integer) As Integer

    Declare Ansi Function getRandomUInt64 Lib "C:\tools\windows-x64\x64\Release\SwiftRNG.dll" _
        Alias "swftGetEntropySynchronized" (ByRef i As UInt64, ByVal byteCount As Integer) As Integer

    Sub Main()
        Dim d As Double
        Dim status As Integer = getRandomDouble(d, Marshal.SizeOf(Of Double))
        If status <> 0 Then
            Console.WriteLine("Could not retrieve a random double from SwiftRNG device")
        Else
            Console.Write("Random double: ")
            Console.WriteLine(d)
        End If

        Dim n As Integer
        status = getRandomInt(n, Marshal.SizeOf(Of Integer))
        If status <> 0 Then
            Console.WriteLine("Could not retrieve a random integer from SwiftRNG device")
        Else
            Console.Write("Random integer: ")
            Console.WriteLine(n)
        End If

        Dim ui64 As UInt64
        status = getRandomUInt64(ui64, Marshal.SizeOf(Of UInt64))
        If status <> 0 Then
            Console.WriteLine("Could not retrieve a random UInt64 from SwiftRNG device")
        Else
            Console.Write("Random UInt64: ")
            Console.WriteLine(ui64)
        End If

    End Sub

End Module

A sample source code for retrieving up to 10,000,000 bytes from SwiftRNG device with a single call

Module Module1
    ' Include the exact path to the SwiftRNG.dll (it uses additional dependencies from same location) available with the software kit.
    Declare Ansi Function getRandom Lib "C:\tools\windows-x64\x64\Release\SwiftRNG.dll" _
        Alias "swftGetEntropySynchronized" (randomBytes As Byte(), length As Long) As Integer
    Sub Main()
        Dim status As Integer
        Dim randomBytes(0 To 9999999) As Byte

        status = getRandom(randomBytes, randomBytes.Length)

        If status = 0 Then
            'Successfully generated a random byte array
            Console.Write("Random byte array generated with success")
        Else
            'A non zero status code indicates an error
            Console.WriteLine("SwiftRNG Not connected Or device Error or invalid request")
        End If
    End Sub

End Module