vc中用shellexecute调用可执行程序为什么只能执行一次啊?

zhangweijlc 2009-08-21 08:34:28
我在vc中用shellexecute调用一个可执行程序,但是只能执行一次,以后都没反应,我单步调试了一下,发现第2次调用貌似好像也执行了啊?
...全文
129 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
clever101 2009-08-21
  • 打赏
  • 举报
回复

参考:


HANDLE m_handle = ShellExecute(this->m_hWnd,"open","Winamp.exe",NULL,"",SW_SHOWDEFAULT);


查查m_handle的值。
zhangweijlc 2009-08-21
  • 打赏
  • 举报
回复
我的可执行程序是个无返回值的c程序,我在vc中传递参数给main函数,然后执行,第一次完全正确,第2次以后执行完调用语句没有任何结果,但是并没有报错,shellexecute在哪里可以看返回值啊,
clever101 2009-08-21
  • 打赏
  • 举报
回复
[Quote=引用楼主 zhangweijlc 的回复:]
我在vc中用shellexecute调用一个可执行程序,但是只能执行一次,以后都没反应,我单步调试了一下,发现第2次调用貌似好像也执行了啊?
[/Quote]

看看第二次调用的返回值是多少?根据返回值确定错误原因。

Returns a value greater than 32 if successful, or an error value that is less than or equal to 32 otherwise. The following table lists the error values. The return value is cast as an HINSTANCE for backward compatibility with 16-bit Windows applications. It is not a true HINSTANCE, however. The only thing that can be done with the returned HINSTANCE is to cast it to an int and compare it with the value 32 or one of the error codes below.

0 The operating system is out of memory or resources.
ERROR_FILE_NOT_FOUND The specified file was not found.
ERROR_PATH_NOT_FOUND The specified path was not found.
ERROR_BAD_FORMAT The .exe file is invalid (non-Microsoft Win32 .exe or error in .exe image).
SE_ERR_ACCESSDENIED The operating system denied access to the specified file.
SE_ERR_ASSOCINCOMPLETE The file name association is incomplete or invalid.
SE_ERR_DDEBUSY The Dynamic Data Exchange (DDE) transaction could not be completed because other DDE transactions were being processed.
SE_ERR_DDEFAIL The DDE transaction failed.
SE_ERR_DDETIMEOUT The DDE transaction could not be completed because the request timed out.
SE_ERR_DLLNOTFOUND The specified dynamic-link library (DLL) was not found.
SE_ERR_FNF The specified file was not found.
SE_ERR_NOASSOC There is no application associated with the given file name extension. This error will also be returned if you attempt to print a file that is not printable.
SE_ERR_OOM There was not enough memory to complete the operation.
SE_ERR_PNF The specified path was not found.
SE_ERR_SHARE A sharing violation occurred.
ziplj 2009-08-21
  • 打赏
  • 举报
回复
... 你想表达什么
雪影 2009-08-21
  • 打赏
  • 举报
回复
晕,你自己说话自相矛盾啊~~
shellexecute执行了几次就会启动几次,但不保证会成功启动可执行程序。
你可以查看shellexecute返回值,是什么类型错误。

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