Jump to content
Xtreme .Net Talk

bogdandaniel

Members
  • Posts

    11
  • Joined

  • Last visited

Everything posted by bogdandaniel

  1. Can anyone tell me where I can find a ASP.NET Quiz sample (the source code for the Quiz)?
  2. After the last call of deviceIoControl all the array from the class are set to Nothing and the application crash. The intereseting part is that the function return True. Please help me! api.zip
  3. Yes the handle is valid
  4. What is wrong with tis code? The result is always false: Private Const DFP_GET_VERSION As Integer = &H74080 Private Const GENERIC_READ As Integer = &H80000000 Private Const GENERIC_WRITE As Integer = &H40000000 Private Const FILE_SHARE_READ As Short = &H1S Private Const FILE_SHARE_WRITE As Short = &H2S Private Const OPEN_EXISTING As Short = 3 Private Const FILE_ATTRIBUTE_SYSTEM As Short = &H4S Private Const CREATE_NEW As Short = 1 Private Const IOCTL_STORAGE_CHECK_VERIFY2 As Integer = &H2D0800 Private Const FILE_READ_ATTRIBUTES As Integer = &H80 Private Const IOCTL_DISK_GET_DRIVE_GEOMETRY As Integer = &H70000 Private Declare Function DeviceIoControl Lib "kernel32" (ByVal hDevice As Integer, ByVal dwIoControlCode As Integer, ByRef lpInBuffer As IntPtr, ByVal nInBufferSize As Integer, ByRef lpOutBuffer As GETVERSIONOUTPARAMS, ByVal nOutBufferSize As Integer, ByRef lpBytesReturned As Integer, ByVal lpOverlapped As IntPtr) As Integer Structure GETVERSIONOUTPARAMS Dim bVersion As Byte ' Binary driver version. Dim bRevision As Byte ' Binary driver revision. Dim bReserved As Byte ' Not used. Dim bIDEDeviceMap As Byte ' Bit map of IDE devices. Dim fCapabilities As Integer ' Bit mask of driver capabilities. <MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> _ Dim dwReserved() As Integer End Structure Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click Dim hdrive As Integer Dim VersionParams As New GETVERSIONOUTPARAMS() hdrive = CreateFile("\\.\PHYSICALDRIVE0", 0, FILE_SHARE_READ Or FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero) Dim bytesReturned As Integer Dim result As Boolean result = DeviceIoControl(hdrive, DFP_GET_VERSION, IntPtr.Zero, 0, VersionParams, 24, bytesReturned, IntPtr.Zero) CloseHandle(hdrive) MsgBox(result) End Sub
  5. Dim result As Boolean result = result = False What is this? now the result is true!!
  6. IntPtr.Zero is the same with ByVal 0& or IntPtr.Zero is the same with Null from VB 6 ?
  7. This is not physical serial of HDD this is volume serial. This serial change with format. Thanks anyway!
  8. Can anyone tell me how to use DeviceIOControl to obtain a hard disk serial number in VB NET?
  9. Thanks for your reply. This is the code that I used: Private Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" _ (ByVal lpRootPathName As String, _ ByVal lpVolumeNameBuffer As String, _ ByVal nVolumeNameSize As Int32, _ ByRef lpVolumeSerialNumber As System.UInt32, _ ByRef lpMaximumComponentLength As Int32, _ ByRef lpFileSystemFlags As Int32, _ ByVal lpFileSystemNameBuffer As String, _ ByVal nFileSystemNameSize As Int32) As Int32 Dim drvserial As System.UInt32 Dim mydrvlabel As String = Space$(200) Dim myfilesys As String = Space$(200) Dim i As Int32 Dim j As Int32 Dim x As Int32 Dim number As Int32 x = GetVolumeInformation("C:\", mydrvlabel, 200, drvserial, i, j, myfilesys, 200) MsgBox(drvserial.ToString & " - " & mydrvlabel) MsgBox(myfilesys) About WMI I found this http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_logicaldisk.asp
  10. :( How can I use the api GetVolumeInformation in VB.NET to get the hard disk serial number? If I use the same code like in VB 6 the serial is always 0! Please help me Thanks
×
×
  • Create New...