希望能给出主要的部分就行了 
特别是参数,我的那个参数又错误,不知道其直是多少了

解决方案 »

  1.   

    http://www.vbaspnew.com/ziyuan/w/api/49.txt
      

  2.   

    搜索了一下,找到这个贴子:
    http://search.csdn.net/Expert/topic/528/528176.xml?temp=.5120813
      

  3.   

    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 Long
    Private Sub Command2_Click()
    Unload Me
    End Sub
    Private 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
    自己对应该一下。