网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

vb.net获得扩展名,扩展名vbp

vb.net,知道一个文件的扩展名,如何获得该类型文件的默认打开程序。

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

vb.net,知道一个文件的扩展名,如何通过这个扩展名获得该文件的默认打开方式(即默认打开程序)?

如没有现存的办法的话只能读取注册表,以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\")

vb.net从文件路径中获取文件名

获取方法,参考实例如下:

'获取路径名各部分: 如: 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
URL链接:http://bjjierui.cn/article/dsipgie.html

其他资讯