Autor Beitrag
FriFra
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: Mo 29.08.05 23:23 
Ich habe mir eine Funktion geschrieben, die mir eigentlich die höchste ID meiner Stringresourcen liefern sollte...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
  function GetMaxResID: integer;
  var
    Buffer: array[0..MAX_PATH] of Char;
    n: integer;
  begin
    for n := 0 to 9999 do
    begin
      if Loadstring(hinstance, n, @buffer, MAX_PATH) = 0 then
      begin
        if GetLastError <> ERROR_SUCCESS then
          break
        else
          Result := n;
      end
      else
        Result := n;
    end;
  end;


Diese Funktion tut es allerdings nicht, weil GetLastError offensichtlich sehr unzuverlässig ist :evil: :roll:

Die Funktion liefert mir bei realen 163 Strings "abwechselnd" (unregelmäßig) 162 (korrekt) und 175 :gruebel:

_________________
Michael
(principal certified lotus professional - developer)
ManuelGS
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 173

Win XP HE, Suse Linux
D6, D7, D2005 Personal
BeitragVerfasst: Fr 09.09.05 02:25 
Bin zwar gerade im Halbschlaf, aber probier mal so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
function GetMaxResID: integer;
  var
    Buffer: array[0..MAX_PATH] of Char;
    n: integer;
  begin
    n:=-1;
    repeat inc(n);
      until (loadstring(hinstance,n,@buffer,max_path) = 0)
        and (getlasterror<>ERROR_SUCCESS);
    result:=n+1;
  end;



Das Prob. könnte leich an max_path liegen. Überprüf mal den Wert, wenn die Funktion startet.

_________________
"Leben ist gänzlich Bühne und Spiel; so lerne denn spielen
und entsage dem Ernst - oder erdulde das Leid." - Palladas von Alexandria