Results 1 to 7 of 7

Thread: Passing objects between programs...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    258

    Passing objects between programs...

    I would like to be able to shell a program from a program, but be able to pass my objects over to it. Is there anyway to do this reliably? Both programs are written in VB6, if that helps. It may be possible that I need to END the first program, which is why I want to pass the objects over to the second program. TIA.

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Passing objects between programs...

    Theres 2 ways that come to mind when doing this.

    Option 1): Completely duplicate the object in app2 as in app1 (whether it be a class object, or a commandbutton)

    Option 2): Allocate memory in app2, then in app1, use CopyMemory to copy the object into the memory app2 has set aside (well, used up). Then use CopyMemory in app2 to move the memory into an Object Variable (or a class).

    Using CopyMemory would require alot of reading up on to do it properly, and I'm not that qualified to give a good example of CopyMemory (although in ASM I could give an example).

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    258

    Re: Passing objects between programs...

    I'm sure there is ALOT to be careful with when using that copymem function. Will it be able to assign the correct data to the correct objects? I think the data will be class objects, ultimately.

  4. #4
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Passing objects between programs...

    can't you do this with an ActiveX dll?

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    258

    Re: Passing objects between programs...

    I have made but 1 dll before, so I am incredibly new to that aspect of programming. I thought no matter what you do, you need to pass something to the DLL in order for it to work with the data. I made a collection with an instance of a class inside it, but in order to do a Exists() function, I could only pass the information to the dll. Is this what you are talking about?

  6. #6
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Passing objects between programs...

    Quote Originally Posted by tacoman667
    I'm sure there is ALOT to be careful with when using that copymem function. Will it be able to assign the correct data to the correct objects? I think the data will be class objects, ultimately.
    Could you not just create the same class in both applications, and save the classes data to a file and load it again? You could experiment with things like AddressOf and make a CallBack function which app1 calls and app2 executes. I've tried it before, and sorta got it working. If you try using SetWindowLong with the GWL_WNDPROC or GWL_HINSTANCE flags and run app2 before app1, then make app1 send the SetWindowLong, app2 executes a function. Meh, I'll see if I have it in my backups.

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  7. #7
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Passing objects between programs...

    Check out this thread for info on creating ActiveX dlls
    http://www.vbforums.com/showthread.php?t=341860

    What I am suggesting is to put all the classes you want to share between programs into the dll. Then both programs can access them.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width