Forum > Windows

File paths on Windows

(1/3) > >>

This is the thing:  I made a software (a game) that saves the configuration in a file whose path and name is returned by the GetAppConfigFile function.  It works perfect on Linux but some Windows (specifically Windows 10) complains that they can't create the file.  The weird thing is that it creates the configuration directory without problems :o.

I suspect it is related with spaces and/or character enconding (String uses UTF8 but Windows disk stuff uses ASCII ISO-something-1) but I couldn't find anything about how to manage that; I know there's something because I remember reading it shomewhere.

Somebody help me!

Is you application using LCL or LazUtils (if it is a Windows GUI app built with Lazarus, then it is).
If so, then UTF8 should not be a problem at all.

Can you show us the relevant part of the code and exactly at what line it fails?
I suppose you use False for the "Global" paramater of GetAppConfigDir?

All my apps use a some variant of GetAppConfigDir to store app config files, and this works flawless under all Windows I tested.
However if run under Citrix system, you should use the roaming profile to store config files.


I had a similar problem before. I think it was solved with the following.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Button1Click(Sender: TObject);var  fname:UTF8String='C:\Users\mali.aydin\Desktop\Türkçe\ĞÜŞİÖÇ.txt';begin  // UTF8ToISO_8859_1 uses add LConvEncoding.;  ExecuteProcess('explorer.exe', '/select,'+PChar(UTF8ToISO_8859_1(fname)), []);end;  

Another possible problem:  some of the directories are not normal directories , but links.


--- Quote from: Ñuño_Martínez on November 24, 2021, 01:30:05 pm ---I suspect it is related with spaces and/or character enconding (String uses UTF8 but Windows disk stuff uses ASCII ISO-something-1)

--- End quote ---
No it does not. It uses UTF-16 (and older UCS2, but that is now a subset ) since Windows NT4, which is a generation ago ( 30 +).
It may work if you define UNICODESTRING instead of the UTF-8 Kludge. ("Kludge" is only for Windows since it was way ahead of its time with the UCS2 encoding)
So try {$mode delphiunicode} for the unit that gives you problems.
And note: everything else you have seen about ascii on windows including and after XP is due to a wrapper layer that kind of makes it work. Since WIN NT4 the core API is Unicode16  and (very old versions since it predates many imrovements and standards) UCS2. Period.


[0] Message Index

[#] Next page

Go to full version