Associating a file with my application - Reg

Are you writing your own components and need help with how to set them up or have questions about the components you are deriving from ? Ask them here.
Post Reply
Knows some wx things
Knows some wx things
Posts: 39
Joined: Tue Jan 20, 2009 10:37 am
Location: chennai

Associating a file with my application - Reg

Post by rajan_m » Fri Jul 03, 2009 9:22 am

Hi, :)

I'v written (wxWidgets)application program in windows platform, which will read the content of a input file(for eg,txt) specified by user and do some processing :| .

My Requirement:
when i double click the input file it has to trigger the aplication program and has to do the processing :shock: .

:idea: I'v associated the input file with my appliction simply through choose program dialog, so when i double click
input file is triggering the exe :D .
Is there any way to get the input file path within myapp::OnInit() :cry: , so that i can get the input data to proceed with.
Every exit is an entry somewhere else!

Earned some good credits
Earned some good credits
Posts: 122
Joined: Fri Apr 14, 2006 9:49 pm
Location: Beaverton, OR

Post by Xangis » Fri Jan 29, 2010 9:08 pm

Setting a file association is not normally done from within a program. It's more common to set file associations using the installer. For instance, I use InnoSetup for my Windows installs, and in one part of that install process I set registry entries that associate file types with my app.

If you're curious about that method, you can look here:

I suppose you could always modify the registry entries in code, but that's bad form because when your app is uninstalled the file associations don't go away.
WinVista/7: VC++ .Net 2010 / Ubuntu 11.04: gcc4.4.3 [2.8.12 on all]

Earned a small fee
Earned a small fee
Posts: 13
Joined: Thu May 21, 2009 3:59 am

Post by matioli » Tue Sep 14, 2010 1:59 pm

rajan_m, you can use the argc and argv (wxApp members):

Code: Select all

bool myApp::OnInit(){
    wxString filename;
    if (argc == 2){ // Check if there is just one argument
        filename = argv[1];
        // do processing
       // use the open file dialog
Matheus de Oliveira

Post Reply