See the image -- when using short names to File.GetShortName() I'm getting garbage...
Professional Software Development Tools
See the image -- when using short names to File.GetShortName() I'm getting garbage...
(Click here to contact me)
Providing Independent Professional Consulting Services for
IndigoRose products, World Wide.
Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)
god d.a.m man, how short do you want that path
if using the API direct it works ok, so its an AMS bug for sure, and i guess bugs need fixing
here, try THIS air code
Code:function GetShortPath(sPath) local _LongPath = Memory.Allocate(1024); local _ShortPath = Memory.Allocate(1024); Memory.PutString(_LongPath, sPath, -1, "Ascii"); local ret = DLL.CallFunction("Kernel32.dll", "GetShortPathNameA", _LongPath..",".._ShortPath..",1024", DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL); local sShortPath = Memory.GetString(_ShortPath, -1, "Ascii"); Memory.Free(_LongPath); Memory.Free(_ShortPath); return sShortPath end sLong="C:\\Users\\Dean\\Documents\\Battlefield Heroes\\PersistentStorage.dat" sShort=GetShortPath(sLong) Dialog.Message("Notice", sShort); Dialog.Message("Notice", GetShortPath(sShort));
Open your eyes to Narcissism, Don't let her destroy your life!!
It's not that I need it shorter, it's that I wanted to ensure it was short.Calling the API yields expected results "untouched".
(Click here to contact me)
Providing Independent Professional Consulting Services for
IndigoRose products, World Wide.
Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)
The problem is caused by the fact the API call that is used is "GetShortPathName" which requires that the file exist at the location in order to get its short path name. I'm assuming in your test it did not, and I have confirmed that it does work in both cases if it exists.
The problems on our end that will be fixed were that we were not returning an empty string on failure and the help did not reflect this information. These will be updated.
me too, i dident test it before now, i just took it for granted it dident work (that will teach me)and I have confirmed that it does work in both cases if it exists.
Josh, i just tried the below code, with a file that does exist
and the result wasCode:sLong="C:\\Users\\Dean\\Documents\\Battlefield Heroes\\PersistentStorage.dat" sShort=File.GetShortName(sLong); Debug.Print(sShort.."\r\n"); Debug.Print(File.GetShortName(sShort).."\r\n");
so in my test it returns exactly the same as the API callCode:C:\Users\Dean\DOCUME~1\BATTLE~1\PERSIS~1.DAT C:\Users\Dean\DOCUME~1\BATTLE~1\PERSIS~1.DAT
and if its a file that does not exist, then its garbage like you said (maybe junk from the memory buffer), the API call tho returns a blank stringCode:C:\Users\Dean\DOCUME~1\BATTLE~1\PERSIS~1.DAT C:\Users\Dean\DOCUME~1\BATTLE~1\PERSIS~1.DAT
Open your eyes to Narcissism, Don't let her destroy your life!!