Cyber22

how can I change the default application for opening .txt to be a application I created instead of IE - in smartphone ed

Re: Smart Devices General default application for .txt

Christopher Fairbairn

Hi,

These file associations are made via registry settings. Whenever the shell is asked to open a file it looks up the registry for a file association in order to find the correct application to launch. So you will need to modify these registry settings to launch your desired application.

In this particular case if you use a regsitry editor (or include the settings within a setup CAB etc) you should be able to change the default value located within HKEY_CLASSES_ROOT\txtfile\Shell\Open\Command to specify your desired application. Currently this will have the value "iexplore.exe file:%1", where %1 is replaced by the shell with the filename.

This functionality is a cut down version of that supported by desktop windows. You can find further details in the Shell documentation on MSDN, for example the following page http://msdn2.microsoft.com/en-us/library/aa969385.aspx.

Hope this helps,

Christopher Fairbairn






Re: Smart Devices General default application for .txt

Cyber22

yep, this is exactly what I was looking for...

so... if I want to run "<applicationName> %1", %1 representing the file name, should I create a extra contructor with parametres in my main form of my project or how can I get the argument in my code





Re: Smart Devices General default application for .txt

Christopher Fairbairn

Hi,

Cyber22 wrote:

so... if I want to run " %1", %1 representing the file name, should I create a extra contructor with parametres in my main form of my project or how can I get the argument in my code

This will depend upon your programming environment. If you are developing for the Compact Framework (C# or VB.NET), you will need to modify the declaration of your Main method.

Within program.cs (assumming your project is C#) you should find a method called main. You need to modify this to look like the following:

Code Snippet
static
void Main(string[] args)

The args (short for arguments) parameter will then contain any parameters passed to your application, hence args[0] will be the filename of the document to open, if you run the application via a command line such as:

Code Snippet
myApp.exe \path\to\filename.txt

Which is what will occur if you setup the registry key to be

Code Snippet
myApp.exe %1

Note: It would be wise in most cases to enclose the %1 in quote marks, i.e. use something like:

Code Snippet
myApp "%1"

The reason is this will cause the command line parser to keep arguments which contain spaces as one argument. Otherwise you will find that files which are contained within directories which have spaces in their file name will not work.

If you are using native code (C or C++ etc) the answer on how to get command line arguments from within your application will depend a little upon your framework.

Hope this helps,

Christopher Fairbairn






Re: Smart Devices General default application for .txt

Cyber22

just like in Java.. I should have thought about that..

thanks a lot Christopher Wink





Re: Smart Devices General default application for .txt

Cyber22

does %1 keep in entire filename (path also or just file name )



Re: Smart Devices General default application for .txt

Christopher Fairbairn

Hi,

Cyber22 wrote:
does %1 keep in entire filename (path also or just file name )

%1 should be the entire filename including path. Windows CE (which Windows Mobile is based around) has no concept of a current working directory so in most cases filenames need to be fully qualified with a path starting at the root folder which is \

Hope this helps,

Christopher Fairbairn.