|
-
November 7th, 1999, 01:52 PM
#1
How do you use CreateFile?
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?
-
November 8th, 1999, 02:28 AM
#2
Re: How do you use CreateFile?
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|