Private Declare Function GetVolumeInformation& Lib "kernel32" _
Alias "GetVolumeInformationA" (ByVal lpRootPathName _
As String, ByVal pVolumeNameBuffer As String, ByVal _
nVolumeNameSize As Long, lpVolumeSerialNumber As Long, _
lpMaximumComponentLength As Long, lpFileSystemFlags As _
Long, ByVal lpFileSystemNameBuffer As String, ByVal _
nFileSystemNameSize As Long)
Declare Function GetTickCount& Lib "kernel32" ()
Declare Function QueryPerformanceCounter Lib "kernel32" _
(lpPerformanceCount As Currency) As Long
Declare Function QueryPerformanceFrequency Lib "kernel32" _
(lpFrequency As Currency) As Long
Function GetSerialNumber(strDrive As String) As Long
Dim SerialNum As Long
Dim Res As Long
Dim Temp1 As String
Dim Temp2 As String
Temp1 = String$(255, Chr$(0))
Temp2 = String$(255, Chr$(0))
Res = GetVolumeInformation(strDrive, Temp1, _
Len(Temp1), SerialNum, 0, 0, Temp2, Len(Temp2))
GetSerialNumber = SerialNum
End Function
Public Function HampRND() As Double
Dim curEnd As Currency
Dim curFreq As Currency
Dim fTimeLag As Double
QueryPerformanceFrequency curFreq
QueryPerformanceCounter curStart
QueryPerformanceCounter curEnd
fTimeLag = 1000 * (CDbl(curEnd) - CDbl(curStart)) / CDbl(curFreq)
QueryPerformanceCounter curStart
'*//////////// Start the rand int code
Dim DiskSN As Long, Ticks As Long, CpuTime As Double, total As Double, tmp As Double, total2 As Double
DiskSN = GetSerialNumber("C:\")
Ticks = GetTickCount
QueryPerformanceCounter curEnd
CpuTime = (1000 * (CDbl(curEnd) - CDbl(curStart)) / CDbl(curFreq)) - fTimeLag
'*//////////// End the rand int code
'*//////////// Start Randomizing
QueryPerformanceFrequency curFreq
QueryPerformanceCounter curStart
total = DiskSN + Ticks + CpuTime
total = total + (CpuTime * Ticks)
total = total + (CpuTime ^ (DiskSN / Ticks))
total = total + (Ticks * 2 ^ (CpuTime - Int(CpuTime)))
total = total / 6
tmp = total - Int(total)
total = total Mod 2 ^ 24 * CpuTime
total = total Mod (Ticks / CpuTime)
total = total Mod Left$(DiskSN, 2) & Left$(Ticks, 4) & Left$(CpuTime, 7)
total = total Mod Right$(DiskSN, 2) & Right$(Ticks, 4) & Right$(CpuTime, 7) & totat * CpuTime * Right$(Ticks, 3)
total = total / 10000000
QueryPerformanceCounter curEnd
total2 = ((1000 * (CDbl(curEnd) - CDbl(curStart)) / CDbl(curFreq)) - fTimeLag) / CpuTime
total = total * total2
total = total Mod (total2 * Left$(total, 8))
total = total Xor (total2 * Left$(total, 5))
HampRND = total + tmp
'*//////////// End Randomizing
End Function