rundll32 url.dll,FileProtocolHandler [英] rundll32 url.dll,FileProtocolHandler
问题描述
我正在使用rundll32 url.dll,FileProtocolHandler my_file.dotx
在Windows下打开文件.
I'm using rundll32 url.dll,FileProtocolHandler my_file.dotx
to open files under Windows.
它对.docx文档工作正常,但是当我对.dotx文档(模板文档)进行尝试时,它会基于模板创建一个新的.docx.
It works fine with .docx documents, but when I try it with .dotx documents (template documents), it creates a new .docx based on the template.
就像Windows资源管理器中的正常行为:双击.dotx模板文件时,它会基于它创建一个新的.docx文件.如果要打开真实的.dotx文件,则必须右键单击它,然后选择打开"而不是新建".
Just as the normal behavior in the windows explorer : when you double-click on a .dotx template file, it creates a new .docx file based on it. If you want to open the real .dotx file, you have to right-click on it and select "open" instead of "new".
问题是:如何对rundll32进行相同处理?该命令中是否有一个选项可以强制打开基础模板而不是创建新文档?
Question is: how to do the same with rundll32? Is there an option in the command to force the opening of the underlying template instead of creating a new document?
我需要一种在命令行中不使用C函数,仅使用纯文本的方式来实现它(我使用Java来做到这一点.)
I need a way to do it without C functions, just plain text, in the command line (I'm using Java to do it).
推荐答案
Maybe you can wrap a simple C program around ShellExecute, passing the verb OPEN.
ShellExecute(NULL, TEXT("open"),
TEXT("rundll32.exe"), TEXT("url.dll,FileProtocolHandler pathToGadget"),
NULL, SW_SHOWNORMAL);
我在此处找到了这个示例.
由于您使用Java进行此操作-您可以尝试ShellExceute函数的 JNI包装像这样(来自我在Wannabe Java Rockstar上发现并被屠杀的示例)
Since you're doing this in Java - you could try a JNI wrapping of the ShellExceute function like this (from the example I found on The Wannabe Java Rockstar and butchered)
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" );
}
这篇关于rundll32 url.dll,FileProtocolHandler的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!