Older Version Newer Version

Alyce Alyce Dec 29, 2011

=GetShortPathNameA= //[[user:Alyce]]// [[toc|flat]] //Some text below is copied from the Microsoft Developers Network Library.// For an eBook or printed book on using the API with Liberty BASIC, see: [[http://alycesrestaurant.com/apilb/index.htm|APIs for Liberty BASIC]] ---- =DOS 8.3 Filenames= In DOS operating systems, filenames were limited to 8 characters and extensions were limited to 3 characters. Some API functions require filenames in this format. A long filename can be converted to a short filename with **GetShortPathNameA** To learn more about 8.3 filenames: [[http://en.wikipedia.org/wiki/8.3_filename|8.3 Filenames at Wikipedia]] =Demo= [[code format="lb"]] filedialog "Open","*.*",file$ if file$="" then end 'use function with null short name argument 'first to determine size of buffer needed calldll #kernel32, "GetShortPathNameA",_ file$ as ptr,_ 'long filename _NULL as long,_ 'short filename argument, null to get length of buffer 0 as long,_ 'length of buffer, null to get length of buffer length as ulong 'required length of buffer 'create a string buffer of the correct length: shortfile$=space$(length)+chr$(0) calldll #kernel32, "GetShortPathNameA",_ file$ as ptr,_ 'long filename shortfile$ as ptr,_ 'short filename length as long,_ 'length of buffer result as ulong print "Long filename is "; file$ print "Length of buffer for short filename is ";length print "Short filename is ";shortfile$ [[code]] ---- [[toc|flat]]