473,513 Members | 2,263 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

executing program by clicking on an associated file (ext)

Good Day Group,

I'm trying to make my application open and run some code when a user clicks
on a file with an associated extension. This is *my* understanding of what
actually happens, please correct me if I am wrong. I've searched the net,
but there doesn't seem to be much on the subject.

1) When using the DotNetPackager (called dotfuscator I believe), we can
associate files with a specific extension to a specific program. Basically
just a registry key being written. Perhaps there is a way to check this
through code and actualy write to the registry if there was a mistake?

2) when a user clicks on an associated file, its like a command line
argument i.e.: "myApp.exe" "c:\myPath\myFile.aaa".

3)In order to use the file, the Main() must accept Args. ie"static void
Main(string[] Args) at which point I can access the filename by accessing
the Args[0] of the Main and store it in a variable in my program.

Please let me know if there's anything else I should know about, or if my
understanding is erroneous.

Thanks and best regards,

Marco
Nov 15 '05 #1
3 1586

"Marco Martin" <ma**********@sympatico.ca.antispam> schreef in bericht
news:%W********************@news20.bellglobal.com. ..
Good Day Group,

I'm trying to make my application open and run some code when a user clicks on a file with an associated extension. This is *my* understanding of what actually happens, please correct me if I am wrong. I've searched the net,
but there doesn't seem to be much on the subject.
Google returns plenty of hits. Just use " fileassociation "c#" "

1) When using the DotNetPackager (called dotfuscator I believe), we can
associate files with a specific extension to a specific program. Basically just a registry key being written. Perhaps there is a way to check this
through code and actualy write to the registry if there was a mistake?
Check http://www.mentalis.org/soft/class.qpx?id=5 It contains both a C# and
VB.Net version with examples.
2) when a user clicks on an associated file, its like a command line
argument i.e.: "myApp.exe" "c:\myPath\myFile.aaa".
yes
3)In order to use the file, the Main() must accept Args. ie"static void
Main(string[] Args) at which point I can access the filename by accessing
the Args[0] of the Main and store it in a variable in my program.
No, you still need to use Main() without arguments but then use
Environment.CommandLine to get the commandline data.
Please let me know if there's anything else I should know about, or if my
understanding is erroneous.

Thanks and best regards,

Marco


Yves
Nov 15 '05 #2
Thanks Yves,

I managed to get file name by using the code below(it works...) Thanks for
the link on associating extentions, its exacly what I needed.

regards,

Marco

static void Main(string[] Args)
{
string strInputFile = null;
if(Args.length == 1)
{
strInputFile = Args[0];
}
Application.Run(new Form1(strInputFile);
}

public Form1(String strInputFile)
{
initializeComponent();
strLocalVar = strInputFile;
}

private void Form1_Load(object sender, System.EventArgs e)
{
//do stuff
if(strLocalVar != null)
{
//Do file stuff
}
}
"phoenix" <pa******@skynetWORK.be> wrote in message
news:er**************@TK2MSFTNGP09.phx.gbl...

"Marco Martin" <ma**********@sympatico.ca.antispam> schreef in bericht
news:%W********************@news20.bellglobal.com. ..
Good Day Group,

I'm trying to make my application open and run some code when a user clicks
on a file with an associated extension. This is *my* understanding of

what
actually happens, please correct me if I am wrong. I've searched the net, but there doesn't seem to be much on the subject.


Google returns plenty of hits. Just use " fileassociation "c#"

"

1) When using the DotNetPackager (called dotfuscator I believe), we can
associate files with a specific extension to a specific program. Basically
just a registry key being written. Perhaps there is a way to check this
through code and actualy write to the registry if there was a mistake?


Check http://www.mentalis.org/soft/class.qpx?id=5 It contains both a C#

and VB.Net version with examples.
2) when a user clicks on an associated file, its like a command line
argument i.e.: "myApp.exe" "c:\myPath\myFile.aaa".


yes
3)In order to use the file, the Main() must accept Args. ie"static void
Main(string[] Args) at which point I can access the filename by accessing the Args[0] of the Main and store it in a variable in my program.


