如何获得“以..打开"窗口的命令行功能? [英] How to get command line of windows "open with .." function?

查看:249
本文介绍了如何获得“以..打开"窗口的命令行功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我之前曾问过一个有关如何使Windows以...打开"应用程序列表的问题. 这是链接回答这个问题.

I previously asked a question that is about how to get windows "open with.." application list. Here's a link to that question.

我们可以使用SHAssocEnumHandlers界面获取具有特定文件扩展名的文件关联,例如.png

We can use SHAssocEnumHandlers interface to get the file association with specific file extension, ex .png

然后使用IAssocHandler并可以检索与文件类型(.png)关联的可执行文件的完整路径和文件名.例如:['Paint': 'C:\\Windows\\system32\\mspaint.exe', ...]

Then use IAssocHandler and can retrieves the full path and file name of the executable file associated with the file type(.png). ex:['Paint': 'C:\\Windows\\system32\\mspaint.exe', ...]

但是我想用给定的图像获取执行mspaint.exe的命令行. 像这样〜"%systemroot%\system32\mspaint.exe" "%1"

But I want to get the command line of executing mspaint.exe with a given image. Like this~ "%systemroot%\system32\mspaint.exe" "%1"

是否还有另一个msdn api可以帮助我们获取"open with .."命令? 我认为应该有,因为Windows XP已经具有此功能.

Is there another msdn api could help us to get the "open with.." command? I think it should have, since windows XP already have this ability.

推荐答案

使用AssocQueryString(..., ASSOCSTR_COMMAND, ...);

示例:

TCHAR commandline[1024];
DWORD size = ARRAYSIZE(commandline);
AssocQueryString(0, ASSOCSTR_COMMAND, _T(".txt"), 0, commandline, &size);

这篇关于如何获得“以..打开"窗口的命令行功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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