Autor Beitrag
Roy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 184

Windows7 Ultimate
Delphi 2007, NET, Embarcadero
BeitragVerfasst: So 14.09.14 20:34 
Dieser Code sagt es sind ungenügend Parameter vorhanden?!?


ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
function GetNativeSystemInfo(var SystemInfo: TSystemInfo): Boolean;
type
  TGetNativeSystemInfo = procedure (var SystemInfo: TSystemInfo) stdcall;
var
  LibraryHandle: HMODULE;
  _GetNativeSystemInfo: TGetNativeSystemInfo;
begin
  Result := False;
  LibraryHandle := GetModuleHandle(kernel32);

  if LibraryHandle <> 0 then
  begin
    _GetNativeSystemInfo := GetProcAddress(LibraryHandle,'GetNativeSystemInfo');
    if Assigned(_GetNativeSystemInfo) then
    begin
      _GetNativeSystemInfo(SystemInfo);
      Result := True;
    end
    else
      GetSystemInfo(SystemInfo);
  end
  else
    GetSystemInfo(SystemInfo);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Label13.Caption := GetNativeSystemInfo;
end;

end.


Moderiert von user profile iconMartok: Delphi-Tags hinzugefügt
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: So 14.09.14 21:07 
Stimmt ja auch, der Var-Parameter muss übergeben werden.
Roy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 184

Windows7 Ultimate
Delphi 2007, NET, Embarcadero
BeitragVerfasst: So 14.09.14 21:19 
user profile iconWasWeißDennIch hat folgendes geschrieben Zum zitierten Posting springen:
Stimmt ja auch, der Var-Parameter muss übergeben werden.


Und wie und wo
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: So 14.09.14 21:23 
Na, beim Aufruf.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
var 
  SystemInfo: TSystemInfo;
begin
  GetNativeSystemInfo(SystemInfo);
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 14.09.14 21:27 
Was im Übrigen auch in dem Beitrag so drin steht...
user profile iconhathor hat folgendes geschrieben Zum zitierten Posting springen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
...

function IsWindows64: Boolean;
var
  ASystemInfo: TSystemInfo;
const
  PROCESSOR_ARCHITECTURE_INTEL = 0;
  PROCESSOR_ARCHITECTURE_IA64 = 6;
  PROCESSOR_ARCHITECTURE_AMD64 = 9;
begin
  GetNativeSystemInfo(ASystemInfo);
  Result := ASystemInfo.wProcessorArchitecture in [PROCESSOR_ARCHITECTURE_IA64,PROCESSOR_ARCHITECTURE_AMD64];
end;
Roy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 184

Windows7 Ultimate
Delphi 2007, NET, Embarcadero
BeitragVerfasst: Di 16.09.14 22:41 
Parameter sind übergeben, jedoch streikt er bei aufruf der übergabe an ein Label
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 16.09.14 22:50 
Wie sieht denn der Quelltext aus?
Roy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 184

Windows7 Ultimate
Delphi 2007, NET, Embarcadero
BeitragVerfasst: Di 16.09.14 22:56 
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
function GetNativeSystemInfo(var SystemInfo: TSystemInfo): Boolean;
type
  TGetNativeSystemInfo = procedure (var SystemInfo: TSystemInfo) stdcall;
var
  LibraryHandle: HMODULE;
  _GetNativeSystemInfo: TGetNativeSystemInfo;
begin
  Result := False;
  LibraryHandle := GetModuleHandle(kernel32);

  if LibraryHandle <> 0 then
  begin
    _GetNativeSystemInfo := GetProcAddress(LibraryHandle,'GetNativeSystemInfo');
    if Assigned(_GetNativeSystemInfo) then
    begin
      _GetNativeSystemInfo(SystemInfo);
      Result := True;
    end
    else
      GetSystemInfo(SystemInfo);
  end
  else
    GetSystemInfo(SystemInfo);
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  SystemInfo: TSystemInfo;
begin
Label13.Caption:= GetNativeSystemInfo(SystemInfo);
end;


Moderiert von user profile iconMartok: Delphi-Tags hinzugefügt
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 17.09.14 06:32 
Genau vor deinem letzten Beitrag hatte ich das Beispiel noch einmal zitiert...
Die Funktion GetNativeSystemInfo liefert nur zurück, ob sie die Informationen erfolgreich holen konnte.

Du kannst danach mit den Werten in deiner Variable SystemInfo arbeiten. Du kannst auch die fertige als Beispiel genannte Funktion IsWindows64 nutzen.
Zur Umwandlung des boolschen Werts in einem String zur Anzeige gibt es BoolToStr.
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: Mi 17.09.14 08:08 
Zitat:
ausblenden Delphi-Quelltext
1:
function GetNativeSystemInfo(var SystemInfo: TSystemInfo): Boolean;					

Welchen Sinn soll es machen, einen Boolean in einem Label anzeigen zu wollen? Gut, mit BoolToStr kann man ihn umwandeln, sonderlich informativ ist das allerdings nicht. Wären die im TSystemInfo-Record zurückgegebenen Werte nicht eher von Interesse?
Sylar
Hält's aus hier
Beiträge: 4
Erhaltene Danke: 2



BeitragVerfasst: Mi 17.09.14 09:21 
Ich hoffe ich unterbreche nicht die Diskussion, aber ich hatte mal irgendwann so ein ähnliches Problem, dass ich herausfinden muss obs ein 64Bit oder 32Bit System ist.
Nach langem suchen bin ich auf die Funktion

ausblenden Delphi-Quelltext
1:
IsWindows64;					


gestoßen in den Jedi Komponenten. Evtl. hilft es ja weiter?

Findet man in der Unit JclSysInfo

Gruß
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 17.09.14 09:28 
user profile iconWasWeißDennIch hat folgendes geschrieben Zum zitierten Posting springen:
Wären die im TSystemInfo-Record zurückgegebenen Werte nicht eher von Interesse?
Die zusammen mit dem benutzten Quelltext gepostete Funktion IsWindows64 gibt (wie auch die von den JEDIs) auch einen Boolean zurück. Darauf war das BoolToStr bezogen.
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: Mi 17.09.14 10:03 
Das war mir schon klar, aber welchen Nutzen hat man davon, zu zeigen, ob die Funktion erfolgreich durchlaufen wurde? Gut, man weiß in diesem Fall, dass GetNativeSystemInfo in der kernel32.dll vorhanden ist, trotzdem stecken die relevanten Informationen IMO im Record.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 17.09.14 13:31 
Was hat das jetzt mit dem zu tun was ich geschrieben habe?
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
Die zusammen mit dem benutzten Quelltext gepostete Funktion IsWindows64 gibt (wie auch die von den JEDIs) auch einen Boolean zurück. Darauf war das BoolToStr bezogen.
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: Mi 17.09.14 13:35 
Wer sagt denn, dass ich Dich überhaupt gemeint habe? Meine Frage war an den TE gerichtet.