Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I do this in VB.NET

Status
Not open for further replies.

woogoo

Programmer
Feb 14, 2004
247
GB
Hi,

I have a third party API I need to use and in the documentation one of the calls requires a void* to a Data Buffer. However, as the void pointer isn't supported in VB and the addressof operator expects a function what do I use?

I'm well confused on this one, any help would be appreciated.

Thanks.
 
Sorry I don't see the relvance of your post. A void pointer in C/C++ points to the starting address of a variable in memory, which in itself is of indeterminate type.

What I need to do is to pass this routine a buffer to store it's data in, but since VB doesn't support void* I'm looking for the VB equivalent.

Does this make sense?
 
Perhaps you need an update API that accepts the .net and vb equivalent and the NOTHING keyword as Rick has mentioned
 
no, a void pointer in C points to memory address 0x0000000.

VB.Net has a constant (Nothing) that points to 0x0000000.

If you need a pointer on the stack that points to 0x0000000 on the heap, then you should be able to send it an uninstantiated variable.

For example:

Code:
dim objBuffer as object = nothing
Some3rdPartyAPI.DoThing(objBuffer)

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Thanks for your input guys, but there is obviously some confusion as to what A.) A void pointer is and B.) what I actually want to achieve.

Sorry ThatGuyRick but your understanding of a void pointer is wrong. "In C/C++, void represents the absence of type, so void pointers are pointers that point to a value that has no type (and thus also an undetermined length and undetermined dereference properties)" as a said in my previous post.

In my VB app I simply want to pass to this function the location of my buffer so it can then use that information to put its data in it thus making it available to me.

 
Try the following code:

Dim a As IntPtr = IntPtr.Zero
 
"In C/C++, void represents the absence of type, so void pointers are pointers that point to a value that has no type (and thus also an undetermined length and undetermined dereference properties)"
Ahh, sorry, I was thinking of a Null pointer. Closest thing to that would probably be an object. Everything inherits from object, so it can be cast to any type.

Anyways, pass it an instantiated object an see how it goes.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top