Click here to Skip to main content
15,923,006 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written a program in VC++ 2008 Express that, when all necessary information is entered, it opens a file in another program (.mpt extension).

However, for whatever reason, opening "actualFile.mpt" does nothing more than opening the shortcut "MPT.exe", and does not open the actual file.

Maybe I'm being too optimistic even asking this, but is there a way to, from my c++ code, to do a File->Open Product... and have the program select the file to open inside this MPT software?

The call I'm using to open the file is simply:
system(mptFile.c_str());


Hope someone can help; thanks in advance,
Pat

EDIT:
Thanks for all the help everyone. If anyone is curious, the command I ended up using is "MPT.exe -lmptFile.mpt".
Posted
Updated 2-Aug-11 4:41am
v2

Try calling with the string "MPT.exe actualFile.mpt". If the command line of MPT allows passing a file to open, this could work.
 
Share this answer
 
Instead of:

system("actualFile.mpt");


Try:

system("mpt.exe actualFile.mpt");


Or (to be more complete):

CString command;
command.Format("mpt.exe \"%s\"", mptFile);
system(command.c_str());


If mpt.exe is in your path, then that should actually invoke mpt.exe.

The only question then is if the mpt.exe program actually parses it's command line and opens files on the command line, or if it expects some sort of command line switch. (Such as "mpt.exe /o filename.mpt" or something similar.) If you don't have documentation on what mpt.exe expects on it's command line, you can always experiment with variations typed in from the command window and see if you can hit on something that works.
 
Share this answer
 
It does not depend on our code, but on how the "mtp" extension is registered in the system (and hence which program it invokes, with which parameters) and by the capability of that program to support an automatic file open when given by the command line.

You an actually try with a specific invocation of the program like suggested here[^], but it is not a good idea for "production".

Pretending a specific app to be in the path of the user's computer isn't a good practice: imagine to be the user of a computer with 100 apps pretending to be in the path. Whatever command you invoke, you run across the entire hard-disk. Not the way to go!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900