|
-
Jun 14th, 2007, 02:25 AM
#1
Thread Starter
New Member
GetShortPathName for dummies
I'm trying to get certain sounds to play through the sndPlaySound API, but it won't play any sound that has a space in the directory path. I poked around for a solution, and apparently the GetShortPathName function is supposed to do the trick. Problem is, I have absolutely no idea how to implement it. I've been tinkering with VB for years, but never progressed beyond the simple stuff. (The sndPlaySound function came from a script I downloaded a while back.)
Where exactly is the function supposed to go, and what code do I need to put in?
-
Jun 14th, 2007, 03:02 AM
#2
Member
Re: GetShortPathName for dummies
Code:
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: http://www.allapi.net/
'E-Mail: [email protected]
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("c:\Program Files\")
End Sub
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
|