请问如何在程序中执行一个exe文件?我查到了一个函数
int _execl( const char *cmdname, const char *arg0, ... const char *argn, NULL )我是这样调用的:
_execl("good","good",NULL);
其中good是我放在同目录下的一个exe文件,功能是打印出一行文本。结果执行后什么都没有
请问有什么问题??或者还有什么别的方法??
非常感谢。
int _execl( const char *cmdname, const char *arg0, ... const char *argn, NULL )我是这样调用的:
_execl("good","good",NULL);
其中good是我放在同目录下的一个exe文件,功能是打印出一行文本。结果执行后什么都没有
请问有什么问题??或者还有什么别的方法??
非常感谢。
解决方案 »
- VisualStudio2010编辑菜单代码出错,请教~~~
- 我的程序在debug版本编译通过,执行成功,但是改为release版本时编译通过了,但提示cannot execute program
- 关于CRect
- 各位大虾,请看
- help
- 想开始学习用SDK和VC进行数据库应用开发,不知道有没有这方面很好的教材?
- GetDefaultConnect()的问题
- 关于CreateFile以及DeviceIoControl的使用
- 不用安装OFFICE,查看DOC,XLS,PPT文件。
- 如何在程序中编写类似 Office2000(XP) 中的助手?
- if (m_pHashTable == NULL) 是干什么用的?
- 紧急求救!!VC的Debug窗口,可以两个停在一排,这是如何实现的??在线等。
LPCSTR lpCmdLine, // command line
UINT uCmdShow // window style
);
或者
HINSTANCE ShellExecute(
HWND hwnd,
LPCTSTR lpVerb,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
);
或者
BOOL CreateProcess(
LPCTSTR lpApplicationName, // name of executable module
LPTSTR lpCommandLine, // command line string
LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD
LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD
BOOL bInheritHandles, // handle inheritance option
DWORD dwCreationFlags, // creation flags
LPVOID lpEnvironment, // new environment block
LPCTSTR lpCurrentDirectory, // current directory name
LPSTARTUPINFO lpStartupInfo, // startup information
LPPROCESS_INFORMATION lpProcessInformation // process information
);自己选一个用吧
LPCSTR lpCmdLine, // 命令行参数,就是可执行文件的路径如:"C:\\test.exe"
UINT uCmdShow // 窗口风格,可以为 SW_SHOW,SW_HIDE,SW_MAXIUM .....
);
上面这个函数是从16位的Windows沿用下来的,这个函数比较老,不过参数少很容易使用HINSTANCE ShellExecute(
HWND hwnd,
LPCTSTR lpVerb,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
);
这个函数是Windows的外壳函数,其内部是调用了CreateProcess()函数,参数比较多,具体的就参考一下MSDN 吧!呵呵……BOOL CreateProcess(
LPCTSTR lpApplicationName, // name of executable module
LPTSTR lpCommandLine, // command line string
LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD
LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD
BOOL bInheritHandles, // handle inheritance option
DWORD dwCreationFlags, // creation flags
LPVOID lpEnvironment, // new environment block
LPCTSTR lpCurrentDirectory, // current directory name
LPSTARTUPINFO lpStartupInfo, // startup information
LPPROCESS_INFORMATION lpProcessInformation // process information
);
这个函数是是这三个函数中功能最强大的一个函数,需要设置的信息比较多,可以完成的对子进程的控制也是最多的,值得楼主好好研究一下!
上面的就是俺说的,希望对楼主有所帮助!
LPCSTR lpCmdLine, // 命令行参数,就是可执行文件的路径如:"C:\\test.exe"
UINT uCmdShow // 窗口风格,可以为 SW_SHOW,SW_HIDE,SW_MAXIUM .....
);
上面这个函数是从16位的Windows沿用下来的,这个函数比较老,不过参数少很容易使用HINSTANCE ShellExecute(
HWND hwnd,
LPCTSTR lpVerb,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
);
这个函数是Windows的外壳函数,其内部是调用了CreateProcess()函数,参数比较多,具体的就参考一下MSDN 吧!呵呵……BOOL CreateProcess(
LPCTSTR lpApplicationName, // name of executable module
LPTSTR lpCommandLine, // command line string
LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD
LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD
BOOL bInheritHandles, // handle inheritance option
DWORD dwCreationFlags, // creation flags
LPVOID lpEnvironment, // new environment block
LPCTSTR lpCurrentDirectory, // current directory name
LPSTARTUPINFO lpStartupInfo, // startup information
LPPROCESS_INFORMATION lpProcessInformation // process information
);
这个函数是是这三个函数中功能最强大的一个函数,需要设置的信息比较多,可以完成的对子进程的控制也是最多的,值得楼主好好研究一下!
上面的就是俺说的,希望对楼主有所帮助!