none
How to change another process's public variable in WinForm application RRS feed

  • Question

  • I have to process A and B.

    I want to access a list variable(List<string>) in process B from process A.

    How could I do this?


    • Edited by Jeff0803 Thursday, October 10, 2019 12:56 AM
    Thursday, October 10, 2019 12:55 AM

All replies

  • The receiving process must provide machanisms to receive it. Say Named Pipes, Memory Mapped Files, UdpClients and so on.

    If it's just plain public variable, you have to use debugging API to access it. However since this is very likely to use for malicious purpose I'm not going to talk about it here.

    • Marked as answer by Jeff0803 Thursday, October 10, 2019 6:14 PM
    • Unmarked as answer by Jeff0803 Friday, October 11, 2019 1:37 PM
    Thursday, October 10, 2019 1:39 AM
    Answerer
  • Just as a followup, this is not a normal thing to do.  Your process A has no easy way to figure out where the variables are in process B.  You need to think about your problem in a different way.  Cheong00 is right; you need to investigate interprocess communication schemes like names pipes and TCP or UDP sockets.

    Tim Roberts | Driver MVP Emeritus | Providenza &amp; Boekelheide, Inc.

    • Marked as answer by Jeff0803 Thursday, October 10, 2019 6:14 PM
    • Unmarked as answer by Jeff0803 Friday, October 11, 2019 1:37 PM
    Thursday, October 10, 2019 6:16 AM
  • I think I need inter process communication and it'll be proper to make a function to handle the list in Process A.

    And I need to notify to the Process A from Process B in order to have handle the list in Process A.

    There's no parameter from Process B to Process A.

    In this case, which way is the best way to simple notification between process in the inter process communication?


    • Edited by Jeff0803 Friday, October 11, 2019 1:39 PM
    Thursday, October 10, 2019 6:14 PM
  • Hi Jeff0803, 

    Thank you for posting here.

    For more information about IPC, you can refer to advices in the following references.

    What is the simplest method of inter-process communication between 2 C# processes?

    how to pass value between two process (.net c# exe)

    Hope them can help you.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, October 15, 2019 9:24 AM
    Moderator
  • We already told you that.  A TCP or UDP socket is not hard, and named pipes are not hard.   You can even use the WM_COPYDATA message, although that's a bit tedious in C#.

    Tim Roberts | Driver MVP Emeritus | Providenza &amp; Boekelheide, Inc.

    Tuesday, October 15, 2019 5:38 PM