Registering an Application to a URL Protocol
来源:互联网 发布:wifi arp攻击软件 编辑:程序博客网 时间:2024/05/16 19:37
To enable an application to handle a particular URL Protocol, you must add a new key, with the appropriate keys and values, to the registry in HKEY_CLASSES_ROOT.
The new registry key must match the protocol scheme that is being added. For instance, to add a "note:" protocol, the key added to HKEY_CLASSES_ROOT should be note. Under this new key, the Default string value should be the display name of the new protocol, and the URL Protocol string value should contain either protocol-specific information or an empty string. Also under the new key, a DefaultIcon key and a shell key should be added. The Default string value under the DefaultIcon key must be the file name to use as an icon for this new URL protocol.
Under the shell key, a key using a verb (such as open) should be added. A command key and a DDEEXEC key may also be added under the key using a verb. The values under the command and DDEEXEC keys are used to call the application.
The following example shows which registry values might be added to register a new application (Notepad.exe in this example) to handle the new URL protocol.
- HKEY_CLASSES_ROOT
- note
- (Default) = "URL:Note Protocol"
- URL Protocol= ""
- DefaultIcon
- (Default) = "notepad.exe"
- shell
- open
- command
- (Default) = "C:/WINDOWS/notepad.exe" "%1"
By adding these settings to the registry, any attempts to navigate to URLs such as "note:C:/MyFile.txt" would attempt to launch Notepad to edit the file C:/MyFile.txt. However, because the URL Protocol handler passes the complete URL string to the application registered in the command, Notepad.exe would be called with the following unanticipated command line syntax:
C:/WINDOWS/notepad.exe "note:C:/MyFile.txt"
Normally, this argument format would be handled by the application that processes the request. However, because Notepad.exe cannot be changed, the protocol prefix must be trimmed from the filename before calling Notepad. The following shell command will trim the prefix from the input string, and pass the rest to Notepad.exe:
@FOR /F "tokens=1* delims=:" %%a IN ("%~1") DO start notepad.exe "%%b"
If the preceding text were saved into a batch file, C:/WINDOWS/Note.cmd for example, the following registry value would correctly launch Notepad.exe with the file specified in the URL string:
- HKEY_CLASSES_ROOT
- note
- shell
- open
- command
- (Default) = "C:/WINDOWS/note.cmd" "%1"
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1538297
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- 将应用程序注册为URL协议(Registering an Application to a URL Protocol)
- Registering an Application to a URL Protocol
- 一個主管的真情告白
- 在一个项目中管理好基础架构和开发团队
- 善始善终才能增加项目成功的机会
- 2007-11-16 日志:照片,难道真要引发血案?
- 利用存儲過程進行簡繁體轉換
- Registering an Application to a URL Protocol
- 转帖--IT圈子里鬼混---谈谈IT行业的一些生存之道!
- ERP实施 浅谈实施顾问的三大核心素质[转]
- 善始善终才能增加项目成功的机会
- 程序员,不要让自己做兔子
- IT售前应该小心的几类客户
- FastReport 4.3 最新补丁
- PM如何在项目管理中学会拒绝?
- 如何在WINDOWS下新建多个桌面并切换(函数)