Getting Short Path Names from Long 
Author Message
 Getting Short Path Names from Long

Please Help,

I have a problem i am trying to retrieve a Short Path name from a Mapped
Network Path (resource located on Win95 OSR2 with Fat32 Partition) from a
Winnt 4.0 Computer

I have the code that retrieves that Short Path Name, the problem is that
this code only seems to only work on local Long file names when using it on
NT 4. This problem only exists on NT 4, the code works perfectly on Win95.

eg.

Win95 Box Shares c:\Test

Winnt box Maps c:\test as d:

Inside c:\test there is a folder called Program Files, so the mapped path
would be
d:\program files .... i need to retrieve the short path name which would be
d:\progra~1

This works across a win95 network , but accross Nt i dont even get a path.

If anyone knows of another API that can be used to retrieve the information,
i would love to find out.

Thankyou

Tarek



Thu, 25 May 2000 03:00:00 GMT  
 Getting Short Path Names from Long

Private Declare Function GetShortPathName Lib "kernel32" Alias
"GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As
String, ByVal cchBuffer As Long) As Long

Dim LongPath As String
Dim ShortPath As String
Dim ShortPathLength As Long
Dim BufSize As Long
Dim returnVal As Long
Dim ShortPathTemp As String * 255

BufSize = Len(ShortPathTemp)
LongPath = "c:\Program Files"

ShortPathLength = GetShortPathName(LongPath, ShortPathTemp, BufSize)

ShortPath = Left$(ShortPathTemp, ShortPathLength)

If you have any questions about this code, please feel free to e-mail.

--

Kim Dobranski
Software Engineer
Hansen Software Development Corp.
http://www.HansenSoftware.com

British Columbia
Canada

Super, Natural British Columbia.
********************************
E-mail:

********************************

Quote:

>Please Help,

>I have a problem i am trying to retrieve a Short Path name from a Mapped
>Network Path (resource located on Win95 OSR2 with Fat32 Partition) from a
>Winnt 4.0 Computer

>I have the code that retrieves that Short Path Name, the problem is that
>this code only seems to only work on local Long file names when using it on
>NT 4. This problem only exists on NT 4, the code works perfectly on Win95.

>eg.

>Win95 Box Shares c:\Test

>Winnt box Maps c:\test as d:

>Inside c:\test there is a folder called Program Files, so the mapped path
>would be
>d:\program files .... i need to retrieve the short path name which would be
>d:\progra~1

>This works across a win95 network , but accross Nt i dont even get a path.

>If anyone knows of another API that can be used to retrieve the
information,
>i would love to find out.

>Thankyou

>Tarek



Thu, 25 May 2000 03:00:00 GMT  
 Getting Short Path Names from Long

I thank you for the code you have provided ... but it does not work across
Win95 --> winnt Network .... the windows nt computer returns nothing.

kim i thank you for your support ... but i have the same sort of code in use
already.... my problem is that this code does not work accross the network
.... the code will give you c:\progra~1 ....... this works across Windows 95
computers on a network, but seems to return nothing across a Windows NT and
Windows 95 network.
I am dumbfounded...... please help...
If you have a win95 computer with fat32 connected to a Win NT server, share
a folder on a win95 computer ... mapp the drive on Nt and run the code .....
it will fail.
Thank you
Tarek


Quote:
>Private Declare Function GetShortPathName Lib "kernel32" Alias
>"GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As
>String, ByVal cchBuffer As Long) As Long

>Dim LongPath As String
>Dim ShortPath As String
>Dim ShortPathLength As Long
>Dim BufSize As Long
>Dim returnVal As Long
>Dim ShortPathTemp As String * 255

>BufSize = Len(ShortPathTemp)
>LongPath = "c:\Program Files"

>ShortPathLength = GetShortPathName(LongPath, ShortPathTemp, BufSize)

>ShortPath = Left$(ShortPathTemp, ShortPathLength)

>If you have any questions about this code, please feel free to e-mail.

>--

>Kim Dobranski
>Software Engineer
>Hansen Software Development Corp.
>http://www.HansenSoftware.com

>British Columbia
>Canada

>Super, Natural British Columbia.
>********************************
>E-mail:

>********************************


>>Please Help,

>>I have a problem i am trying to retrieve a Short Path name from a Mapped
>>Network Path (resource located on Win95 OSR2 with Fat32 Partition) from a
>>Winnt 4.0 Computer

>>I have the code that retrieves that Short Path Name, the problem is that
>>this code only seems to only work on local Long file names when using it
on
>>NT 4. This problem only exists on NT 4, the code works perfectly on Win95.

>>eg.

>>Win95 Box Shares c:\Test

>>Winnt box Maps c:\test as d:

