Loading ...
Sorry, an error occurred while loading the content.

AW: [libertybasic] Directory Short Name

Expand Messages
  • pendl2megabit
    Message 1 of 3 , May 2, 2006
    • 0 Attachment
      > Hi All:
      > I'm trying to use the MS Directory "Program Files" in a path for
      > an ODBC32
      > call. I enclosed it in quotes but am getting problems perhaps because of
      > the space in the MS Directory name and I don't think ODBC likes
      > the quotes.
      > There is a short name for this Directory but I couldn't find it on google.
      > Anyone know it off-hand? I know there is LB code to get short names (I'm
      > not sure if that is even what I'm looking for) but if it is I can
      > try that
      > route.
      > Rick

      the prefered way to get the short form of a path is using the API function


      '---code start
      filedialog "Select a file", DefaultDir$ + "\*.*", FileName$

      if FileName$ <> "" then
      print "Long Filename: "; FileName$
      print "Short Filename: "; GetShortPathName$(FileName$)
      end if

      print "Finished ..."

      function GetShortPathName$(lpszLongPath$)
      lpszLongPath$ = lpszLongPath$ + chr$(0)
      cchBuffer = _MAX_PATH + 1

      lpszShortPath$ = space$(cchBuffer) + chr$(0)

      calldll #kernel32, "GetShortPathNameA", _
      lpszLongPath$ as ptr, _
      lpszShortPath$ as ptr, _
      cchBuffer as ulong, _
      result as ulong

      select case
      case result = 0
      GetShortPathName$ = "ERROR encountered!"
      case result > cchBuffer
      cchBuffer = result
      goto [retryGetShortPathName]
      case else
      GetShortPathName$ = trim$(lpszShortPath$)
      end select
      end function
      '---code end

      Stefan Pendl

      Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de
    Your message has been successfully submitted and would be delivered to recipients shortly.