Mr. Kiran V. Sutar
Newbie level 4
- Joined
- Dec 17, 2003
- Messages
- 5
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- Mumbai, India
- Activity points
- 133
getvolumeinformation windows xp
Hi Forum Members,
I have written a following small routine in VisualBasic6:
Purpose:
To read the Volume Serial Number of the HDD (C:\).
Problem:
The above code works well on Windows98, and shows the Volume Serial Number correctly.
If I execute the same code on Windows XP, sometimes it works and sometimes it doesn't. Following are the tested conditions where it works and where it does not work:
Test 1: WindowsXP (Laptop) having OfficeXP, NTFS File System, Logged as Administrator. It works OK.
Test 2: Windows XP (StandAlone Desktop PC), having OfficeXP, FAT32 File System, Logged as User having Administrative rights. It works OK.
Test 3: Windows XP (PC connected to NT Network), having WindowsXP on C Drive, NTFS File System, Logged as user having administrative rights. it does NOT work. the volume serial number is returned as 0.
Please inform me if I am doing any mistake in the coding or testing. :?: My basic intention is to read the Serial Number of the C Drive in all of the Windows Operating Systems.
Thanking you in advance.
With best regards from,
Mr. Kiran V. Sutar.
Hi Forum Members,
I have written a following small routine in VisualBasic6:
Dim strVolumeNameBuffer As String * 11 'Can only be 11 bytes
Dim strFileSystemNameBuffer, strClient As String
Private Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
Private Sub btnExit_Click()
Unload Me
End Sub
Private Sub btnGetVolumeInfo_Click()
Dim itemp1 As Integer
Dim str1 As String
strDrive = Me.txtVolume.Text
strVolumeNameBuffer = Space(11)
strFileSystemNameBuffer = Space(255)
GetVolumeInformation Left(strDrive, 2) & "\", strVolumeNameBuffer, Len(strVolumeNameBuffer), lngVolumeSerialNumber, lngMaximumComponentLength, lngFileSystemFlags, strFileSystemNameBuffer, Len(strFileSystemNameBuffer)
str1 = "Drive : " & strDrive & vbCrLf
str1 = str1 & "VolumeNameBuffer : " & strVolumeNameBuffer & vbCrLf
str1 = str1 & "VolumeSerialNumber : " & Str(lngVolumeSerialNumber) & vbCrLf
str1 = str1 & "VolumeMaximumComponentLength : " & Str(lngMaximumComponentLength) & vbCrLf
str1 = str1 & "VolumeFileSystemFlags : " & Str(lngFileSystemFlags) & vbCrLf
str1 = str1 & "VolumeFileSystemNameBuffer : " & strFileSystemNameBuffer & vbCrLf
str1 = str1 & "VolumeFileSystemNameBufferSize : " & Str(Len(strFileSystemNameBuffer)) & vbCrLf
MsgBox str1
itemp1 = FreeFile()
Open Trim(App.Path & "\VolumeInfo.Txt") For Append Access Write As itemp1
Print #itemp1, str1
Close #itemp1
End Sub
Purpose:
To read the Volume Serial Number of the HDD (C:\).
Problem:
The above code works well on Windows98, and shows the Volume Serial Number correctly.
If I execute the same code on Windows XP, sometimes it works and sometimes it doesn't. Following are the tested conditions where it works and where it does not work:
Test 1: WindowsXP (Laptop) having OfficeXP, NTFS File System, Logged as Administrator. It works OK.
Test 2: Windows XP (StandAlone Desktop PC), having OfficeXP, FAT32 File System, Logged as User having Administrative rights. It works OK.
Test 3: Windows XP (PC connected to NT Network), having WindowsXP on C Drive, NTFS File System, Logged as user having administrative rights. it does NOT work. the volume serial number is returned as 0.
Please inform me if I am doing any mistake in the coding or testing. :?: My basic intention is to read the Serial Number of the C Drive in all of the Windows Operating Systems.
Thanking you in advance.
With best regards from,
Mr. Kiran V. Sutar.