新网创想网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
Public Function GetTypeFilePath(ByVal mType As String)
创新互联建站专注为客户提供全方位的互联网综合服务,包含不限于做网站、成都网站设计、河北网络推广、小程序定制开发、河北网络营销、河北企业策划、河北品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联建站为所有大学生创业者提供河北建站搭建服务,24小时服务热线:028-86922220,官方网址:www.cdcxhl.com
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
如没有现存的办法的话只能读取注册表,以txt文件为类:
HKEY_CLASSES_ROOT\.txt '在这个地址有个默认属性值是:txtfile
HKEY_CLASSES_ROOT\txtfile\shell\open\command '这里的默认属性值txtfile的关联程序:%SystemRoot%\system32\NOTEPAD.EXE %1
我暂不了解vb.net读注册表函数(刚在学),以vbs为类:
Dim WshShell
Set WshShell = WScript.CreateObject("Wscript.Shell")
Dim Ext
ext= WshShell.RegRead ("HKEY_CLASSES_ROOT\.mp3\") '这里的扩展名.mp3可以改成其它的看看
MsgBox WshShell.RegRead ("HKEY_CLASSES_ROOT\" ext "\shell\open\command\")
获取方法,参考实例如下:
'获取路径名各部分: 如: c:\dir1001\aaa.txt
'获取路径路径 c:\dir1001\
Public Function GetFileName(FilePathFileName As String) As String '获取文件名 aaa.txt
On Error Resume Next
Dim i As Integer, J As Integer
i Len(FilePathFileName)
J InStrRev(FilePathFileName, "\")
GetFileName Mid(FilePathFileName, J + 1, i)
End Function
''获取路径路径 c:\dir1001\
Public Function GetFilePath(FilePathFileName As String) As String '获取路径路径 c:\dir1001\
On Error Resume Next
Dim J As Integer
J InStrRev(FilePathFileName, "\")
GetFilePath Mid(FilePathFileName, 1, J)
End Function
'获取文件名但不包括扩展名 aaa
Public Function GetFileNameNoExt(FilePathFileName As String) As String '获取文件名但不包括扩展名 aaa
On Error Resume Next
Dim i As Integer, J As Integer, k As Integer
i Len(FilePathFileName)
J InStrRev(FilePathFileName, "\")
k InStrRev(FilePathFileName, ".")
If k 0 Then
GetFileNameNoExt Mid(FilePathFileName, J + 1, i - J)
Else
GetFileNameNoExt Mid(FilePathFileName, J + 1, k - J - 1)
End If
End Function
'===== '获取扩展名 .txt
Public Function GetFileExtName(FilePathFileName As String) As String '获取扩展名 .txt
On Error Resume Next
Dim i As Integer, J As Integer
i Len(FilePathFileName)
J InStrRev(FilePathFileName, ".")
If J 0 Then
GetFileExtName ".txt"
Else
GetFileExtName Mid(FilePathFileName, J, i)
End If
End Function