dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Aug 4, 1997

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Long File Names Can Be Confusing

If you want to open Paint with a file from your application, it's better to convert the path of the file you want to open from long to short names. Doing so is wise because in some situations-if your path contains spaces, for example-Paint may refuse to work properly. Before passing a file name to Paint, convert it to short names with this routine, which takes advantage of the Win32 API:
 
Declare Function GetShortPathName Lib "kernel32" Alias _
	"GetShortPathNameA" (ByVal lpszLongPath As String, _
	ByVal lpszShortPath As String, _
	ByVal cchBuffer As Long) As Long

Function ShortName(LongPath As String) As String
	Dim ShortPath As String
	Const MAX_PATH = 260
	Dim ret&
	ShortPath = Space$(MAX_PATH)
	ret& = GetShortPathName(LongPath, ShortPath, MAX_PATH)
	If ret& Then
		ShortName = Left$(ShortPath, ret&)
	End If
End Function
This trick may prove useful with any application you pass file names to. It would be smart to try passing "strange" file names/paths to make sure.
Andrea Nagar
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date