newbie: Getting Program Files folder in Windows Mobile 6.0

  • Thread starter Thread starter Bjørn Brox
  • Start date Start date
B

Bjørn Brox

Hi!

Can anyonecome with some C# program example on how to get the path of
the "Program Files" folder on a windows mobile unit (//Program Files" in
an english version of WM 6)

I need to know if a specific executable is installed on the unit, and
start it when needed.

I know about the following statement:

String path =
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);

but it just return the "Program" folder in the Start Menu, i.e. name
where the startup links is present, not the real path where the exe is
present.
 
Hi,


You should post this question into the Compact framework NG (crossposting
there now)
 
Generally, you'd use SHGetSpecialFolderPath(). I'm not aware of a
generally-available (all versions of Windows Mobile), method of getting that
without P/Invoking it.

BOOL SHGetSpecialFolderPath(
HWND hwndOwner,
LPTSTR lpszPath,
int nFolder,
BOOL fCreate
);

SHGetSpecialFolderPath( hwnd, pathstring, CSIDL_PROGRAM_FILES /* 0x26 */,
FALSE ) would get the path that you're interested in.

Paul T.
 
Paul G. Tobey [eMVP] skrev:
Generally, you'd use SHGetSpecialFolderPath(). I'm not aware of a
generally-available (all versions of Windows Mobile), method of getting that
without P/Invoking it.

BOOL SHGetSpecialFolderPath(
HWND hwndOwner,
LPTSTR lpszPath,
int nFolder,
BOOL fCreate
);

SHGetSpecialFolderPath( hwnd, pathstring, CSIDL_PROGRAM_FILES /* 0x26 */,
FALSE ) would get the path that you're interested in.

Thanks, it worked.
The returned value from this was as expected: "\\Program Files"

Any reason that the
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)
wrapper returns "\\Windows\\Start Menu\\Programs"?

....
 
I'm sure there must be, but I certainly don't know what it is! What version
of .NET CF does it do that in? Maybe it was fixed in a later version or
service pack.

Paul T.

Bjørn Brox said:
Paul G. Tobey [eMVP] skrev:
Generally, you'd use SHGetSpecialFolderPath(). I'm not aware of a
generally-available (all versions of Windows Mobile), method of getting
that without P/Invoking it.

BOOL SHGetSpecialFolderPath(
HWND hwndOwner,
LPTSTR lpszPath,
int nFolder,
BOOL fCreate
);

SHGetSpecialFolderPath( hwnd, pathstring, CSIDL_PROGRAM_FILES /* 0x26 */,
FALSE ) would get the path that you're interested in.

Thanks, it worked.
The returned value from this was as expected: "\\Program Files"

Any reason that the
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) wrapper
returns "\\Windows\\Start Menu\\Programs"?

...
 
Paul G. Tobey [eMVP] skrev:
I'm sure there must be, but I certainly don't know what it is! What version
of .NET CF does it do that in? Maybe it was fixed in a later version or
service pack.
I am using CF 3.5

Anyhow, both "\\Program Files" and "\\Windows\\Start Menu\\Programs" are
in my opinion both special folders that should be covered by the
Environment.SpecialFolder enum.

Bjørn Brox said:
Paul G. Tobey [eMVP] skrev:
Generally, you'd use SHGetSpecialFolderPath(). I'm not aware of a
generally-available (all versions of Windows Mobile), method of getting
that without P/Invoking it.

BOOL SHGetSpecialFolderPath(
HWND hwndOwner,
LPTSTR lpszPath,
int nFolder,
BOOL fCreate
);

SHGetSpecialFolderPath( hwnd, pathstring, CSIDL_PROGRAM_FILES /* 0x26 */,
FALSE ) would get the path that you're interested in.
Thanks, it worked.
The returned value from this was as expected: "\\Program Files"

Any reason that the
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) wrapper
returns "\\Windows\\Start Menu\\Programs"?

...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top