答案 0 :(得分:6)
documented way表示该对话框将使用openas动词。
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED|COINIT_DISABLE_OLE1DDE);
SHELLEXECUTEINFO sei = { sizeof(sei) };
sei.fMask = SEE_MASK_NOASYNC;
sei.nShow = SW_SHOWNORMAL;
sei.lpVerb = "openas";
sei.lpFile = "C:\\yourfile.ext";
ShellExecuteEx(&sei);
如果你在HKEY_CLASSES_ROOT\Unknown\shell\openas
下检查,你会发现这与在shell32中调用(未记录的)OpenAs_RunDLL导出相同。
答案 1 :(得分:1)
执行RUNDLL32 Shell32,OpenAs_RunDLL path/to/file/to/open
答案 2 :(得分:0)
只是不要使用显式动词。使用特定的动词,例如' open'是一个很大的错误:
简单地将NULL作为动词传递是一种更正确的方法。系统将自动选择最合适的动词:
换句话说,简单
ShellExecute(0, NULL, 'C:\MyFile.StrangeExt', ...);
将显示"打开"对话框。
如果您需要特定操作,请仅使用特定动词。例如。 ' print','探索',' runas'。否则 - 只传递nil。
答案 3 :(得分:-1)
go with foolowing code you will get your solution-
public const uint SEE_MASK_INVOKEIDLIST = 12;//add this line in your code
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED|COINIT_DISABLE_OLE1DDE);
SHELLEXECUTEINFO sei = { sizeof(sei) };
sei.nShow = SW_SHOWNORMAL;
sei.lpVerb = "openas";
sei.lpFile = "C:\\yourfile.ext";
sei.lfmask= SEE_MASK_INVOKEIDLIST;//add this line in your code
ShellExecuteEx(&sei);
SEE_MASK_INVOKEIDLIST this variable set "Verb" from presented system registry.