No, you still need to use Main() without arguments but then use
Environment.CommandLine to get the commandline data.
Please let me know if there's anything else I should know about, or if my understanding is erroneous.

Thanks and best regards,

Marco


Yves

Nov 15 '05 #3
Thanks Yves,

I managed to get file name by using the code below(it works...) Thanks for
the link on associating extentions, its exacly what I needed.

regards,

Marco

static void Main(string[] Args)
{
string strInputFile = null;
if(Args.length == 1)
{
strInputFile = Args[0];
}
Application.Run(new Form1(strInputFile);
}

public Form1(String strInputFile)
{
initializeComponent();
strLocalVar = strInputFile;
}

private void Form1_Load(object sender, System.EventArgs e)
{
//do stuff
if(strLocalVar != null)
{
//Do file stuff
}
}
"phoenix" <pa******@skynetWORK.be> wrote in message
news:er**************@TK2MSFTNGP09.phx.gbl...

"Marco Martin" <ma**********@sympatico.ca.antispam> schreef in bericht
news:%W********************@news20.bellglobal.com. ..
Good Day Group,

I'm trying to make my application open and run some code when a user clicks
on a file with an associated extension. This is *my* understanding of

what
actually happens, please correct me if I am wrong. I've searched the net, but there doesn't seem to be much on the subject.


Google returns plenty of hits. Just use " fileassociation "c#"

"

1) When using the DotNetPackager (called dotfuscator I believe), we can
associate files with a specific extension to a specific program. Basically
just a registry key being written. Perhaps there is a way to check this
through code and actualy write to the registry if there was a mistake?


Check http://www.mentalis.org/soft/class.qpx?id=5 It contains both a C#

and VB.Net version with examples.
2) when a user clicks on an associated file, its like a command line
argument i.e.: "myApp.exe" "c:\myPath\myFile.aaa".


yes
3)In order to use the file, the Main() must accept Args. ie"static void
Main(string[] Args) at which point I can access the filename by accessing the Args[0] of the Main and store it in a variable in my program.


No, you still need to use Main() without arguments but then use
Environment.CommandLine to get the commandline data.
Please let me know if there's anything else I should know about, or if my understanding is erroneous.

Thanks and best regards,

Marco


Yves

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
20323
by: Che | last post by:
I have the following code /* WinTest.java */ import java.io.*;
11
3586
by: BoonHead, The Lost Philosopher | last post by:
I think the .NET framework is great! It's nice, clean and logical; in contradiction to the old Microsoft. It only saddens me that the new Microsoft still doesn't under stand there own...
2
4952
by: Gos | last post by:
Hi, I have a program that needs to open a list of attachments displayed on a ListView. I have used Process.Start method to open the files using their associated program. This works correctly if...
7
8057
by: Shane Story | last post by:
I want to be able to get the icon associated with a certain file extension. I can read the registry hkey_classes to get the ext. then look to the other key for default icon. How can I then...
5
3155
by: IcingDeath via DotNetMonster.com | last post by:
I am building this SQL Server database app in which i can store files. In order to display files I want to have the app show the associated icon for the extension of the file that is in the...
4
1781
by: pamelafluente | last post by:
Hi guys, I have a little question (hope it's not dumb) ;-) I have a form, containing a TreeView, say TreeView1, I want to to add a file to the tree: Sub AddFile(ByVal MyFile As...
27
2048
by: cj | last post by:
I run this program and to exit click the X in the upper right corner. But apparently it isn't really ending the program. If I return to VB and make changes then try to rebuild the app it says the...
4
1896
memoman
by: memoman | last post by:
Can any body help me in that program ??? mail me if anybody could reach any -helpfull- thing Write a C++ program that namely insert, delete, and search in a fixed record length file (containing...
3
2470
by: plbaldri | last post by:
I have written a very simple and basic program for an intro Comp Sci class and am having trouble with it crashing. The program needs to accept a filename on the command line at the prompt and has to...
0
7171
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7388
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7547
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5693
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5098
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4751
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3230
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1607
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.