具体:
声明:
      Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult 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
      ' Return codes from Registration functions.      Const ERROR_SUCCESS = 0&
      Const ERROR_BADDB = 1&
      Const ERROR_BADKEY = 2&
      Const ERROR_CANTOPEN = 3&
      Const ERROR_CANTREAD = 4&
      Const ERROR_CANTWRITE = 5&
      Const ERROR_OUTOFMEMORY = 6&
      Const ERROR_INVALID_PARAMETER = 7&
      Const ERROR_ACCESS_DENIED = 8&
      Private Const HKEY_CLASSES_ROOT = &H80000000
      Private Const MAX_PATH = 260&
      Private Const REG_SZ = 1
代码:
Private Sub AssociateFileExtension(Extension As String, PathToExecute As String, ApplicationName As String)
          
          'Extension is three letters without the "."          Dim sKeyName As String   'Holds Key Name in registry.
          Dim sKeyValue As String  'Holds Key Value in registry.
          Dim ret&           'Holds error status if any from API calls.
          Dim lphKey&        'Holds created key handle from RegCreateKey.
      'This creates a Root entry called "MyApp".
          sKeyName = ApplicationName
          sKeyValue = ApplicationName
          ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)
          ret& = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&)
      'This creates a Root entry called .BAR associated with "MyApp".
          sKeyName = "." & Extension
          sKeyValue = ApplicationName
          ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)
          ret& = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&)
      'This sets the command line for "MyApp".
          sKeyName = ApplicationName
          sKeyValue = PathToExecute & " %1"
          ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)
          ret& = RegSetValue&(lphKey&, "shell\open\command", REG_SZ, sKeyValue, MAX_PATH)
End Sub

解决方案 »

  1.   

    具体一点:
    声明:
          Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult 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
          ' Return codes from Registration functions.      Const ERROR_SUCCESS = 0&
          Const ERROR_BADDB = 1&
          Const ERROR_BADKEY = 2&
          Const ERROR_CANTOPEN = 3&
          Const ERROR_CANTREAD = 4&
          Const ERROR_CANTWRITE = 5&
          Const ERROR_OUTOFMEMORY = 6&
          Const ERROR_INVALID_PARAMETER = 7&
          Const ERROR_ACCESS_DENIED = 8&
          Private Const HKEY_CLASSES_ROOT = &H80000000
          Private Const MAX_PATH = 260&
          Private Const REG_SZ = 1
    代码:
    Private Sub AssociateFileExtension(Extension As String, PathToExecute As String, ApplicationName As String)
              
              'Extension is three letters without the "."          Dim sKeyName As String   'Holds Key Name in registry.
              Dim sKeyValue As String  'Holds Key Value in registry.
              Dim ret&           'Holds error status if any from API calls.
              Dim lphKey&        'Holds created key handle from RegCreateKey.
          'This creates a Root entry called "MyApp".
              sKeyName = ApplicationName
              sKeyValue = ApplicationName
              ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)
              ret& = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&)
          'This creates a Root entry called .BAR associated with "MyApp".
              sKeyName = "." & Extension
              sKeyValue = ApplicationName
              ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)
              ret& = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&)
          'This sets the command line for "MyApp".
              sKeyName = ApplicationName
              sKeyValue = PathToExecute & " %1"
              ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)
              ret& = RegSetValue&(lphKey&, "shell\open\command", REG_SZ, sKeyValue, MAX_PATH)
    End Sub
      

  2.   

    应该是有某个参数,我记得不大清楚了,是一个打开文件的参数,和SCR程序的那个/S什么的参数差不多。
      

  3.   

    程序启动时取得command对象中的参数.开启参数所指的文件.
      

  4.   

    不好意思,分一直给不出去,每次出现"成功给分,正在生成贴子列表页面"后就出现"http500错误",我下次再来给分吧.
      

  5.   

    后面的参数是%1
    用Command取得。
    例:
    Dim Strcmd As String
    Strcmd = Command
    If InStr(Strcmd, "%1") then
    …………………………………………
    End If
      

  6.   

    先在安装时用注册表建立关联,再在程序中用command,几年前就解决了.
      

  7.   

    关联txt
    打开时你能用
    command得到文件路径