CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2012
    Posts
    1

    Access a running process

    Hello,
    I am running an application P1 through which i am calling process P2 like

    Process.start(P2)

    I want to access some public variable of P1 from P2

    there are 2 hurdles here:
    firstly, i have to suspend P1 until P2 completes
    secondly, i should make sure that P2 does not create a new instance of P1.

    Any expert in c# can guide me through this?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Access a running process

    Well, multithreading is not the same as multiprocessing.
    You cannot directly access "some public variable" of one process from another process. You have to implement some type of IPC (Interprocess Communications) between them.
    I'm not a expert in C#, so may be wrong, but look at these .NET functions.
    Victor Nijegorodov

  3. #3
    Join Date
    May 2012
    Location
    Bonn, Germany
    Posts
    43

    Re: Access a running process

    Does the process P2 "belong" to you?
    Do you have access to its source code?
    If yes, then it's easy to implement some kind of IPC.
    If not, then you could still get access to P2's memory address space using WinAPI, this is what typical game hacks do.

    ________________________________
    Visit my project: Derivative Calculator

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: Access a running process

    I want to access some public variable of P1 from P2
    Please define "public." What publishing mechanism is implied here?

    firstly, i have to suspend P1 until P2 completes
    Suspending process isn't anything trivial, and there's no standard mechanism for this I'm aware of.

    I want to access some public variable of P1 from P2
    . . .
    secondly, i should make sure that P2 does not create a new instance of P1.
    I believe that's something wrong with the explanation. From "I want to access" I get that P2 is all yours. So to make sure P2 does not create something you should not create that something.
    Best regards,
    Igor

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

Featured