打开一个没有“.exe"的可执行文件使用 ShellExecute 扩展 [英] Open an executable file without an ".exe" extension with ShellExecute

查看:46
本文介绍了打开一个没有“.exe"的可执行文件使用 ShellExecute 扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用 ShellExecute 打开一个没有.exe"扩展名的可执行文件.我可以使用 CreateProcess,但我更喜欢使用 ShellExecute.有什么办法吗?

I want to open an executable file that have no ".exe" extension with ShellExecute. I can use CreateProcess but I prefer to use ShellExecute. There is any way to do it?

我使用 C++ 和 win32api 函数.

I use C++ with the win32api functions.

谢谢.

推荐答案

您使用 SHELLEXECUTEINFO 结构的 lpClass 成员 说,我希望你把这个文件当作一个 EXE,即使它不是看起来像扩展程序中的一个."

You use the lpClass member of the SHELLEXECUTEINFO structure to say, "I want you to treat this file as if it were an EXE, even though it doesn't look like one from the extension."

int _tmain(int argc, _TCHAR* argv[])
{
  SHELLEXECUTEINFO sei = {0};
  sei.cbSize = sizeof(sei);
  sei.nShow = SW_SHOWNORMAL;
  sei.lpFile = TEXT("myprogram.wrongextension");
  sei.fMask = SEE_MASK_CLASSNAME;
  sei.lpVerb = TEXT("open");
  sei.lpClass = TEXT("exefile");
  ShellExecuteEx(&sei);
  return 0;
}

这篇关于打开一个没有“.exe"的可执行文件使用 ShellExecute 扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