Click to See Complete Forum and Search --> : an API declaration problem
abdul
Jul 3rd, 2001, 06:50 PM
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?
Yonatan
Jul 3rd, 2001, 07:15 PM
Change this:
... lpSecurityAttributes As SECURITY_ATTRIBUTES ...
To this:
... ByVal lpSecurityAttributes As Long ...
And when calling the function, just pass zero here. :rolleyes:
DaveAMS
Aug 24th, 2001, 01:35 PM
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)
JoshT
Aug 24th, 2001, 02:17 PM
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)
Megatron
Aug 24th, 2001, 05:18 PM
I think CLng(0) would also have worked.
Yonatan
Aug 25th, 2001, 05:15 AM
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. :rolleyes: Since the API would think that this is actually a SECURITY_ATTRIBUTES pointer, it would fail.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.