假设我有一个a.txt文件,我想在双击的时候用自己写的程序打开它,要怎么做?
高手可不可以写个例子,谢谢拉。
高手可不可以写个例子,谢谢拉。
解决方案 »
- 招VB程序员-3个月的项目
- Scroll 中现显 Picture ..
- VB中能调用FLASH编的文件(.SWF)吗?
- 急急!!!如何实现这个功能???
- 水晶报表9.0用installsheild打包问题(cr9rdcmergemodules.zip解压后的*.msm文件引入到installsheild中)
- 如果打开的文件有几十M的话,那么怎样是速度不是处理的太慢?
- VB有延时的函数吗
- 为什么我的VB工程类型只有四种?
- 100分奉送!各位同仁,你们在公司的做软件提成有多少?
- 请问:在VB6中如何实现对FILESYSTEMOBJECT的引用?谢谢!
- VB中如何备份access?
- sqldmo.dll注册问题
那么对于的文件就用你自己的程序来打开了
在vb中不知道有没有
你说的是打开方式用自己写的程序吧?但那样的话只会运行程序,.txt里的内容不会显示啊。
还请明示啊!要改哪些地方?怎么改?假设我的程序叫Text.exe。
@="txtfile"[HKEY_CLASSES_ROOT\txtfile]
@="文本文档"[HKEY_CLASSES_ROOT\txtfile\shell][HKEY_CLASSES_ROOT\txtfile\shell\open][HKEY_CLASSES_ROOT\txtfile\shell\open\command]
@=c:\test.exe %1保存为 a.reg ,双击运行导入。
将你的程序放在 c:\, 在form_load 里面写着: msgbox command$
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_CURRENT_CONFIG = &H80000004
Private Const REG_SZ = 1 ' Unicode nul terminated string
Private Const REG_NONE = 0 ' No value type
Private Const REG_EXPAND_SZ = 2 ' Unicode nul terminated string
Private Const REG_BINARY = 3 ' Free form binary
Private Const REG_DWORD = 4 ' 32-bit number
Private Const REG_DWORD_BIG_ENDIAN = 5 ' 32-bit number
Private Const REG_MULTI_SZ = 7
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hkey As Long) As Long
Private Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hkey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As LongPrivate Sub Command2_Click()
Unload Me
End SubPrivate Sub Form_Load()
Command1.Caption = "建立关联"
Command2.Caption = "退出"
Label1.Caption = "扩展名"
Label2.Caption = "默认值"
Label3.Caption = "类型描述"
Label4.Caption = "shell"
Label5.Caption = "打开命令"
Label6.Caption = "打印命令"
Label7.Caption = "文件图标"
Text1.Text = ".abc"
Text3.Text = "abc源文件"
Text2.Text = "abcfile"
Text4.Text = "open"
Text5.Text = "c:\windows\notepad.exe %1"
Text6.Text = "c:\windows\notepad.exe /p %1"
Text7.Text = "D:\自编程序\系统信息\wmp.ico"
End Sub
Private Sub Command1_Click()
Dim hkey As Long
hkey = HKEY_CLASSES_ROOT
RegSetValue hkey, Text1.Text, REG_SZ, Text2.Text, 7
RegSetValue hkey, Text2.Text, REG_SZ, Text3.Text, 9
RegSetValue hkey, Text2.Text & "\" & "shell", REG_SZ, Text4.Text, 5
RegSetValue hkey, Text2.Text & "\" & "shell\open\command", REG_SZ, Text5.Text, Len(StrConv(Text5.Text, vbFromUnicode)) + 1
RegSetValue hkey, Text2.Text & "\" & "shell\print\command", REG_SZ, Text6.Text, Len(StrConv(Text6.Text, vbFromUnicode)) + 1
RegSetValue hkey, Text2.Text & "\" & "defaulticon", REG_SZ, Text7.Text, Len(StrConv(Text5.Text, vbFromUnicode)) + 1
MsgBox ""
RegCloseKey hkey
End Sub