![]() |
|
|
|||||||
| Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
|
Опции темы | Поиск в этой теме | Опции просмотра |
|
#1
|
|||
|
|||
|
Цитата:
Наверное все уже поняли что это!!! Это функции для определения имени/имён ресурса "RT_GROUP_ICON"... Помогите пожалуйста заменить все TStrings на что нибудь альтернативное!!! Может масив какой!!! Или еще что, только что бы использовался или SysUtils.pas или Windows.pas или всё вместе... Заранее благодарен!!! P.S. И если не трудно то и все String! |
|
#2
|
|||
|
|||
|
TStringList.
TStrings есть абстрактный базовый класс. Его создавать нельзя. |
|
#3
|
|||
|
|||
|
Цитата:
|
|
#4
|
||||
|
||||
|
Есть в нете альтернативные модули с TList, явно пытаешься написать на API (или почти 8-) безоконное приложение или как минимум консольник, вот, еще зачем в таком приложении получать инфу о значках или это дело для прикрытия, а на самом деле RC_DATA на прицеле => джойнер ;-)
|
|
#5
|
|||
|
|||
|
Цитата:
Код:
function StockResourceType(ResType: PChar): string;
begin
if ResType = PChar(14) then
Result:='RT_GROUP_ICON';
end;
function EnumResNamesProc(Module: HMODULE; ResType, ResName: PChar; Ts: TStrings): Integer; stdcall;
begin
if (StockResourcetype(ResType) = 'RT_GROUP_ICON') then
begin
if HiWord(Cardinal(ResName)) <> 0 then
Ts.Add(ResName)
else
Ts.Add(Format('%d', [LoWord(Cardinal(ResName))]));
end;
Result:=1;
end;
function EnumResTypesProc(Module: HMODULE; ResType: PChar; Ts: TStrings): Integer; stdcall;
begin
if (StockResourcetype(ResType) = 'RT_GROUP_ICON') then
begin
EnumResourceNames(Module, ResType, @EnumResNamesProc, Integer(Ts));
end;
Result:=1;
end;Код:
EnumResourceTypes(LoadLib, @EnumResTypesProc, Integer(Вот сюда её выводила)); ![]() |
|
#6
|
||||
|
||||
|
EnumResourceTypes вызывай с передачей хэндла открытого на запись файла
(CreateFile вместо Integer(Вот сюда её выводила) ) в EnumResNamesProc пиши в файл, т.е. Ts.Add замени на WriteFile :lol: |
|
#7
|
|||
|
|||
|
Цитата:
|
|
#8
|
||||
|
||||
|
да можно конечно:
var arr: array [0..$ffff] of String; // не хватит - добавим) и через инкремент глобальной переменной запоминать в элементах массива. конечное значение глобальной переменной будет количеством элементов |
|
#9
|
|||
|
|||
|
Цитата:
![]() |
|
#10
|
||||
|
||||
|
Код:
unit CustomStringList;
interface
uses
SysUtils;
type
TCustomStringList = class
private
FLines: Array of String;
function GetText: String;
function GetCount: Integer;
function GetLines(const Index: Integer): String;
procedure SetLines(const Index: Integer; const Value: String);
public
constructor Create; virtual;
destructor Destroy; override;
property Text: String read GetText;
property Count: Integer read GetCount;
property Lines[const Index: Integer]: String read GetLines write SetLines;
procedure Add(const Value: String);
procedure Clear;
end;
implementation
constructor TCustomStringList.Create;
begin
inherited;
SetLength(FLines, 0);
end;
destructor TCustomStringList.Destroy;
begin
SetLength(FLines, 0);
inherited;
end;
function TCustomStringList.GetLines(const Index: Integer): String;
begin
if (Index >= 0) and (Index <= Length(FLines)-1) then
Result := FLines[Index]
else
begin
raise Exception.Create('Недопустимый индекс строки');
Exit;
end;
end;
procedure TCustomStringList.SetLines(const Index: Integer; const Value: String);
begin
if (Index >= 0) and (Index <= Length(FLines)-1) then
FLines[Index] := Value
else
begin
raise Exception.Create('Недопустимый индекс строки');
Exit;
end;
end;
function TCustomStringList.GetText;
var
I, B, E: Integer;
begin
Result:= '';
B:= Low(FLines);
E:= High(FLines);
for I:=B to E do
if I = E then
Result:= Result + FLines[i]
else
Result:= Result + FLines[i] + #13#10;
end;
function TCustomStringList.GetCount;
begin
Result:= Length(FLines);
end;
procedure TCustomStringList.Add(const Value: String);
begin
SetLength(FLines, Length(FLines)+1);
FLines[High(FLines)]:= Value;
end;
procedure TCustomStringList.Clear;
begin
SetLength(FLines, 0);
end;
end.Используем Код:
var
CSL: TCustomStringList;
I: Integer;
begin
CSL:= TCustomStringList.Create;
for I:= 1 to 10 do
CSL.Add('Lines '+IntToStr(I));
Memo1.Lines.Add(CSL.Text);
Memo1.Lines.Add(inttostr(CSL.Count));
CSL.Free;
end;Последний раз редактировалось pesi, 28.08.2010 в 13:49. |
|
#11
|
|||
|
|||
|
собствнно, непонятно почему нельзя использовать модуль Classes. Он ничего такого тяжелого в себе не содержит. Это раз.
Два. Реализовать свой список строк можно и на динамическом массиве. Там только проблема, что динамический массив нельзя менять внутри процедуры (может в версиях после 7 это и поправили). но с другой стороны легко написать свою обертку над ним в виде класса. Код:
unit MyStrings;
interface
uses
Windows, SysUtils;
type
TMyStrings = class
private
FItems : Array Of String;
function GetCount : Integer;
function GetItem(Index : Integer) : String;
procedure SetItem(Index : Integer; Value : String);
public
constructor Create; virtual;
destructor Destroy; override;
procedure Clear;
function Add(AStr : String) : Integer;
function IndexOf(AStr : String) : Integer; overload;
function IndexOf(AStr : String; ACaseSensitive : Boolean) : Integer; overload;
procedure Delete(AIndex : Integer);
procedure Remove(AStr : String);
property Count : Integer read GetCount;
property Items[Index : Integer] : String read GetItem write SetItem;
end;
implementation
function TMyStrings.GetCount : Integer;
begin
Result := Length(FItems);
end;
function TMyStrings.GetItem(Index : Integer) : String;
begin
If (Index < Low(FItems)) Or (Index > High(FItems))
Then Raise Exception.CreateFmt('Index out of bounds (%d).',[Index]);
Result := FItems[Index];
end;
procedure TMyStrings.SetItem(Index : Integer; Value : String);
begin
If (Index < Low(FItems)) Or (Index > High(FItems))
Then Raise Exception.CreateFmt('Index out of bounds (%d).',[Index]);
FItems[Index] := Value;
end;
constructor TMyStrings.Create;
begin
inherited;
SetLength(FItems,0);
end;
destructor TMyStrings.Destroy;
begin
SetLength(FItems,0);
inherited;
end;
procedure TMyStrings.Clear;
begin
SetLength(FItems,0);
end;
function TMyStrings.Add(AStr : String) : Integer;
begin
SetLength(FItems,Length(FItems)+1);
Result := High(FItems);
FItems[Result] := AStr;
end;
function TMyStrings.IndexOf(AStr : String) : Integer;
begin
Result := IndexOf(AStr,True);
end;
function TMyStrings.IndexOf(AStr : String; ACaseSensitive : Boolean) : Integer;
var
I : Integer;
cResult : Integer;
begin
Result := -1;
For I := Low(FItems) To High(Fitems) Do
Begin
If ACaseSensitive
Then cResult := AnsiCompareStr(FItems[i],AStr)
Else cResult := AnsiCompareText(FItems[i],AStr);
If cResult = 0 Then
Begin
Result := I;
Break;
End;
End;
end;
procedure TMyStrings.Delete(AIndex : Integer);
var
I : Integer;
begin
If (AIndex < Low(FItems)) Or (AIndex > High(FItems))
Then Raise Exception.CreateFmt('Index out of bounds (%d).',[AIndex]);
For I := AIndex To High(FItems) - 1 Do
FItems[i] := FItems[I+1];
SetLength(FItems,Length(FItems)-1);
end;
procedure TMyStrings.Remove(AStr : String);
var
AIndex : Integer;
begin
AIndex := IndexOf(AStr);
If AIndex = -1
Then Raise Exception.CreateFmt('Item ''%s'' not found.',[AStr]);
Delete(AIndex);
end;
end. |