假设我有一个a.txt文件,我想在双击的时候用自己写的程序打开它,要怎么做?
高手可不可以写个例子,谢谢拉。

解决方案 »

  1.   

    在vc中,你建立工程的时候,选择相应的类型
    那么对于的文件就用你自己的程序来打开了
    在vb中不知道有没有
      

  2.   

    VB中没见过啊,我想应该要API函数来实现吧,应该用哪些API啊?等待中。
      

  3.   

    write registry use regedit.exe hk_cr\txtfile\ write default value ,data is your program path add "%1" at last
      

  4.   

    wfhlxl: 
        你说的是打开方式用自己写的程序吧?但那样的话只会运行程序,.txt里的内容不会显示啊。
      

  5.   

    tztz520(午夜逛街):
    还请明示啊!要改哪些地方?怎么改?假设我的程序叫Text.exe。
      

  6.   

    http://community.csdn.net/Expert/topic/3299/3299495.xml?temp=.8159906http://community.csdn.net/Expert/topic/3072/3072290.xml?temp=.6806757
      

  7.   

    Windows Registry Editor Version 5.00[HKEY_CLASSES_ROOT\.txt]
    @="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$
      

  8.   

    Const HKEY_CLASSES_ROOT = &H80000000
    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
      

  9.   

    you use richtext.loadfile command() in form.load