Results 1 to 2 of 2

Thread: GetShortPathName for dummies

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    1

    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?

  2. #2
    Member
    Join Date
    Nov 2006
    Posts
    50

    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
  •  



Click Here to Expand Forum to Full Width