|
-
August 12th, 1999, 03:04 PM
#1
Array Addresses
I'm trying to use the MsgWaitForMultipleObjects function, and one of the arguments is a pointer to an array of handles. So, I've got my array of Longs and use VarPtr on the 0th element to pass it as a pointer. However, the function only recognizes this as a pointer if the array has only one element (I use GetLastError and get error code 6). Are VB pointers structured differently than C++ pointers? Does anyone know of a work-around for this?
-
August 13th, 1999, 04:12 AM
#2
Re: Array Addresses
VB doesn't have pointers like in C, although there are some undocumented functions yo get a pointer. If I remember it well, I saw a while ago another API, which wants an array too as one of it's arguments. I saw inthe example code that they change it in the declaration from Byval Blah as long to Blah() as long, or something like that (sorry it was a loooong time ago I saw it...)
Maybe you can try that, and see if that works.
Crazy D :-)
-
August 13th, 1999, 02:25 PM
#3
Re: Array Addresses
Yeah, you can pass pointers to API's in vb by preceding the variable with VarPtr. It's pretty much undocumented in MS, but will return the address (long type) of pretty much any type of variable, including user-defined types (supposedly). However, in my case, it just doesn't seem to work well enough for arrays. Thanks for the suggestion, though. I'll try it.
-
August 14th, 1999, 10:02 AM
#4
Re: Array Addresses
Passing a pointer to an array is simple, just pass the first item in the array ByRef to the procedure. All you have to be careful of is that the array is sized large enough to handle what will be written in to it by the procedure being called, assuming something will be written into it of course. If not things get a little nutty.
You don't have to mess with VarPtr..
You can also pass any item in the array and it will be assumed that it is the "start" of the array.
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
|