Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleEject a ZIP tape
Keywordszip, eject zip, eject tape
CategoriesWindows
 
Use the DeviceIoControl API function.

Note: I don't have a ZIP drive so I haven't tried this.

Thanks to Voronwë who dug up this code at the VISBAS-L archives.

The code is mostly courtesy of Fred Vagner.

 
Public Sub EjectMedia(Drive As String)
Dim SecAttr As SECURITY_ATTRIBUTES
Dim ErrorResult
Dim hDevice As Long, Regs As Registers, RB As Long

  hDevice = CreateFile("\\.\vwin32", 0, 0, SecAttr, 0, _
      FILE_FLAG_DELETE_ON_CLOSE, 0)
  If hDevice = -1 Then
    ErrorResult = -1
    Exit Sub
  End If
  With Regs
    .RegAX = &H220D
    .RegBX = Asc(Left(Drive, 1)) - 64
    .RegCX = &H849
  End With
  ErrorResult = DeviceIoControl(hDevice, _
      VWin32_DIOC_DOS_IOCTL, Regs, Len(Regs), Regs, _
      Len(Regs), RB, 0)
  ErrorResult = CloseHandle(hDevice)
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated