|
-
Oct 7th, 2006, 05:07 PM
#1
Thread Starter
Addicted Member
Dos Way
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
-
Oct 7th, 2006, 05:27 PM
#2
Re: Dos Way
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]
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
-
Oct 7th, 2006, 05:27 PM
#3
Re: Dos Way
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]
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
-
Oct 7th, 2006, 05:42 PM
#4
Thread Starter
Addicted Member
Re: Dos Way
can u try this plz ?
MsgBox GetShortPath(App.Path & "\" & App.EXEName & ".exe")
it doesn't return anything :S
-
Oct 7th, 2006, 05:44 PM
#5
Re: Dos Way
works absolutely fine for me:
C:\PROGRA~1\MICROS~4\VB98\Project1.exe
-
Oct 7th, 2006, 06:23 PM
#6
Re: Dos Way
change to this
MsgBox GetShortPath(App.Path) & "\" & App.EXEName & ".exe"
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 8th, 2006, 03:59 AM
#7
Re: Dos Way
 Originally Posted by westconn1
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|