如何通过自定义url将参数传递给应用程序 [英] How to pass argument through custom url to an application

查看:319
本文介绍了如何通过自定义url将参数传递给应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Windows 7
,我想通过自定义url打开文件名作为参数
我点击了链接 http:// msdn.microsoft.com/zh-cn/library/aa767914(v=vs.85).aspx

I am using windows 7 I want to pass filename as argument which I want to open through custom url. I followed link http://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx

我的python代码是:

My python code is:

import os,sys
selectedFileName=(sys.argv)[1]
os.startfile(selectedFileName)

我的注册表设置是:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\cultest]
@="\"URL:cultest Protocol\""
"URL Protocol"="\"\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\cultest\DefaultIcon]


[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\cultest\shell]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\cultest\shell\open]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\cultest\shell\open\command]
@="\"D:\\Test\\argument\\dist\\cultest.exe\" \"%1\""

我输入webbrowser / mozila / explorer。
我尝试了cultest: C:/Users/liverpool/Desktop/Hostname.txt,但它不起作用C:/Users/liverpool/Desktop/Hostname.txt是文件名

So which url I type in webbrowser/mozila/explorer. I tried with cultest:"C:/Users/liverpool/Desktop/Hostname.txt" but it didn't work C:/Users/liverpool/Desktop/Hostname.txt is the file name

推荐答案

您的注册表代码和屏幕截图不同: cultest.exe和 curlargu.exe。

Your registry code and screenprint are not the same: 'cultest.exe' and 'curlargu.exe'.

您已经使用了HKEY_LOCAL_MACHINE而不是HKEY_CLASSES_ROOT。他们指向相同的地方,但可能有所不同。如果cultest.exe是您提到的文件夹中的程序,则此注册表代码应该起作用。您的浏览器URL调用是正确的。

And you have used the HKEY_LOCAL_MACHINE instead of HKEY_CLASSES_ROOT. They point to the same, but it might make a difference. If cultest.exe is your program in the mentioned folder, then this registry code should work. Your browser URL call is correct.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\cultest]
@="URL:cultest Protocol"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\cultest\DefaultIcon]
@="D:\\Test\\argument\\dist\\cultest.exe,0"

[HKEY_CLASSES_ROOT\cultest\shell]

[HKEY_CLASSES_ROOT\cultest\shell\open]

[HKEY_CLASSES_ROOT\cultest\shell\open\command]
@="D:\\Test\\argument\\dist\\cultest.exe \"%1\""

我今天为自己的程序使用了相同的REG文件,并且该文件正在运行。我注意到斜杠之间有一些细微的差别...

I used the same REG-file today for my own program and it is working. I noticed some minor differences in the slashes...

这篇关于如何通过自定义url将参数传递给应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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