473,668 Members | 2,661 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to associate files with application

hi,
i want to know how to make a specific type of file open in an
application i developed in python when the user clicks on the file.(in
windows) for eg. a .txt file when clicked opens in notepad, a .doc file
when clicked opens in MS-word. In the same way i want to make a .xyz
file open in the application i developed when clicked.
thanks in advance for any advice.

Oct 27 '05 #1
6 2369

Ashok wrote:
hi,
i want to know how to make a specific type of file open in an
application i developed in python when the user clicks on the file.(in
windows) for eg. a .txt file when clicked opens in notepad, a .doc file
when clicked opens in MS-word. In the same way i want to make a .xyz
file open in the application i developed when clicked.
thanks in advance for any advice.


Not an expert in this (OS-related) field but in Windows I think that
would be a Registry thing...

Maybe this article could help you start somewhere...
http://antivirus.about.com/od/window...fileassoc4.htm

Good Luck, and maybe you can reply-post your eventual success recipe!

Oct 28 '05 #2
Ashok wrote:
hi,
i want to know how to make a specific type of file open in an
application i developed in python when the user clicks on the file.(in
windows) for eg. a .txt file when clicked opens in notepad, a .doc file
when clicked opens in MS-word. In the same way i want to make a .xyz
file open in the application i developed when clicked.
thanks in advance for any advice.


You need to add several registry keys to do this, here's a short version
of what you need to do:

Example assumes you want to:

1. associate .ext with C:\Program Files\MyProgram \prog.exe
2. pass on any extra arguments to prog.exe (ie. test.ext 1 2 3 would
send 1 2 3 as well to prog.exe)
3. associate the icon of prog.exe to any file with a .ext extension

Ok, here's what you need to do:

1. Under HKEY_CLASSES_RO OT, add a key (folder) with the name .ext
2. Open that key, and set the (Default) value to MyProgramExtend edFile
(this name is something you choose yourself and should be a "identifier "
that identifies the file type. If your program supports several types of
files, make up unique identifiers for each.)
3. Under HKEY_CLASSES_RO OT, add another key, this time with the same
name you made up in 2. above, ie MyProgramExtend edFile
4. Open that key, and set the (Default) value to a textual description
of the type of file. This is what will show up in explorer in the file
type column. If you leave this empty, the description will be .EXT File
5. Inside MyProgramExtend edFile, add another key with the name shell
(lower-case is typical, can probably be Shell or whatever)
6. Inside shell, create another key with the name open
7. Inside open, create another key with the name command
8. Inside command, Set the (Default) value to:
"C:\Program Files\MyProgram \prog.exe" "%1" %*

Note that you need the quotes as specified above, exactly like written

9. Go back to MyProgramExtend edFile and create another key with the name
DefaultIcon
10. Inside DefaultIcon, set (Default) value to:
"C:\Program Files\MyProgram \prog.exe", 0

This will pick the first icon in prog.exe resource to show for the
files. Use 1 for second, etc.

There are also other commands you can add. If you want to be able to
right-click on the file and select a menu item to process the file in a
specific way, for instance by passing along specific parameters to
prog.exe, you can add more keys than "open" on the level open is
created. The (Default) value inside the key is then the text of the menu
item.

To find examples, just find a file extension in Windows that behaves the
way you want your own to behave and look through HKEY_CLASSES_RO OT\.ext
to find the details you want.

--
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:la***@vk arlsen.no
PGP KeyID: 0x2A42A1C2
Oct 28 '05 #3
Lasse Vågsæther Karlsen wrote:
Ashok wrote:
hi,
i want to know how to make a specific type of file open in an
application i developed in python when the user clicks on the file.(in
windows) for eg. a .txt file when clicked opens in notepad, a .doc file
when clicked opens in MS-word. In the same way i want to make a .xyz
file open in the application i developed when clicked.
thanks in advance for any advice.


You need to add several registry keys to do this, here's a short version
of what you need to do:

Example assumes you want to:

1. associate .ext with C:\Program Files\MyProgram \prog.exe
2. pass on any extra arguments to prog.exe (ie. test.ext 1 2 3 would
send 1 2 3 as well to prog.exe)
3. associate the icon of prog.exe to any file with a .ext extension

Ok, here's what you need to do:

1. Under HKEY_CLASSES_RO OT, add a key (folder) with the name .ext
2. Open that key, and set the (Default) value to MyProgramExtend edFile
(this name is something you choose yourself and should be a "identifier "
that identifies the file type. If your program supports several types of
files, make up unique identifiers for each.)
3. Under HKEY_CLASSES_RO OT, add another key, this time with the same
name you made up in 2. above, ie MyProgramExtend edFile
4. Open that key, and set the (Default) value to a textual description
of the type of file. This is what will show up in explorer in the file
type column. If you leave this empty, the description will be .EXT File
5. Inside MyProgramExtend edFile, add another key with the name shell
(lower-case is typical, can probably be Shell or whatever)
6. Inside shell, create another key with the name open
7. Inside open, create another key with the name command
8. Inside command, Set the (Default) value to:
"C:\Program Files\MyProgram \prog.exe" "%1" %*

Note that you need the quotes as specified above, exactly like written

9. Go back to MyProgramExtend edFile and create another key with the name
DefaultIcon
10. Inside DefaultIcon, set (Default) value to:
"C:\Program Files\MyProgram \prog.exe", 0

