简体   繁体   English

如何在C ++应用程序中的exe文件中打开文件

[英]How can I open a file inside of an exe inside of my c++ app

Question is I have this button that when clicked I would like it open a file for me inside of a specific executable. 问题是我有这个按钮,当单击该按钮时,我希望它在特定的可执行文件内为我打开一个文件。

I am a tad rusty on c++ and this is a legacy application using c++ 6.0 built on windows xp.....So any help would be greatly appreciated! 我对c ++有点生疏,这是一个使用Windows xp上构建的c ++ 6.0的旧应用程序。因此,任何帮助将不胜感激!

Here is my code cpp 这是我的代码cpp

void CJunkView::OnCadkeyButton() 

  {
   CString fileToOpen = "C:\\Documents and Settings\\Administrator\\Desktop\\x.prt";
   CString exePath = "C:\\CK19\\Ckwin.exe";
   system ("start (exePath), (fileToOpen)");
  }

When I click this button it returns this Windows cannot find 'exePath,'.Make sure you typed the name correctly and then try again. 当我单击此按钮时,它将返回此Windows找不到“ exePath”的窗口。请确保正确键入名称,然后重试。

You need to build a string that contains the entire system call and the pass the buffer of that string to system() 您需要构建一个包含整个系统调用的字符串,并将该字符串的缓冲区传递给system()

Edit: 编辑:

In response to the comment by IInspectable we could just use the implicit conversion operator operator LPCTSTR() 为了回应IInspectable的评论,我们可以只使用隐式转换运算operator LPCTSTR()

void CJunkView::OnCadkeyButton() 
{
   CString fileToOpen = "C:\\Documents and settings\\Administrator\\Desktop\\x.prt";
   CString exePath = "C:\\CK19\\Ckwin.exe";
   CString cmd = "start " + exePath + ", " + fileToOpen;
   system (cmd);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM