DeviceIOControl Does Not Work on Windows 98

i wrote a program that get hard disk's firmware serial and it works fine in winXP/Win2000

but when i run it in win98 it doesn't give me the serial number

i used Smartvsd.vxd and vWin32.vxd to Solve this problem but it doesn't work yet.

any idea

plz forgive me for my bad english .

 



Answer this question

DeviceIOControl Does Not Work on Windows 98

  • raedbenz

    How are you calling DeviceIOControl.

    How is your call to DeviceIOControl related to Smartvsd.vxd and vWin32.vxd



  • derrickcui

    (a little off-topic, but: http://news.bbc.co.uk/1/hi/5164450.stm)

  • Rush hour

    thank you very much .

    it return hFile a number that isn't equal -1 .

    but next problem is that , how to use DeviceIOControl

    i used this two ways , but both of them doesn't work:

    first way:

    DeviceIoControl(hFile, VWIN32_DIOC_DOS_IOCTL, sci, Marshal.SizeOf(sci), sco, Marshal.SizeOf(sco), lReturnSize, 0)

    second way:

    DeviceIoControl(hFile, DFP_RECEIVE_DRIVE_DATA, sci, Marshal.SizeOf(sci), sco, Marshal.SizeOf(sco), lReturnSize, 0)


  • oolon

    i changed the code but it doesn't work.

    •  Have you verified that the drive support SMART IDE commands

    i think it doesn't support SMART IDE commands.

    and can you explain some more  

    • is the call to DeviceIOControl returning a non-zero value if not, what's the error code reported by GetLastError

    it return 1 .

     

     


  • JGP

    From his test.zip:

    Private Declare Function CreateFile _
    Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, _
    ByVal dwDesiredAccess As Integer, _
    ByVal dwShareMode As Integer, _
    ByVal lpSecurityAttributes As Integer, _
    ByVal dwCreationDisposition As Integer, _
    ByVal dwFlagsAndAttributes As Integer, _
    ByVal hTemplateFile As Integer) As Integer



  • koosha

    I don't know much about low level disk access structures, so I can't verify whether the interop layouts match or not. However, I did notice that some other samples compute the DriveHeadReg differently:

    sci.irDriveRegs.bDriveHeadReg = CByte(&HA0 Or ((lDriveNumber And 1) << 4))

    Can you try this instead If your lDriveNumber value is neither 0 nor 1, that could be the problem.

    Here are some more suggestions to verify:

    • Have you verified that the drive support SMART IDE commands
    • Is the call to DeviceIOControl returning a non-zero value If not, what's the error code reported by GetLastError

    Hope this helps,



  • imj

    Can you post the interop declaration for CreateFile Depending on which version you call(ASCII or UNICODE), you might need to explicitly state the marshalling for the string parameter.

    Best regards,



  • MagedSalah

    I would say don't bother: if they haven't upgraded from windows 98, they are unlikely to spend any money to buy a new program. I know that doesn't help, but perhaps you are pending too much of your time worrying about a few users who are really going to be a pain in the neck for you. Hopefully your time is more valuable than that. As a programmer you have to know when it's worth while to fix a 'bug' and when to let it go (not all bugs are worth fixing).



  • David Gardiner

    i know that and i copied smartvsd.vxd in %windows%\system\iosubsys folder and vWin32.vxd in system\Vmm32\ in win98.

    but it doesn't work yet.

    i want to know , how can i install this files


  • SachinSurana

    dear, i know that .

    but i'm a programmer and i write program, i don't know which Windows people use and i must test it in Difrrent version of windows and fix Bugs.


  • michael412

    smartvsd may not be installed in all versions of Windows. http://vbnet.mvps.org/index.html code/disk/smartide.htm seems to outline a workaround for these circumstances.

  • R.Tutus

    I guess I should have started by asking whether the call to CreateFile succeeds in Win98. If it does, then I was looking in the wrong place, but if it doesn't then there's some hope with tweaking around with the interop declaration.

    Anyway, can you try changing the signature for the string parameter to be (this will make sure that it matches the Win32 API

    <MarshalAs(UnmanagedType.LPTStr)>ByVal lpFileName As String

    Note that if you intend to use this call in 64 bit OS, it would require further tweaking.

    Hope this helps,



  • jaomello

    first i use CreateFile

    If Environment.OSVersion.Platform = PlatformID.Win32NT Then

    'in windows XP/2000

    hFile = CreateFile("\\.\PhysicalDrive" & CStr(lDriveNumber), GENERIC_READ Or GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0)

    ElseIf Environment.OSVersion.Platform = PlatformID.Win32Windows Then ' 9X

    ' in win98

    hFile = CreateFile("\\\\.\\vwin32", GENERIC_READ, FILE_SHARE_READ Or FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)

    'hFile = CreateFile("\\.\Smartvsd", 0, 0, 0, CREATE_NEW, 0, 0)

    End If

    i use DeviceIOControl like code below:

    If hFile <> INVALID_HANDLE_VALUE Then

    sci.bDriveNumber = CType(lDriveNumber, Byte)

    sci.cBufferSize = Marshal.SizeOf(sco)

    sci.irDriveRegs.bDriveHeadReg = CType(&HA0 Or (lDriveNumber << 4), Byte)

    sci.irDriveRegs.bCommandReg = &HEC

    sci.irDriveRegs.bSectorCountReg = 1

    sci.irDriveRegs.bSectorNumberReg = 1

    If DeviceIoControl(hFile, DFP_RECEIVE_DRIVE_DATA, sci, Marshal.SizeOf(sci), sco, Marshal.SizeOf(sco), lReturnSize, 0) <> 0 Then

    sSerial = SwapChars(sco.ids.sSerialNumber)

    sModel = SwapChars(sco.ids.sModelNumber)

    sFirmware = SwapChars(sco.ids.sFirmwareRev)

    GetHDData = True

    End If

    i'm waiting your help


  • Jain1122

    there's my program source code:

    http://www.meandyouwith2003.persiangig.com/VB2005/Test.zip

    thanks for your helps.


  • DeviceIOControl Does Not Work on Windows 98