I have this path C:\Documents and Settings\System Administrator
as u know dos reads it in this way C:\Docume~1\System~1>
how can I let my application read the path in the dos way using app.path
thanks
Printable View
I have this path C:\Documents and Settings\System Administrator
as u know dos reads it in this way C:\Docume~1\System~1>
how can I let my application read the path in the dos way using app.path
thanks
VB Code:
Option Explicit Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long Public Function GetShortPath(strFileName As String) As String 'KPD-Team 1999 'URL: [url]http://www.allapi.net/[/url] 'E-Mail: [email][email protected][/email] Dim lngRes As Long, strPath As String 'Create a buffer strPath = String$(165, 0) 'retrieve the short pathname lngRes = GetShortPathName(strFileName, strPath, 164) 'remove all unnecessary chr$(0)'s GetShortPath = Left$(strPath, lngRes) End Function Private Sub Form_Load() MsgBox GetShortPath(App.Path) End Sub
so is your question that you want to convert App.Path into the short path version? if so:VB Code:
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" ( _ ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long Private Function GetShortPath(strFileName As String) As String 'KPD-Team 1999 'URL: [url]http://www.allapi.net/[/url] 'E-Mail: [email][email protected][/email] Dim lngRes As Long, strPath As String 'Create a buffer strPath = String$(165, 0) 'retrieve the short pathname lngRes = GetShortPathName(strFileName, strPath, 164) 'remove all unnecessary chr$(0)'s GetShortPath = Left$(strPath, lngRes) End Function Private Sub Form_Load() MsgBox GetShortPath(App.Path) End Sub
can u try this plz ?
MsgBox GetShortPath(App.Path & "\" & App.EXEName & ".exe")
it doesn't return anything :S
works absolutely fine for me:
C:\PROGRA~1\MICROS~4\VB98\Project1.exe
change to this
MsgBox GetShortPath(App.Path) & "\" & App.EXEName & ".exe"
no don't do that as the exe name may also need to be shortened.Quote:
Originally Posted by westconn1