问题描述
我已经在VC ++ 2008 Express中编写了一个程序,当输入所有必要信息时,它将在另一个程序(扩展名为.mpt)中打开一个文件.
但是,无论出于何种原因,打开"actualFile.mpt"只不过是打开快捷方式"MPT.exe",而不会打开实际文件.
也许我甚至都不敢问这个问题,但是有没有办法从我的C ++代码中执行File-> Open Product ...,并让程序选择要在此MPT软件中打开的文件?
我用来打开文件的调用很简单:
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());
希望有人能帮忙;预先感谢,
帕特
谢谢各位的帮助.如果有人好奇,我最终使用的命令是"MPT.exe -lmptFile.mpt".
Hope someone can help; thanks in advance,
Pat
Thanks for all the help everyone. If anyone is curious, the command I ended up using is "MPT.exe -lmptFile.mpt".
推荐答案
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());
如果mpt.exe在您的路径中,则实际上应该调用mpt.exe.
然后,唯一的问题是mpt.exe程序是否实际上解析了它的命令行并在命令行上打开了文件,或者它是否期望某种命令行开关. (例如"mpt.exe/o filename.mpt"或类似的名称.)如果您没有关于mpt.exe在其命令行中期望的内容的文档,则始终可以尝试使用从命令窗口,看看您是否可以找到起作用的东西.
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.
这篇关于从C ++代码打开文件菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!