vb.net,知道一个文件的扩展名,如何获得该类型文件的默认打开程序。
vb.net,从系统中获得某个文件类型的默认打开程序。例如.rar,获得默认打开程序为d:\ProgramFiles\winrar\winrar.exe例如.docx,获...
vb.net,从系统中获得某个文件类型的默认打开程序。
例如.rar,获得默认打开程序为d:\Program Files\winrar\winrar.exe
例如.docx,获得默认打开程序为"C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.EXE"
要具体代码,不要思路,谢谢 展开
例如.rar,获得默认打开程序为d:\Program Files\winrar\winrar.exe
例如.docx,获得默认打开程序为"C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.EXE"
要具体代码,不要思路,谢谢 展开
1个回答
展开全部
Public Function GetTypeFilePath(ByVal mType As String)
mType = mType.Trim
If mType.Substring(0, 1) <> "." Then mType = "." & mType
Dim Key As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(mType)
Dim Result As String = ""
If Not Key Is Nothing Then
Dim SubKeyValue As Object
Dim Value As String
SubKeyValue = Key.GetValue("")
If Not SubKeyValue Is Nothing Then
Value = SubKeyValue.ToString
Dim SubKey As Microsoft.Win32.RegistryKey, ResultKey As Microsoft.Win32.RegistryKey
SubKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(Value)
If Not SubKey Is Nothing Then
ResultKey = SubKey.OpenSubKey("shell\open\command\", False)
If Not ResultKey Is Nothing Then
Result = ResultKey.GetValue("").ToString
End If
End If
End If
End If
Return Result
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询