Autor |
Beitrag |
Roy
Beiträge: 184
Windows7 Ultimate
Delphi 2007, NET, Embarcadero
|
Verfasst: So 14.09.14 20:34
Dieser Code sagt es sind ungenügend Parameter vorhanden?!?
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 Martok: Delphi-Tags hinzugefügt
|
|
WasWeißDennIch
Beiträge: 653
Erhaltene Danke: 160
|
Verfasst: So 14.09.14 21:07
Stimmt ja auch, der Var-Parameter muss übergeben werden.
|
|
Roy
Beiträge: 184
Windows7 Ultimate
Delphi 2007, NET, Embarcadero
|
Verfasst: So 14.09.14 21:19
WasWeißDennIch hat folgendes geschrieben : | Stimmt ja auch, der Var-Parameter muss übergeben werden. |
Und wie und wo
|
|
WasWeißDennIch
Beiträge: 653
Erhaltene Danke: 160
|
Verfasst: So 14.09.14 21:23
Na, beim Aufruf.
Delphi-Quelltext 1: 2: 3: 4:
| var SystemInfo: TSystemInfo; begin GetNativeSystemInfo(SystemInfo); |
|
|
jaenicke
Beiträge: 19285
Erhaltene Danke: 1743
W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
|
Verfasst: So 14.09.14 21:27
|
|
Roy
Beiträge: 184
Windows7 Ultimate
Delphi 2007, NET, Embarcadero
|
Verfasst: Di 16.09.14 22:41
Parameter sind übergeben, jedoch streikt er bei aufruf der übergabe an ein Label
|
|
jaenicke
Beiträge: 19285
Erhaltene Danke: 1743
W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
|
Verfasst: Di 16.09.14 22:50
Wie sieht denn der Quelltext aus?
|
|
Roy
Beiträge: 184
Windows7 Ultimate
Delphi 2007, NET, Embarcadero
|
Verfasst: Di 16.09.14 22:56
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 Martok: Delphi-Tags hinzugefügt
|
|
jaenicke
Beiträge: 19285
Erhaltene Danke: 1743
W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
|
Verfasst: 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
Beiträge: 653
Erhaltene Danke: 160
|
Verfasst: Mi 17.09.14 08:08
Zitat: | 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
|
Verfasst: 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
Delphi-Quelltext
gestoßen in den Jedi Komponenten. Evtl. hilft es ja weiter?
Findet man in der Unit JclSysInfo
Gruß
|
|
jaenicke
Beiträge: 19285
Erhaltene Danke: 1743
W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
|
Verfasst: Mi 17.09.14 09:28
WasWeißDennIch hat folgendes geschrieben : | 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
Beiträge: 653
Erhaltene Danke: 160
|
Verfasst: 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
Beiträge: 19285
Erhaltene Danke: 1743
W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
|
Verfasst: Mi 17.09.14 13:31
Was hat das jetzt mit dem zu tun was ich geschrieben habe? jaenicke hat folgendes geschrieben : | 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
Beiträge: 653
Erhaltene Danke: 160
|
Verfasst: Mi 17.09.14 13:35
Wer sagt denn, dass ich Dich überhaupt gemeint habe? Meine Frage war an den TE gerichtet.
|
|