vc中winexec使用?

来源:百度知道 编辑:UC知道 时间:2024/05/14 11:04:05
#include <iostream.h>
#include <windows.h>

int main()
{
WinExec("E:\QQ.EXE",SW_SHOW);
return 0;
}
编译时出现----------------Configuration: 1 - Win32 Debug--------------------
Compiling...
1.cpp
c:\program files\microsoft visual studio\myprojects\1\1.cpp(5) : error C2065: 'winexec' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\1\1.cpp(5) : warning C4129: 'Q' : unrecognized character escape sequence
c:\program files\microsoft visual studio\myprojects\1\1.cpp(6) : warning C4508: 'main' : function should return a value; 'void' return type assumed
2.c
c:\program files\microsoft visual studio\myprojects\1\2.c(6) : warning C4129: 'Q' : unrecognized character escape sequence
执行 cl.exe 时出错.

1.exe - 1 error(s), 0 warning(s)
怎么

  该函数只提供对16位机子的兼容。应用程序应该使用CreateProcess函数。

  Declare Function WinExec Lib "kernel32" Alias "WinExec" (ByVal lpCmdLine As String, ByVal nCmdShow As Long) As Long

  • 说明

  运行指定的程序

  • 返回值

  Long,大于31表示成功,请参考FindExecutable函数

  •  参数表

  参数 类型及说明

  lpCmdLine String,包含要执行的命令行

  nCmdShow Long,定义了以怎样的形式启动程序的常数值。参考ShowWindow函数的nCmdShow参数

  • 注解

  请参考对CreateProcess函数的说明,了解在目录中查找指定文件的顺序

  VC中如何使用

  WINSHELLAPI void WINAPI WinExecErrorA(HWND hwnd, int error, LPCSTR lpstrFileName, LPCSTR lpstrTitle);

  WINSHELLAPI void WINAPI WinExecErrorW(HWND hwnd, int error, LPCWSTR lpstrFileName, LPCWSTR lpstrTitle);

  • 参数说明:

  hw