>>Inside c:\test there is a folder called Program Files, so the mapped path
>>would be
>>d:\program files .... i need to retrieve the short path name which would
be
>>d:\progra~1

>>This works across a win95 network , but accross Nt i dont even get a path.

>>If anyone knows of another API that can be used to retrieve the
>information,
>>i would love to find out.

>>Thankyou

>>Tarek



Fri, 26 May 2000 03:00:00 GMT  
 Getting Short Path Names from Long

Tarek,

You may want to look at Brad Martinez's undoc shell example on his web site
at:

http://members.aol.com/btmtz/vb/index.htm

I believe that it has some functions that might help - you might want to
talk to Brad and see what ideas he has.

Jeremy Adams

CCRP: http://www.zeode-sd.com/ccrp

Quote:

>I thank you for the code you have provided ... but it does not work across
>Win95 --> winnt Network .... the windows nt computer returns nothing.

>kim i thank you for your support ... but i have the same sort of code in
use
>already.... my problem is that this code does not work accross the network
>.... the code will give you c:\progra~1 ....... this works across Windows
95
>computers on a network, but seems to return nothing across a Windows NT and
>Windows 95 network.
>I am dumbfounded...... please help...
>If you have a win95 computer with fat32 connected to a Win NT server, share
>a folder on a win95 computer ... mapp the drive on Nt and run the code
.....
>it will fail.
>Thank you
>Tarek



>>Private Declare Function GetShortPathName Lib "kernel32" Alias
>>"GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As
>>String, ByVal cchBuffer As Long) As Long

>>Dim LongPath As String
>>Dim ShortPath As String
>>Dim ShortPathLength As Long
>>Dim BufSize As Long
>>Dim returnVal As Long
>>Dim ShortPathTemp As String * 255

>>BufSize = Len(ShortPathTemp)
>>LongPath = "c:\Program Files"

>>ShortPathLength = GetShortPathName(LongPath, ShortPathTemp, BufSize)

>>ShortPath = Left$(ShortPathTemp, ShortPathLength)

>>If you have any questions about this code, please feel free to e-mail.

>>--

>>Kim Dobranski
>>Software Engineer
>>Hansen Software Development Corp.
>>http://www.HansenSoftware.com

>>British Columbia
>>Canada

>>Super, Natural British Columbia.
>>********************************
>>E-mail:

>>********************************


>>>Please Help,

>>>I have a problem i am trying to retrieve a Short Path name from a Mapped
>>>Network Path (resource located on Win95 OSR2 with Fat32 Partition) from a
>>>Winnt 4.0 Computer

>>>I have the code that retrieves that Short Path Name, the problem is that
>>>this code only seems to only work on local Long file names when using it
>on
>>>NT 4. This problem only exists on NT 4, the code works perfectly on
Win95.

>>>eg.

>>>Win95 Box Shares c:\Test

>>>Winnt box Maps c:\test as d:

>>>Inside c:\test there is a folder called Program Files, so the mapped path
>>>would be
>>>d:\program files .... i need to retrieve the short path name which would
>be
>>>d:\progra~1

>>>This works across a win95 network , but accross Nt i dont even get a
path.

>>>If anyone knows of another API that can be used to retrieve the
>>information,
>>>i would love to find out.

>>>Thankyou

>>>Tarek



Fri, 26 May 2000 03:00:00 GMT  
 Getting Short Path Names from Long

I don't know much about these functions and whether they work on 95 and NT, but
the type WIN32_FIND_DATA gives the short name as variable cAlternate.

Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal
lpFileName As String, _
                    lpFindFileData As WIN32_FIND_DATA) As Long
Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal
hFindFile As Long, _
                    lpFindFileData As WIN32_FIND_DATA) As Long
Type WIN32_FIND_DATA
        dwFileAttributes As Long
        ftCreationTime As FILETIME
        ftLastAccessTime As FILETIME
        ftLastWriteTime As FILETIME
        nFileSizeHigh As Long
        nFileSizeLow As Long
        dwReserved0 As Long
        dwReserved1 As Long
        cFileName As String * max_path
        cAlternate As String * 14
End Type

Art.



Fri, 26 May 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Getting Short Path Names from Long

2. Getting Short Path Names from Long

3. Getting short file name from long file name:

4. Change long path name to short pathname

5. Getting short file names instead of long filenames?

6. Getting Long file names from short

7. Changing Long Paths to Short Paths in a 16-bit App

8. Getting DOS 8.3 path from Windows long file name

9. App.Path only returning short path name - Why?

10. app.path only returns short path name

11. App.Path returns "short" path name

12. Get long file name from short file name

 

 
Powered by phpBB® Forum Software