02-13-2013 11:42 AM
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.
Solved! Go to Solution.
02-13-2013 11:57 PM - edited 02-13-2013 11:59 PM
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:
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.