c++ - 在 ShellExecute 函数中运行多个命令 (C++)

标签 c++ windows

我正在尝试运行以下行:

hRet = ShellExecute(HWND_DESKTOP,
                    L"open",
               (*)  L"C:\\...\\wmplayer.exe  C:\\...\\.mp4",       
                    NULL, 
                    NULL,
                    SW_SHOW);

但是文件(.mp4)打不开,可能是因为我在一个参数中给出了两个路径。 我还尝试运行以下命令:

(*)  L"\"C:\\...\\wmplayer.exe\"  \"C:\\...\\.mp4\""

和:

(*)  L"C:\\...\\wmplayer.exe\"  \"C:\\...\\.mp4"

但是没有用,你能帮忙吗?? 谢谢...!

最佳答案

阅读文档我会说调用应该是

hRet = ShellExecute(HWND_DESKTOP,
                    L"open",
                    L"C:\\...\\wmplayer.exe",
                    L"C:\\...\\.mp4",       
                    NULL,
                    SW_SHOW);

文档说:

lpParameters [in, optional] Type: LPCTSTR If lpFile specifies an executable file, this parameter is a pointer to a null-terminated string that specifies the parameters to be passed to the application. The format of this string is determined by the verb that is to be invoked. If lpFile specifies a document file, lpParameters should be NULL.

因此您可以直接将 .mp4 文件作为 lpFile 参数传递并保留此 NULL(但将使用默认播放器)或者您必须将播放器名称作为文件传递,将电影名称作为参数传递。

关于c++ - 在 ShellExecute 函数中运行多个命令 (C++),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20029138/

相关文章:

c++ - 为什么当我在 cpp 的初始化中指定多维数组时必须有边界

java - SpringSource Tool Suite windows 7 32 位安装程序指向错误的 JRE

java - 在 Windows 中检索登录的用户名和主机名

windows - 未经认证的 Windows 驱动程序

c++ - Boost 过程中缺少异常

c++ - 从麦克风到整数数组的音频采样(C++/Qt)

c++ - 获取内联定义的友元函数的地址

c++ - 立即模式未正确绘制 alpha 纹理

windows - 发布版本中与 OutputDebugString 相关的开销

node.js - 'npm install' 在 Windows 上非常慢