Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > Access数据库-模块/函数/VBA

返回长文件名的短文件名函数

时 间:2004-11-18 00:00:00
作 者:黄海   ID:32  城市:苏州
摘 要:返回长文件名的短文件名函数 
正 文:

如我们在使用REGSVR32.exe注册控件时,如果这个控件的路径中有空格或者文件名太长,就会注册不成功,因为REGSVR32.exe不支持长文件名,下面的函数就是解决这样的类似的问题
' 例如
' ? getShortPath("C:\Documents and Settings\Administrator\桌面\")
' C:\DOCUME~1\ADMINI~1\桌面\

'------------------------------------------------------------

Option Compare Database
Option Explicit

Private Declare Function GetShortPathName32 Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long

Public Function getShortPath(ByVal strFullPath As String) As String

    Dim strShortPath As String

    strShortPath = Space(256)
    GetShortPathName32 strFullPath, strShortPath, 256
    strShortPath = Left(strShortPath, InStr(strShortPath, Chr(0)) - 1)
    getShortPath = strShortPath

End Function



Access软件网官方交流QQ群 (群号:483923997)       Access源码网店

常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助