This will pick the first icon in prog.exe resource to show for the
files. Use 1 for second, etc.

There are also other commands you can add. If you want to be able to
right-click on the file and select a menu item to process the file in a
specific way, for instance by passing along specific parameters to
prog.exe, you can add more keys than "open" on the level open is
created. The (Default) value inside the key is then the text of the menu
item.

To find examples, just find a file extension in Windows that behaves the
way you want your own to behave and look through HKEY_CLASSES_RO OT\.ext
to find the details you want.

I'm no Windows expert but I think that, using Windows Explorer, one can,
with a right mouse click, select "Open With".

You can then choose the appropriate executable. I believe that, if you
had set the "Always open with this program" box, then the registry is
automatically updated.

Colin W.
Oct 28 '05 #4
On Fri, 28 Oct 2005 09:48:27 -0400, "Colin J. Williams"
<cj*@sympatico. ca> declaimed the following in comp.lang.pytho n:

I'm no Windows expert but I think that, using Windows Explorer, one can,
with a right mouse click, select "Open With".

You can then choose the appropriate executable. I believe that, if you
had set the "Always open with this program" box, then the registry is
automatically updated.
You could also use the "file types" page (on XP it is under
"tools/folder options", W9x puts it under "view/folder options" I
believe). to define new file types, and then define all the actions
available for it. The default would be the Open action, but you might
add a print or edit action; these would show up using a right-click on
the file.
-- =============== =============== =============== =============== == <
wl*****@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
=============== =============== =============== =============== == <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.ne tcom.com/> <

Oct 28 '05 #5
Dennis Lee Bieber wrote:
On Fri, 28 Oct 2005 09:48:27 -0400, "Colin J. Williams"
<cj*@sympatico. ca> declaimed the following in comp.lang.pytho n:
I'm no Windows expert but I think that, using Windows Explorer, one can,
with a right mouse click, select "Open With".

<snip>

There are several ways to do this using Windows Explorer. I was under
the assumption the OP wanted to know how he could automate it since that
is what you typically want to do with applications you write.

--
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:la***@vk arlsen.no
PGP KeyID: 0x2A42A1C2
Oct 29 '05 #6
Thanks Lasse, that was really helpful

Nov 3 '05 #7

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

Similar topics

1
3396
by: knutsample | last post by:
Hello! I'm trying to associate a file extension to my wxPython script so that all I have to do is double click on the file and my python script will load up with the path of that file. For instance, I've associated all .py files to be opened up with emacs.exe. If I double click on a .py file, emacs.exe would open up with that file in its buffer.
2
1844
by: John Baker | last post by:
Hi: I have used this group a number of times simply because while the manuals for Access may show the technology, but most are really weak on how to apply it in special situations and the indexes are less that complete!. This is also the first real application iI have developed for Access, although I have done a number in Lotus Approach. I have a table with information on how an Associate is to be handled under a specific Purchase...
1
1259
by: Tran Hong Quang | last post by:
Hi, Is it possible to write a code in C++ to associate a given file extension with our application? So that if user double click on the file on Windows Explorer, our application will be launched. Thanks Tran Hong Quang
1
1310
by: Ryan Liu | last post by:
Hi, As I remember theare are In and Out stream associate with a socket. TcpClient seems there in only one NetworkStream to do both read and write. Then will it be a conflicit if both side try to send data? And when one end is sending data, if another end is not calling Recevive or BeginReceive, will the sender be blocked? Or recevier side network hardware will read anyway, just our high-end application has not take the data yet?
4
15642
by: BD | last post by:
Hi all. Running SQL2K SP4 on W2K3 Standard, SP4. I have just refreshed a database on one server with a backup from another. The database had existed previously on the target server, and I am just refreshing its contents. I used the following approach 1) From the target server, create a SQL script with users and roles 2) From the source server, back up the db
1
1147
by: zidansoft | last post by:
I created appropriate registry entries(shell\open\command) . my simple application lunching with that particular extension . problem 1 how i can handle that particular file from my application?(how get file name as well as where i can handle ) problem2 when i tried with big application (liking with so many dll and other files) it is crashing, i believe this may be happening due to
2
1480
by: wizardRahl | last post by:
Hello, I am curious to know if there is a way to associate old files with a new installation of windows. I reinstalled windows b/c the OS crashed and would never boot. Upon installing the fresh copy, I made a seperate folder called Windows2 to store the new system files and just to make sure that none of my data was lost. I now want to have all my old programs and such to load correctly. I know that I could just go and reinstall them...
0
827
by: Proogeren | last post by:
Hello Does anyone know if it is possible to associate mp3 files with a vb 6.o application? Like windows media player. so that when you see a mp3 file in explorer it will have your applications icon? help appreciated
0
3175
by: liuhengyi | last post by:
Hi, I also have a question when using VS 2008 to edit the xml file. In my xml file, I used schemaLocation attribute to specify the xsd. If I put the xsd in our internal sharepoint site such as: xsi:schemaLocation="someNs http://sharepoint/Test.xsd" VS2008 xml editor shows that "this schema referenced from this location in your document contains errors". However if I copy the xsd to the local folder, and use this:
0
8381
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8797
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8583
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7401
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6209
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5681
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4380
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2791
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 we have to send another system
2
1786
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.