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
网站栏目:vb.net获得扩展名,扩展名vbp
文章转载:https://www.cdcxhl.com/article4/dsipgie.html
成都网站建设公司_创新互联,为您提供网页设计公司、关键词优化、搜索引擎优化、移动网站建设、全网营销推广、动态网站
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联