I am using Delphi 2010, and my program wants to get the system time path. I use TPath.GetTempPath and everything works fine ... at least for me and my colleagues. But on some client machines, this method returns a clipped path that (of course) does not exist. I found out that the problem seems to be the result of a basic call to GetLongPathName ().
The full code is as follows:
[...] var TmpDir : String; Len : Integer; begin [... Call to GetTempPath succeeds and we have a valid temp directory in short "~" notation in var TmpDir ...] Len := GetLongPathName(PChar(TmpDir), nil, 0); // Len = 37 SetLength(TmpDir, Len - 1); // We want to set the len of TmpDir to 37 - 1. GetLongPathName(PChar(TmpDir), PChar(TmpDir), Len); // Only 32 (instead of 36) characters are copied - so we have a cropped path - But why?! end; [...]
This only happens on some systems, and I don't know why. I found a nasty workaround for this, but I would like to know what is going on here.
Can anyone tell about this?
winapi path delphi delphi-2010
Patrick
source share