Executable name

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aryeh Katz

    #1

    Executable name

    How can I determine the full name of a c# executable, like the c
    GetModuleFileNa me?
    Thanks.
    Aryeh

  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Executable name

    Aryeh,

    On the Assembly class, there is a Location property you can use to get
    the location of the assembly. Now, to get the assembly to get the property
    of, you can use the static GetExecutingAss embly, which will give you the
    assembly of the code that called it, or you can use the static
    GetEntryAssembl y method, which will return the assembly that is the entry
    point. For most applications, this assembly is the executable which was
    launched.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Aryeh Katz" <ank@secure-services.com> wrote in message
    news:OfG4QxDtDH A.540@tk2msftng p13.phx.gbl...[color=blue]
    > How can I determine the full name of a c# executable, like the c
    > GetModuleFileNa me?
    > Thanks.
    > Aryeh
    >[/color]


    Comment

    • Aryeh Katz

      #3
      Re: Executable name

      Nicholas Paldino [.NET/C# MVP] wrote:
      [color=blue]
      > Aryeh,
      >
      > On the Assembly class, there is a Location property you can use to get
      > the location of the assembly. Now, to get the assembly to get the property
      > of, you can use the static GetExecutingAss embly, which will give you the
      > assembly of the code that called it, or you can use the static
      > GetEntryAssembl y method, which will return the assembly that is the entry
      > point. For most applications, this assembly is the executable which was
      > launched.
      >[/color]
      Thanks, this is exactly what I need.
      Out of curiousity, do you happen to know if the performance is better for
      GetExectuingAss embly().Locatio n or
      using PInvoke on GetModuleFileNa me ?
      Aryeh

      Comment

      • Nicholas Paldino [.NET/C# MVP]

        #4
        Re: Executable name

        Aryeh,

        I don't think that GetModuleFileNa me will give you the results that you
        want. That is for DLLs that are native code, not necessarily managed code.


        --
        - Nicholas Paldino [.NET/C# MVP]
        - mvp@spam.guard. caspershouse.co m

        "Aryeh Katz" <ank@secure-services.com> wrote in message
        news:OecUa7EtDH A.2400@tk2msftn gp13.phx.gbl...[color=blue]
        > Nicholas Paldino [.NET/C# MVP] wrote:
        >[color=green]
        > > Aryeh,
        > >
        > > On the Assembly class, there is a Location property you can use to[/color][/color]
        get[color=blue][color=green]
        > > the location of the assembly. Now, to get the assembly to get the[/color][/color]
        property[color=blue][color=green]
        > > of, you can use the static GetExecutingAss embly, which will give you the
        > > assembly of the code that called it, or you can use the static
        > > GetEntryAssembl y method, which will return the assembly that is the[/color][/color]
        entry[color=blue][color=green]
        > > point. For most applications, this assembly is the executable which was
        > > launched.
        > >[/color]
        > Thanks, this is exactly what I need.
        > Out of curiousity, do you happen to know if the performance is better for
        > GetExectuingAss embly().Locatio n or
        > using PInvoke on GetModuleFileNa me ?
        > Aryeh
        >[/color]


        Comment

        • Aryeh Katz

          #5
          Re: Executable name

          Nicholas Paldino [.NET/C# MVP] wrote:
          [color=blue]
          > Aryeh,
          >
          > I don't think that GetModuleFileNa me will give you the results that you
          > want. That is for DLLs that are native code, not necessarily managed code.
          >
          >[/color]
          I guess what you're saying makes sense.
          Thanks.
          Aryeh

          Comment

          Working...