rundll32 url.dll,FileProtocolHandler

我正在使用rundll32 url.dll,FileProtocolHandler my_file.dotxWindows下打开文件。

它适用于.docx文档,但是当我用.dotx文档(模板文档)进行尝试时,它会根据模板创build一个新的.docx文件。

就像在Windows资源pipe理器中的正常行为一样:当你双击一个.dotx模板文件时,它会根据它创build一个新的.docx文件。 如果你想打开真正的.dotx文件,你必须右键单击它,并select“打开”,而不是“新”。

问题是:如何用rundll32做同样的事情? 命令中是否有选项来强制打开底层模板而不是创build新文档?

编辑:我需要一种方法来执行它没有C函数,只是纯文本,在命令行(我使用Java来做到这一点)。

也许你可以用ShellExecute包装一个简单的C程序,传递动词OPEN。

 ShellExecute(NULL, TEXT("open"), TEXT("rundll32.exe"), TEXT("url.dll,FileProtocolHandler pathToGadget"), NULL, SW_SHOWNORMAL); 

我在这里找到了这个例子。

编辑:

既然你正在用Java来做这件事 – 你可以试试像这样的ShellExceute函数的JNI包装 (从我在Wannabe Java Rockstar上找到的例子中被屠杀)

  public static boolean execute(String file, String parameters) { Function shellExecute = Shell32.getInstance().getFunction(SHELL_EXECUTE.toString()); Int32 ret = new Int32(); shellExecute.invoke(ret, // return value new Parameter[] { new Handle(), // hWnd new Str("open"), // lpOperation new Str(file), // lpFile new Str(parameters), // lpParameters new Str(), // lpDirectory new Int32(1) // nShowCmd }); if(ret.getValue() <= 32) { System.err.println("could not execute ShellExecute: " + file + ". Return: " + ret.getValue()); } return (ret.getValue() > 32); } public static void main(String[] args) { ShellExecute.execute("rundll32.exe","url.dll,FileProtocolHandler pathToGadget" ); }