Solved

anyone? zip tape?

Posted on 2000-04-11
3
239 Views
Last Modified: 2010-05-02
dear anyone
please pardon my english. can u tell me how to eject zip tape?
0
Comment
Question by:vb6vb6
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
Ruchi earned 400 total points
ID: 2706415
From the web:

Put the following code in the module.

Option Explicit

Private Type Registers
  RegBX As Long
  RegDX As Long
  RegCX As Long
  RegAX As Long
  RegDI As Long
  RegSI As Long
  RegFlags As Long
End Type

Type SECURITY_ATTRIBUTES
        nLength As Long
        lpSecurityDescriptor As Long
        bInheritHandle As Boolean
End Type

Public Const FILE_FLAG_DELETE_ON_CLOSE = &H4000000
Private Const VWin32_DIOC_DOS_IOCTL = 1

Private Declare Function DeviceIoControl Lib "kernel32" (ByVal hDevice As Long, ByVal dwIoControlCode As Long, lpInBuffer As Any, ByVal nInBufferSize As Long, lpOutBuffer As Any, ByVal nOutBufferSize As Long, lpBytesReturned As Long, ByVal lpOverlapped As Long) As Long
Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

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


Place a command button. Put the code in the form.

Private Sub Command1_Click()
  EjectMedia "D:"  'the letter of your zip drive
End Sub


0
 

Author Comment

by:vb6vb6
ID: 2706423
ruchi
u answered fast. thank u a lot.
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2706574
vb6vb6: You're most welcome! I'm glad that I could be of any help to you!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now