Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8221561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:58:09+00:00 2026-06-07T13:58:09+00:00

I have a path in short version or in DOS format ( C:/DOCUME~1 e.g)

  • 0

I have a path in short version or in DOS format (“C:/DOCUME~1” e.g) and want to get the full path/long path of it (“C:/Documents And Settings” e.g).

I tried GetLongPathName api. It WORKED. But when deal with unicode filename it turns out failure.

Private Declare Function GetLongPathName Lib "kernel32" Alias _
    "GetLongPathNameA" (ByVal lpszShortPath As String, _
    ByVal lpszLongPath As String, ByVal cchBuffer As Long) As Long

I tried to alias GetLongPathNameW instead but it seems do nothing, for BOTH Unicode and non-Unicode filename, always return 0. In MSDN there’s only article about GetLongPathNameW for C/C++, not any for VB/VBA. May I do something wrong?

Is there any solution for this case? I spend hours on Google and StackOverflow but can’t find out.

Regards,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T13:58:10+00:00Added an answer on June 7, 2026 at 1:58 pm

    Does this work for you? I’ve converted the file path to short path name then converted it back again which gives the correct string even when unicode (eg C:/Tö+)

    Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" _
        (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long
    Private Declare Function GetLongPathName Lib "kernel32" Alias "GetLongPathNameA" _
        (ByVal lpszShortPath As String, ByVal lpszLongPath As String, ByVal cchBuffer As Long) As Long
    
    Public Function GetShortPath(ByVal strFileName As String) As String
        'KPD-Team 1999
        'URL: [url]http://www.allapi.net/[/url]
        'E-Mail: [email]KPDTeam@Allapi.net[/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
    
    Public Function GetLongPath(ByVal strFileName As String) As String
        Dim lngRes As Long, strPath As String
        'Create a buffer
        strPath = String$(165, 0)
        'retrieve the long pathname
        lngRes = GetLongPathName(strFileName, strPath, 164)
        'remove all unnecessary chr$(0)'s
        GetLongPath = Left$(strPath, lngRes)
    End Function
    
    Private Sub Test()
        shortpath = GetShortPath("C:/Documents And Settings")
    
        Longpath = GetLongPath(shortpath)
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 path objects in my android code.I have tried all the way
I have a path and I want to list the subdirectories under it, where
I have a path + filename that contains [] several times. What i want
Short version: I have an MSBuild project that imports another project. There is a
Short version: can you help me fill in this code? var conkeror_settings_dir = ".conkeror.mozdev.org/settings";
Short Version: I have 7 SSISDeploymentManifest files I need to run. Is there a
I've updated active_admin to version 0.3.0 to get internationalization working. But I have problems
The short version : How do I get JBPM5 Rule Nodes to use a
I need to change the old Win98 short path names to long path names.
I have a Path (a star figure): <Path x:Name=NiceStar StrokeThickness=10 Stroke=#ff000000 StrokeMiterLimit=1 Data=F1 M

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.