|
-
Jul 3rd, 2001, 06:50 PM
#1
Thread Starter
PowerPoster
an API declaration problem
Wheven I put this API call as private or public:
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
it gives me an error message saying:
User-Defined type not defined
What is rong with that and how do I fix that?
-
Jul 3rd, 2001, 07:15 PM
#2
Guru
Change this:
... lpSecurityAttributes As SECURITY_ATTRIBUTES ...
To this:
... ByVal lpSecurityAttributes As Long ...
And when calling the function, just pass zero here.
-
Aug 24th, 2001, 01:35 PM
#3
Lively Member
Not to be picky, but lpSecurityAttributes really ought to be:
ByVal lpSecurityAttributes As Any
When calling the function, pass Null.
The cases where it matters whether this is a Long set to zero or an Any set to Null are rare, but I've run into cases where a Long zero won't work (especially in win2k)
-
Aug 24th, 2001, 02:17 PM
#4
Black Cat
I had trouble with it on Win2K, to get it to work (it was declared as any), I passed "ByVal 0&". (which probably is the same as Null)
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Aug 24th, 2001, 05:18 PM
#5
I think CLng(0) would also have worked.
-
Aug 25th, 2001, 05:15 AM
#6
Guru
Originally posted by DaveAMS
Not to be picky, but lpSecurityAttributes really ought to be:
ByVal lpSecurityAttributes As Any
When calling the function, pass Null.
No way.. MSDN says that if you don't want this variable, pass NULL.
MSDN's NULL is different from VB's Null.
When you pass NULL in C++, it passes a pointer whose value is equal to zero (a null pointer).
When you pass Null in VB, it passes a pointer to a valid Variant whose vt member is VT_NULL. Since the API would think that this is actually a SECURITY_ATTRIBUTES pointer, it would fail.
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
|