有空格的话,可以先得到他的短文件名再注册可以这样,先做个小工具,窗体上先放1个按钮和1个textbox Option ExplicitPrivate Declare Function GetShortPathName Lib "kernel32" _ Alias "GetShortPathNameA" (ByVal lpszLongPath As String, _ ByVal lpszShortPath As String, ByVal cchBuffer As Long) As LongPrivate Function GetShortName(ByVal sLongFileName As String) As String Dim lRetVal As Long, sShortPathName As String, iLen As Integer 'Set up buffer area for API function call return sShortPathName = Space(255) iLen = Len(sShortPathName) 'Call the function lRetVal = GetShortPathName(sLongFileName, sShortPathName, iLen) 'Strip away unwanted characters. GetShortName = Left(sShortPathName, lRetVal) End Function Private Sub Command1_Click()Text1.Text = GetShortName(Text1.Text)End Sub运行,在textbox中输入控件的完整路径,点按钮,会在textbox中得到短文件名,然后复制它,注册控件即可
Option ExplicitPrivate Declare Function GetShortPathName Lib "kernel32" _
Alias "GetShortPathNameA" (ByVal lpszLongPath As String, _
ByVal lpszShortPath As String, ByVal cchBuffer As Long) As LongPrivate Function GetShortName(ByVal sLongFileName As String) As String
Dim lRetVal As Long, sShortPathName As String, iLen As Integer
'Set up buffer area for API function call return
sShortPathName = Space(255)
iLen = Len(sShortPathName) 'Call the function
lRetVal = GetShortPathName(sLongFileName, sShortPathName, iLen)
'Strip away unwanted characters.
GetShortName = Left(sShortPathName, lRetVal)
End Function
Private Sub Command1_Click()Text1.Text = GetShortName(Text1.Text)End Sub运行,在textbox中输入控件的完整路径,点按钮,会在textbox中得到短文件名,然后复制它,注册控件即可
路径两边加上双引号试试