Archived

This topic is now archived and is closed to further replies.

VB and C++ sharing memory - possible?

This topic is 6280 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there. Is it possible to set up variables to they can be shared between a VB6 program and C++ DLL''s? I''m not talking about passing parameters to functions. I mean, can I declare global variables and access them from both languages? Having an answer to this would hugely help with some of my problems. Articles and advice are welcome. Thanks.

Share this post


Link to post
Share on other sites
i think so, you can put both functions and variables in dll''s...

Whip open the dll wizard in vc6 and try it out...

hehe
also you coulld just declare a null function, get it with the GetProcAddress() and cast his ass as a pointer to the type you want, you could use it to do whatever you want then Or will it explode if you try to set a value to dll func address?


Declaring dll calls in VB is a big pain, since it doesn''t have pointers and doesn''t support all the C base types quite the same way... and when you make a mistake, BOOM VB closes.

Share this post


Link to post
Share on other sites
Shared Memory is what you''re looking for. I''ve never tried, but I''m going to guess that accessing shared memory in VB is a NIGHTMARE. You might want to try some kind of COM setup, I can guarantee that it''s going to be your simplest route.

Share this post


Link to post
Share on other sites
I'm not too sure abot this, but there are some undocumented things in VB, such as VarPtr, StrPts and ObjPtr, all of these will return the pointer for a variable, string or object respectivlely. Then you could somehow pass the pointer to the dll.

Check out this article, it should help your cause:
http://turbid.chthonic.bc.ca/articles/nitro.html


hth

EDIT: Fixed hyperlink

Trying is the first step towards failure.

Edited by - ragonastick on October 8, 2000 1:27:12 AM

Share this post


Link to post
Share on other sites