Loading associated files

Lie Lie.1296 at gmail.com
Sun Apr 27 08:38:43 EDT 2008


On Apr 24, 10:14 pm, flarefi... at googlemail.com wrote:
> I am trying to make a a simple databasing GUI interface and and have
> created a module to deal with parsing the data from a file and a GUI
> based program that displays this data using PyQt4, i know how to
> register files in the system registry using python and also using Inno
> Setup which i use to package my applications, but i cant work out how
> if a file is doubled clicked on to send the path of that file to
> python.

Do you mean: when a file with "your extension" is double clicked on,
then Windows should pass the path of that file to "your application"
that is written in Python?

(snip)

On Apr 26, 7:26 pm, flarefi... at googlemail.com wrote:
> I can't get this to work (I am on XP SP2 by the way and using Python
> 2.5),
>
> I wrote a very simple script to test the idea:
>
> import sys
>
> for arg in sys.argv:
>     print arg
>
> raw_input("Done") #Merely to slow the program down so i can see output
>
> and then setup a file extension .xyz, placed it in the registry, can
> get a .xyz file to work as a python script so the registry setup is
> fine, but when i try and put the parameter to the above program and a
> %1 (or even without) it gets the following error message from windows:
>
> C:\...\hmm.xyz is not a valid Win32 application.
>
> any suggestions??

Windows seems to be trying to execute your file.xyz as an application,
this means it hasn't associated your extension (.xyz) with your
application, instead .xyz is associated as an executable.

To associate your extension with your application, see:
http://msdn2.microsoft.com/en-us/library/bb776883.aspx
It's a bit advanced

NOT TESTED:
# Create or edit Registry Key: 'HKEY_CLASSES_ROOT\.xyz'
# Change the value for the key 'HKEY_CLASSES_ROOT\.xyz:' into 'MyApp'
# Create or edit Registry Key: 'HKEY_CLASSES_ROOT\MyApp\Shell\Open
\Command'
# Change Registry Key value for 'HKEY_CLASSES_ROOT\MyApp\Shell\Open
\Command' into: '"C:\pathtomyapp\myapp.py" "%1"'

Check an existing registry key, how they do it.



More information about the Python-list mailing list