Double click on file to load in my app

E

Elmo Watson

I have set the file association for Text files with my application - now
what I'd like to do is to double click on a text file, and have it actually
load in my application.
Right now - all that happens when I double click on the file is that it runs
my application, but the file I double clicked on is not loaded.

1. The default icon never changes for Text Files
2. When I go in, with Regedit, to look at what this put in, for this:
Registry.SetValue(HKEY_CLASSES_ROOT, "My App\\\\shell\\\\open\\\\command",
"", SessionVar.Expand("%AppFolder%\\\\MyApp.exe\\\"%1\""), REG_SZ);
I get:
c:\Program Files\myFolder\\My app.exe\"%1"
isn't it supposed to be a 1 surrounded by percent (%1%)?, and more like:
c:\Program Files\myFolder\My app.exe %1%

3. HKEY_CLASSES_ROOT\TxtFile never gets changed from Notepad - I change that
designation to my application, and at least it will open my application, but
it won't load the file into my application

I've gotten this stuff from the knowledgebase, and from indigo rose posts
concerning it - -
Can someone please give me a definitive section of code to get this done?
 
M

Moty Michaely

I have set the file association for Text files with my application - now
what I'd like to do is to double click on a text file, and have it actually
load in my application.
Right now - all that happens when I double click on the file is that it runs
my application, but the file I double clicked on is not loaded.

1. The default icon never changes for Text Files
2. When I go in, with Regedit, to look at what this put in, for this:
Registry.SetValue(HKEY_CLASSES_ROOT, "My App\\\\shell\\\\open\\\\command",
"", SessionVar.Expand("%AppFolder%\\\\MyApp.exe\\\"%1\""), REG_SZ);
I get:
c:\Program Files\myFolder\\My app.exe\"%1"
isn't it supposed to be a 1 surrounded by percent (%1%)?, and more like:
c:\Program Files\myFolder\My app.exe %1%

3. HKEY_CLASSES_ROOT\TxtFile never gets changed from Notepad - I change that
designation to my application, and at least it will open my application, but
it won't load the file into my application

I've gotten this stuff from the knowledgebase, and from indigo rose posts
concerning it - -
Can someone please give me a definitive section of code to get this done?


Dear Eimo,

You need to associate the file extension with your application.

Check this sample out:
http://www.codeproject.com/shell/cgfiletype.asp

Hope this helps.

Moty
 
E

Elmo Watson

Sorry for that - - - - Actually, this was not meant for this group - I was
sending two message - one to this group and one to the support department
for the setup software I am using....

Here's what I really meant for this group - -

I've got TextFiles associated with my application - however, when I double
click on the files, it just opens my application, and does not load the file
inside my application. Here's my sub:
Private Sub GetOutsideFile(ByVal FileArgs() As String)
Dim s As String
For Each s In FileArgs
If s.EndsWith("txt") Then
CreateNewDocument(s)
End If
Next
End Sub

Then, in the form load, I put this line:
GetOutsideFile(Environment.GetCommandLineArgs())

What am I missing here?
 
E

Elmo Watson

It probably would help, if I knew C++
however, I'm a VB.Net developer

Thanks, though
 

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

Top