http://www.21code.com/codebase/?pos=down&id=195

解决方案 »

  1.   

    应该是在注册表的HKEY_CLASSES_ROOT下面建立一个后缀名的子键,然后再建立一个程序关联。查一下注册表看一个例子。
      

  2.   

    感谢您使用微软产品。首先,您需要在Windows中将您自定义文件的后缀名和和您的应用程序关联。您可以通过API写入注册表的方法实现,请参考下列代码:Private Declare Function RegCreateKey& Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey&, ByVal lpszSubKey$, lphKey&)
    Private Declare Function RegSetValue& Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hKey&, ByVal lpszSubKey$, ByVal fdwType&, ByVal lpszValue$, ByVal dwLength&)
    Private Const MAX_PATH = 256&
    Private Const REG_SZ = 1
    Private Sub Command1_Click()
           Dim sKeyName As String
           Dim sKeyValue As String
           Dim ret&
           Dim lphKey&
           sKeyName = "MyApp" 
           sKeyValue = "plafiles"
           ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)
           ret& = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&)
           sKeyName = ".pla"‘文件的扩展名
           sKeyValue = "MyApp"
           ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)
           ret& = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&)
           sKeyName = "MyApp"
           sKeyValue = "c:\Project1.exe %1" ‘设置名称
           ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)
           ret& = RegSetValue&(lphKey&, "shell\open\command", REG_SZ, sKeyValue, MAX_PATH)
    End Sub此外,您需要在程序运行中判断是否存在参数,如果存在则打开参数表示的文件,即:
    If Command() <> "" Then
    ‘打开Command表示的文件
    End IfCommand是程序运行的参数,关于Command您可以参考以下文章:
    Command Function
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbenlr98/html/vafctCommand.asp微软全球技术中心 VB技术支持
    本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
      

  3.   

    acptvb(微软全球技术中心 VB技术支持) 来了,就一定解决了