使用vb.net创建文件关联 [英] Creating a file association with vb.net

查看:98
本文介绍了使用vb.net创建文件关联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在vb.net中创建一个程序,我想将我的应用程序设置为给定文件扩展名的默认应用程序,例如.txt.

我该怎么做?

解决方案

我找到了一种通过vb.net关联文件的简单方法(来自CodeProject,链接:

I am creating a program in vb.net, and I want to set my application as the default application for a given file extension - for example, .txt.

How can I accomplish this?

解决方案

I found a simple way to associate files by vb.net (from CodeProject, link: http://www.codeproject.com/Articles/18594/File-Association-in-VB-NET)

The code is:

My.Computer.Registry.ClassesRoot.CreateSubKey(".rtf").SetValue("", "Rich Text File", Microsoft.Win32.RegistryValueKind.String)
    My.Computer.Registry.ClassesRoot.CreateSubKey("Rich Text File\shell\open\command").SetValue("", Application.ExecutablePath & " ""%l"" ", Microsoft.Win32.RegistryValueKind.String)

这篇关于使用vb.net创建文件关联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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