一个没有人问过的问题,求解决办法 http://www.21code.com/codebase/?pos=down&id=195 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 应该是在注册表的HKEY_CLASSES_ROOT下面建立一个后缀名的子键,然后再建立一个程序关联。查一下注册表看一个例子。 感谢您使用微软产品。首先,您需要在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 = 1Private 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 Functionhttp://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)。 acptvb(微软全球技术中心 VB技术支持) 来了,就一定解决了 Byte转字符串??? VB控件inet的execute 和 openurl问题 如何知道Update是否成功 如何用VB将桌面设置为Web页? 借宝地,如何求职,请指教? 如何用VB把x,y两列数据在坐标系中画出来 (送100分) timer应用问题 在线等待:生成exe文件后如何发给朋友? 一个关于控件和动态连接库注册的问题! 今天CET6考得不好:( 导出功能谁会呢??? 如何使子窗体得活动范围不超过父窗体的范围?
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)。