LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

"main" arguments when starting program - How does Windows communicate file-open requests to programs?

Solved!
Go to solution

Does anybody know what Windows passes or sends to a program when it is first started? I'm not even sure what to search under. In particular, if I double-click on a document (say a data file that I've generated with my LabWindows/CVI program) and have my program set as the default for that file under Windows, how does my program know it when it starts up? (I.e. double-clicking on a Word document starts Word and opens that document.) Also, what if my program is already running? Presumably Windows sends a message to programs telling them that the user has requested it to open a file of the appropriate type.

0 Kudos
Message 1 of 2
(2,720 Views)
Solution
Accepted by topic author pblase

Windows passes the filename you clicked on to the application as a command-line parameter: the attached program simply lists all command line arguments received so you can check how this works. I made some tests creating a ".XYZ" file and then associating this program to it. Next I created a new "Print" operation, defined this way:

 

FIleAssociation.PNG

 

and received the correct parameters both when I simply double-clicked the file and when I right-clicked it and selected "Print".

 

(Note: argv[0] is always the program name itself: command line options, if any, starts at index 1).

 

I cannot say anything on your second question: I know CVI has a way to see if another instance of the application is running (see CheckForDuplicateAppInstance command in the Utility Library) but I don't know how it is implemented.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 2
(2,709 Views)