Thread View: pl.comp.lang.delphi
4 messages
4 total messages
Started by J-23
Sun, 05 Nov 2017 19:48
CompareStringEx WinAPI - Problem
Author: 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
Re: CompareStringEx WinAPI - Problem
Author: J-23
Date: Sun, 05 Nov 2017 23:55
Date: Sun, 05 Nov 2017 23:55
29 lines
1759 bytes
1759 bytes
W dniu 05.11.2017 o 20:48, J-23 pisze: > 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. > działa, za stałą podstawić trzeba aktualnie wybrany w systemie kod języka dla języka polskiego będzie to wartość 'pl-PL' LOCAL_USER_DEFAULT = 'pl-PL' Oriętujecie się może jaką wartość powinna posiadać stała SORT_DIGITSASNUMBERS jest ona dostępna od win7 w górę lecz w MSDN nie mogę znaleść informacji jaką ona przyjmuje wartość Pozdrawiam J-23
Re: CompareStringEx WinAPI - Problem
Author: MKi
Date: Mon, 06 Nov 2017 08:56
Date: Mon, 06 Nov 2017 08:56
11 lines
1387 bytes
1387 bytes
> Oriętujecie się może jaką wartość powinna posiadać stała > SORT_DIGITSASNUMBERS > > jest ona dostępna od win7 w górę lecz w MSDN nie mogę znaleść informacji > jaką ona przyjmuje wartość Zakładam, że 8. Znalazłem takie coś: https://abi-laboratory.pro/compatibility/Windows_6.0_to_Windows_7.0/x86_64/headers_diff/normaliz.dll/diff.html Pozdrowienia, MKi
Re: CompareStringEx WinAPI - Problem
Author: J-23
Date: Mon, 06 Nov 2017 17:29
Date: Mon, 06 Nov 2017 17:29
16 lines
1568 bytes
1568 bytes
W dniu 06.11.2017 o 09:56, MKi pisze: >> Oriętujecie się może jaką wartość powinna posiadać stała >> SORT_DIGITSASNUMBERS >> >> jest ona dostępna od win7 w górę lecz w MSDN nie mogę znaleść >> informacji jaką ona przyjmuje wartość > > Zakładam, że 8. Znalazłem takie coś: > https://abi-laboratory.pro/compatibility/Windows_6.0_to_Windows_7.0/x86_64/headers_diff/normaliz.dll/diff.html > > Dzięki :) przyda się w między czasie znalazłem jeszcze coś takiego http://pinvoke.net/ Pozdrawiam
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads