DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: 2 variables pointing to same location

  1. #1
    Join Date
    Nov 2006
    Posts
    2

    2 variables pointing to same location

    Hi All,

    I have a VC# dll, that has a public bool variable. In my VC++ win32 application I am calling functions from this dll.

    I want a variable in my VC++ project and the public variable in VC# to point to the same location ( that is, they have the same address). So that when I assign a value to the public variable in VC#, I can check the value in VC++ !!
    (both the variables are of type bool)

    Can I do something of the sort ??

    I have a public function in the VC# dll, which takes a bool pointer as the parameter passed to it. If I assign the address of my VC++ bool variable to it and in the dll assign the value of the pointer to the public variable in VC#, I still dont get the same values in the VC++ code.

    For instance I call the dll function as
    c->cmdListen_Click(&NewPosition);

    where c is the class declared in the dll and NewPostition is declared as

    bool NewPosition = false;

    The function cmdListen_Click is declared as ..

    public unsafe void cmdListen_Click(bool* NewPositionPointer)

    and I am trying to assign the variables as:

    ReceivedPositionUpdate = *(NewPositionPointer);

    Do these variables have the same address or do I need to do something else?

    Thanks

  2. #2
    Join Date
    Nov 2003
    Posts
    4,118
    I guess it's doable but why not use a simpler technique such as engvironment variables or a file that contains the bool value?
    Danny Kalev

  3. #3
    Join Date
    May 2006
    Posts
    176
    Quote Originally Posted by saaniaferoze
    I have a VC# dll, that has a public bool variable. In my VC++ win32 application I am calling functions from this dll.

    I want a variable in my VC++ project and the public variable in VC# to point to the same location ( that is, they have the same address). So that when I assign a value to the public variable in VC#, I can check the value in VC++ !!
    (both the variables are of type bool)
    [...]
    Maybe you should have a boolean variable in your C# DLL, and access it from C++ using two functions exported from DLL by your code, like GetMyBoolean and SetMyBoolean? In this way you do not need pointers.

    I hope this helps.

  4. #4
    Join Date
    Nov 2006
    Posts
    2
    Thanks, Why didnt I think of it !!

Similar Threads

  1. JDOM Classpath Help Required
    By kpandya in forum Java
    Replies: 5
    Last Post: 01-15-2006, 08:10 PM
  2. JDOM Errors & How to set the classpath
    By kpandya in forum Java
    Replies: 0
    Last Post: 01-14-2006, 08:01 PM
  3. Replies: 0
    Last Post: 05-04-2005, 07:58 PM
  4. Replies: 0
    Last Post: 08-03-2002, 03:19 PM
  5. How to get pointers to variables and file location
    By Benzsoft in forum VB Classic
    Replies: 1
    Last Post: 02-21-2002, 11:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center