Results 1 to 12 of 12

Thread: Call a make my application run a sub routine, from another application?

  1. #1

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065

    Call a make my application run a sub routine, from another application?

    hey guys,

    how can i make my application run a sub routine, from another external application?

    Explaination:

    Say i have two EXE's

    1) MainApp.exe
    2) Settings.exe

    When / If I change & save any settings in Settings.exe, how can i make MainApp.exe re-call a sub (IE: LoadSettings()) to get the new settings from an ini file?

    is it possible?


    Thanks guys.
    Wayne
    Wayne

  2. #2

  3. #3

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    Originally posted by MartinLiss
    No.
    K, Tnx
    Wayne

  4. #4
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Okinawa, Japan
    Posts
    271

    Actually

    This is possible, provided you have the source code of both apps in VB.

  5. #5
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    This is possible.
    You simply need the Address of the sub routing in the other application.
    You can use AddressOf to get the memory location of the sub or function, and then you could use the CallWindowLong() API to call that function.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  6. #6
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148
    CallWindowLong is an in-process call. You can't call an address of another application this way, I'm afraid, because it will look for the address in the current process (insert weird analogy of streets and addresses here...).

    You can, however, get Windows to execute code in another application by sending the main window of that application a WM_TIMER message with lParam pointing to the address you want to run.

    Alternatively, if you have the source code for both applications you can implement Inter process communication using registered messages from Visual Basic...

  7. #7
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Okinawa, Japan
    Posts
    271
    Another way i think would work is if both apps are in VB, you can make one or both with exports and call with normal API.

    Just edited, wont work, app crashes without error message.
    Last edited by packetVB; May 13th, 2003 at 07:23 AM.

  8. #8
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    You sure CallWindowLong is in-process ?
    Bugger. Never knew that.

    I wonder if it will work inside process-trees...?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  9. #9
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Brilliant article on interprocess comms btw!!
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  10. #10
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148
    You sure CallWindowLong is in-process ?
    It'd probably work cross-process in Windows 95-Me. Most stuff does...which is why those OSes have stability and security issues

  11. #11
    Fanatic Member alexandros's Avatar
    Join Date
    Oct 2002
    Location
    Milky Way Galaxy
    Posts
    694
    why don't you just make a dll and then call the sub from the dll.

  12. #12

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    Originally posted by Merrion
    CallWindowLong is an in-process call. You can't call an address of another application this way, I'm afraid, because it will look for the address in the current process (insert weird analogy of streets and addresses here...).

    You can, however, get Windows to execute code in another application by sending the main window of that application a WM_TIMER message with lParam pointing to the address you want to run.

    Alternatively, if you have the source code for both applications you can implement Inter process communication using registered messages from Visual Basic...
    thanks, i will look into this later on

    I think its just what i need (not had a proper look yet though)


    why don't you just make a dll and then call the sub from the dll.
    i dont want both of the apps to be able to run the sub,

    I want to force the external app to run the sub
    Wayne

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