![]() | Steema Issues DatabaseNote: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;otherwise you can use StackOverflow. Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy. |
| Summary: | GPF in function LongPathName | ||
|---|---|---|---|
| Product: | VCL TeeChart | Reporter: | John Santmann <JSantmann> |
| Component: | Export | Assignee: | Steema Issue Manager <issuemanager> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | david |
| Priority: | --- | ||
| Version: | 131016 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows | ||
| Chart Series: | --- | Delphi / C++ Builder RAD IDE Version: | |
Thanks for reporting. Can you confirm which IDE is showing the problem? (Delphi 2009 or 2010?) Fixes have been applied, but to be compatible with non-unicode Delphi versions, this line should be:
@GetLongPathName:=GetProcAddress(TeeKernel32,{$IFDEF UNICODE}'GetLongPathNameW'{$ELSE}'GetLongPathNameA'{$ENDIF});
|
Problem with the following procedure which generates GPF because it needs GetLongPathNameW instead of GetLongPathNameA. In addition, the buffer is one byte too small. Fix is in code below. function LongPathName(const FileName:String):String; var BufferSize: DWord; begin // "GetLongPathNameA" available only for Win2000, WinXP or Win2003, or newer ! if (Win32Platform=VER_PLATFORM_WIN32_NT) and (WindowsMajorVersion>=5) then begin (* // --------- BEGIN REMOVED CODE ----------- if TeeKernel32=0 then begin TeeKernel32:=TeeLoadLibrary(kernel32); if TeeKernel32<>0 then @GetLongPathName:=GetProcAddress(TeeKernel32,'GetLongPathNameA'); end; BufferSize := GetLongPathName(PChar(FileName), nil, 0); SetLength(Result, BufferSize - 1); GetLongPathName(PChar(FileName), PChar(Result), BufferSize); // ----------- END RREMOVED CODE ---------- *) // 2/19/2009 ------------ BEGIN CODE ADDED ----------------- if TeeKernel32=0 then begin TeeKernel32:=TeeLoadLibrary(kernel32); if TeeKernel32<>0 then @GetLongPathName:=GetProcAddress(TeeKernel32,'GetLongPathNameW'); end; // returns length (including #0) of LongPath (or 0 if not found or error) BufferSize := GetLongPathName(PChar(FileName), // lpszShortPath PChar(Result), // Out lpszLongPath 0) ; // cchBuffer SetLength(Result, // '' BufferSize) ; GetLongPathName(PChar(FileName), // lpszShortPath PChar(Result), // Out lpszLongPath BufferSize) ; // cchBuffer If BufferSize > 0 then SetLength(Result, // remove #0 BufferSize - 1) ; // 2/19/2009 - END FIXED CODE ADDED end else result:=FileName; end;