小妹求教各位大侠(急用):如何在VC++中调用.exe文件
在VC++中调用.exe文件,有相应的函数吗?还是要编写成.dll才能调用?
谢谢各位大侠,请多多指教
问题点数:50、回复次数:14Top
1 楼suxk(逍遥小子)回复于 2003-06-03 20:48:36 得分 10
UINT WinExec(
LPCSTR lpCmdLine, // command line
UINT uCmdShow // window style
);
Top
2 楼kingtsui(http://community.studyez.com/blogs/silentacorn)回复于 2003-06-03 20:51:59 得分 0
CreateProcess
The CreateProcess function creates a new process and its primary thread. The new process runs the specified executable file in the security context of the calling process.
If the calling process is impersonating another user, the new process uses the token for the calling process, not the impersonation token. To run the new process in the security context of the user represented by the impersonation token, use the CreateProcessAsUser or CreateProcessWithLogonW function.
BOOL CreateProcess(
LPCTSTR lpApplicationName,
LPTSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
BOOL bInheritHandles,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPCTSTR lpCurrentDirectory,
LPSTARTUPINFO lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation
);
Parameters
Top
3 楼jsphuang(建设者)回复于 2003-06-03 20:53:57 得分 30
打开C盘的c:\Windows\Notepad.exe
ShellExecute(NULL,"open","c:\\Windows\\Notepad.exe",NULL,NULL,SW_SHOW);
Top
4 楼ydzqw(BE BIG)回复于 2003-06-03 20:54:48 得分 0
ShellExecuteTop
5 楼jjqiao710102(aqiao)回复于 2003-06-03 21:01:12 得分 10
VC提供了三种方式:
一、ShellExecute
二、WinExec
三、CreateProcess
以第三种创建新的进程为最快。Top
6 楼wanghuahua(五月天)回复于 2003-06-03 21:38:12 得分 0
CreateProcess的参数好多啊,都是什么意思呀
我是初学者,好胡涂
Top
7 楼linawz(沧江孤浪)回复于 2003-06-04 06:51:56 得分 0
请问如果要直接打开一个TXT,文件那又怎么做呢?比如说是E:\\result\\file.txtTop
8 楼binjuny(binjuny)回复于 2003-06-04 07:35:11 得分 0
我来晚了,,,都被说的,,,
一、ShellExecute
二、WinExec
三、CreateProcess
Top
9 楼sxmzmxh(哥舒帶菜刀)回复于 2003-06-04 14:29:09 得分 0
還是system("notepad");最快Top
10 楼lazycalm(lazycalm)回复于 2003-06-04 20:47:30 得分 0
STARTUPINFO si = {sizeof(si)};
PROCESS_INFORMATION pi;
CreateProcess(TEXT("the path of your exe"),NULL,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);Top
11 楼yndfcd(YNDFCD)回复于 2003-06-05 11:33:23 得分 0
不知道你所说的调用是什么意思,如果是想执行一个程序的话,楼上己经说过了。
如果只是想用exe中的资源的话,用LoadLibrary,LoadLibrayEx.Top
12 楼windows_editor(十年树木,百年树袋熊)回复于 2003-06-05 16:52:47 得分 0
CreateProcess,这个函数能保证你在调用exe的时候后台执行Top
13 楼Nizvoo()回复于 2003-06-05 17:41:21 得分 0
CreateProcessTop
14 楼jiadrun(MustBeSuccess)回复于 2003-06-05 18:21:22 得分 0
WinExec()
ShellExecute()Top



