|
Posted by Peter Foot [MVP] on August 25, 2008, 12:34 am
Please log in for more thread options
P/Invoking GetModuleFileName allows you to get the full path of the launched
executable:-
http://mobileworld.appamundi.com/blogs/peterfoot/archive/2008/08/24/get-the-name-of-executing-exe.aspx
Peter
--
Peter Foot
Microsoft Device Application Development MVP
peterfoot.net | appamundi.com | inthehand.com
APPA Mundi Ltd - software solutions for a mobile world
In The Hand Ltd - .NET Components for Mobility
> Hello - I'm trying to make my program reference a data file installed
> along with the binary in the program directory (let's say \Program
> Files\MYPROG\). Within a program, in order to find out the program
> installation directory, I'm using the directory component of
> Assembly.GetExecutingAssembly().GetName().CodeBase
>
> Unfortunately, this only works when the program was started from that
> directory. If the program was started from a shortcut on a Start Menu,
> this property returns "\Windows\Start Menu\" which is obviously not
> what I want.
>
> So the question is, what is the right way (in .NET CF) to retrieve the
> program installation directory (apart from hardcoding it).I suspect
> that in the absence of a true API, one could make the setup script
> create a registry key and place this directory in it, but I'm not sure
> how to do it portably. I would very much appreciate any suggestions.
>
> Regards,
> -- Alexander
|