CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2008
    Posts
    24

    Getting process arguments

    Hi all,
    I am writing a program in c# and i want to get arguments of an unmanaged .exe file. I am using System.Diagnostics.Process class to start process and i think Process class only allow us to set the arguments of the processes by using Process.StartInfo.Arguments.

    Is it possible to get the arguments of the processes in c#?

    Thanks in advance.

  2. #2
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Getting process arguments

    Quote Originally Posted by izzetbaysal View Post
    Hi all,
    I am writing a program in c# and i want to get arguments of an unmanaged .exe file. I am using System.Diagnostics.Process class to start process and i think Process class only allow us to set the arguments of the processes by using Process.StartInfo.Arguments.

    Is it possible to get the arguments of the processes in c#?

    Thanks in advance.
    I don't understand what you mean. You say that you are starting the process, so how could you not know the arguments? You are creating the StartInfo object with a string, so you know the contents of that string already.

  3. #3
    Join Date
    Mar 2008
    Location
    IRAN
    Posts
    811

    Re: Getting process arguments

    you should look at memory to see with what arguments the process have been started.
    it is not possible to do it with C#.

    look at these sysntaxes in C# and C++ to see in what variables arguments resides.
    blue names are compiler generated and user can change those names.
    Code:
    // C#
    static void Main( string[] args )
    
    // C++
    int main(int argc, char** argv)
    
    // or C++
    int main(int argc, char *argv[])
    Please rate my post if it was helpful for you.
    Java, C#, C++, PHP, ASP.NET
    SQL Server, MySQL
    DirectX
    MATH
    Touraj Ebrahimi
    [toraj_e] [at] [yahoo] [dot] [com]

  4. #4
    Join Date
    Mar 2008
    Posts
    24

    Re: Getting process arguments

    Thanks for the reply but what i am trying to do is getting the argument types of the process and generating inputs automatically. After that i will send those inputs to the .exe file and get the outputs. So exe file can be any file that i don't know which arguments it take as inputs.

    Thanks in advance

  5. #5
    Join Date
    Mar 2008
    Location
    IRAN
    Posts
    811

    Re: Getting process arguments

    Quote Originally Posted by izzetbaysal
    So exe file can be any file that i don't know which arguments it take as inputs.
    you should know what exactly are the arguments than can be accepted by the exe file otherwise the program may have unpredictable behaviour or even not working.
    Please rate my post if it was helpful for you.
    Java, C#, C++, PHP, ASP.NET
    SQL Server, MySQL
    DirectX
    MATH
    Touraj Ebrahimi
    [toraj_e] [at] [yahoo] [dot] [com]

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Getting process arguments

    If you started the process (from your process), then you know what the process arguments are.

    If you didn't start the process, then you are out of luck.

    This is because Windows passes the start up arguments to the application upon startup, but it doesn't save the information. It's up to the application to save that information if necessary.

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