Tom Anderson
November 7th, 1999, 12:52 PM
Trying to use API GetTapeStatus to determine if tape is inserted in tape drive. Must use CreateFile to get handle to the device (Tape0). All examples are C++. How do you use this API from VB6?
|
Click to See Complete Forum and Search --> : How do you use CreateFile? Tom Anderson November 7th, 1999, 12:52 PM Trying to use API GetTapeStatus to determine if tape is inserted in tape drive. Must use CreateFile to get handle to the device (Tape0). All examples are C++. How do you use this API from VB6? Lothar Haensler November 8th, 1999, 01:28 AM try this: option Explicit private 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 private Const OPEN_EXISTING = 3 private Type SECURITY_ATTRIBUTES nLength as Long lpSecurityDescriptor as Long bInheritHandle as Long End Type private Const GENERIC_READ = &H80000000 private Const INVALID_HANDLE_VALUE = -1 private Declare Function CloseHandle Lib "kernel32" (byval hObject as Long) as Long private Sub Command1_Click() Dim lResult as Long Dim sa as SECURITY_ATTRIBUTES sa.nLength = len(sa) lResult = CreateFile("c:\test.txt", _ GENERIC_READ, 0, sa, OPEN_EXISTING, 0&, 0&) If lResult = INVALID_HANDLE_VALUE then MsgBox "cannot open" else Call CloseHandle(lResult) End If End Sub it doesn't take tape drives into account, as I don't have access to one, but it shows you the APIs and it has been tested in VB 6, NT 4 codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |