c/c++语言开发共享打开外部程序

我一直试图在C中打开像编辑器这样的外部程序。我已经搜索了几个小时但没有找到打开外部可执行文件的方法,例如从控制台应用程序打开Skype等。

到目前为止这是我的代码:

/* fopen1.c */ #include  #include  #include  #include  int main(int) { FILE *fp; fp = fopen("C://Users/Jonte/Desktop/Skype.exe", "r"); } 

如何打开外部文件? 谢谢,真诚的,贝林

    一种可能的方式 –

    system("C:\Windows\notepad.exe");

    要么

     ShellExecute(NULL, "open", "C:\Windows\notepad.exe", NULL, NULL, SW_SHOWDEFAULT); 

    或使用CreateProcess

     VOID startup(LPCTSTR lpApplicationName) { // additional information STARTUPINFO si; PROCESS_INFORMATION pi; // set the size of the structures ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); // start the program up CreateProcess( lpApplicationName, // the path argv[1], // Command line NULL, // Process handle not inheritable NULL, // Thread handle not inheritable FALSE, // Set handle inheritance to FALSE 0, // No creation flags NULL, // Use parent's environment block NULL, // Use parent's starting directory &si, // Pointer to STARTUPINFO structure &pi ) // Pointer to PROCESS_INFORMATION structure ) // Close process and thread handles. CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); } 

      以上就是c/c++开发分享打开外部程序相关内容,想了解更多C/C++开发(异常处理)及C/C++游戏开发关注计算机技术网(www.ctvol.com)!)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

      ctvol管理联系方式QQ:251552304

      本文章地址:https://www.ctvol.com/c-cdevelopment/519064.html

      (0)
      上一篇 2020年12月5日
      下一篇 2020年12月5日

      精彩推荐