Article View: pl.comp.lang.delphi
Article #346156CompareStringEx WinAPI - Problem
From: J-23
Date: Sun, 05 Nov 2017 19:48
Date: Sun, 05 Nov 2017 19:48
91 lines
3290 bytes
3290 bytes
Witam,
Chcę posortować TStringList przy pomocy funkcji WinAPI
https://msdn.microsoft.com/en-us/library/windows/desktop/dd317761(v=vs.85).aspx
napisałem sobie moduł ftp://vps427063.ovh.net/Tools.pas
[Tutaj treść tego modułu]
unit Tools;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LCLType, Dialogs;
const
SORT_DIGITSASNUMBERS = $00000008;
LOCAL_USER_DEFAULT = '!sys-default-locale';
type
PNLSVersionInfoEx = ^TNLSVersionInfoEx;
TNLSVersionInfoEx = record
dwNLSVersionInfoSize: DWord;
dwNLSVersion: DWord;
dwDefinedVersion: DWord;
dwEffectiveId: DWord;
guidCustomVersion: TGuid;
end;
procedure ListFileDir(Path: string; Filtr: string; FileList: TStringList);
function compare(List: TStringList; Index1, Index2: integer): integer;
function CompareStringEx(lpLocaleName: PChar; dwCmpFlags: DWord;
lpString1: PChar; cchCount1: integer; lpString2: PChar; cchCount2:
integer;
lpVersionInformation: PNLSVersionInfoEx; lpReserved: Pointer; lParam:
LParam): integer;
external 'kernel32.dll';
implementation
procedure ListFileDir(Path: string; Filtr: string; FileList: TStringList);
var
SR: TSearchRec;
begin
if FindFirst(Path + Filtr, faAnyFile, SR) = 0 then
begin
repeat
if (SR.Attr <> faDirectory) then
begin
FileList.Add(SR.Name);
end;
until FindNext(SR) <> 0;
FindClose(SR);
end;
end;
function compare(List: TStringList; Index1, Index2: integer): integer;
begin
try
Result := CompareStringEx(PChar(LOCAL_USER_DEFAULT),
SORT_DIGITSASNUMBERS,
PChar(List.Strings[Index1]), -1, PChar(List.Strings[Index2]), -1,
nil, nil, 0);
except
ShowMessage(SysErrorMessage(GetLastOSError));
end;
end;
end.
lecz dostaję wyjątek "Parametr jest niepoprawny," - wychodzi na to że
skopałem któryś parametr funkcji CompareStringEx tylko przyznam że
rzadko bawię się WinAPI i nie przychodzi mi do głowy który by mógł to
być
Swoją drogą zauważyliście ze na MSDN jak coś teraz podają w stałych to
podają same nazwy bez ich wartości - Ciekawe to jest :)
Moje środowisko:
Lazarus 1.6.4
Win 7
Pozdrawiam
J-23
Technical Details
Message-ID:
<59ff6b1e$0$5160$65785112@news.neostrada.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!news.unit0.net!peer02.am4!peer.am4.highwinds-media.com!peer03.fr7!futter-mich.highwinds-media.com!news.highwinds-media.com!newsfeed.neostrada.pl!unt-exc-01.news.neostrada.pl!unt-spo-a-01.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!news.unit0.net!peer02.am4!peer.am4.highwinds-media.com!peer03.fr7!futter-mich.highwinds-media.com!news.highwinds-media.com!newsfeed.neostrada.pl!unt-exc-01.news.neostrada.pl!unt-spo-a-01.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail Newsgroups: pl.comp.lang.delphi X-Mozilla-News-Host: news://news.neostrada.pl:119 From: J-23 <Baczeklu@poczta.fm> Subject: CompareStringEx WinAPI - Problem Date: Sun, 5 Nov 2017 20:48:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 Lines: 91 Message-ID: <59ff6b1e$0$5160$65785112@news.neostrada.pl> Organization: Telekomunikacja Polska NNTP-Posting-Host: 188.146.165.50 X-Trace: 1509911327 unt-rea-a-01.news.neostrada.pl 5160 188.146.165.50:5401 X-Complaints-To: abuse@news.neostrada.pl X-Received-Body-CRC: 3774105335 X-Received-Bytes: 3210 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit