Autor |
Beitrag |
majolo
Beiträge: 334
Ubuntu 8.04, WinXP Prof.
D1, D6Pers, D7 Prof., D8 Prof., D2005 Pers
|
Verfasst: Di 24.09.02 20:01
Hi Leute,
wie bekomme ich:
1. den Pfad, wo Windows installiert ist raus.Z.B bei Partition ändert sich ja das Laufwerk oder anderer Installationspfad.
2. Wie bekommt man die Windowssysteminformationen raus:
Betriebssystem(ggf. Adminrechte oder nicht),Arbeitsspeicher,Takt, etc.?
Bin sicher steht schon irgendwo, nur die Suche spuckts leider nicht aus.
Gruss
majolo
|
|
Horst
Beiträge: 120
|
Verfasst: Di 24.09.02 20:09
majolo hat folgendes geschrieben: | Hi Leute,
wie bekomme ich:
1. den Pfad, wo Windows installiert ist raus.Z.B bei Partition ändert sich ja das Laufwerk oder anderer Installationspfad.
2. Wie bekommt man die Windowssysteminformationen raus:
Betriebssystem(ggf. Adminrechte oder nicht),Arbeitsspeicher,Takt, etc.?
Bin sicher steht schon irgendwo, nur die Suche spuckts leider nicht aus.
Gruss
majolo |
zu 1) lies mit GetenviromentVariable('WINDIR') einfach die Umgebungsvariable 'WINDIR' aus, dann weißt Du wo Windows installiert wurde.
zu 2) ist etwas kniffeliger. Da muss ich auch erstmal suchen. In irgend einer Toolbox habe schon mal was dazu gelesen...
Gruss
Horst
|
|
DeCodeGuru
Beiträge: 1333
Erhaltene Danke: 1
Arch Linux
Eclipse
|
Verfasst: Di 24.09.02 20:10
zu 1.: GetWindowsDirectory. Hier ist nochmal ein Auszug aus der PSDK.
Zitat: | The GetWindowsDirectory function retrieves the path of the Windows directory. The Windows directory contains such files as applications, initialization files, and help files.
This function is provided primarily for compatibility. Applications should store code in the Program Files folder and persistent data in the Application Data folder in the user's profile. For more information, see ShGetFolderPath.
Quelltext 1: 2: 3: 4:
| UINT GetWindowsDirectory( LPTSTR lpBuffer, // buffer for Windows directory UINT uSize // size of directory buffer ); |
Parameters
lpBuffer
[out] Pointer to the buffer to receive the null-terminated string containing the path. This path does not end with a backslash unless the Windows directory is the root directory. For example, if the Windows directory is named Windows on drive C, the path of the Windows directory retrieved by this function is C:\Windows. If the system was installed in the root directory of drive C, the path retrieved is C:\.
uSize
[in] Maximum size of the buffer specified by the lpBuffer parameter, in TCHARs. This value should be set to MAX_PATH+1 to allow sufficient space for the path and the null terminator.
Return Values
If the function succeeds, the return value is the length of the string copied to the buffer, in TCHARs, not including the terminating null character.
If the length is greater than the size of the buffer, the return value is the size of the buffer required to hold the path.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
zu 2.:
Wenn du den Arbeitsspeicher auslesen willst, kannste ja mit folgendem Code experimentieren:
Quelltext 1: 2: 3: 4: 5: 6: 7: 8:
| procedure TForm1.Button1Click(Sender: TObject); var MemoryStatus: TMemoryStatus; begin MemoryStatus.dwLength := SizeOf(MemoryStatus); GlobalMemoryStatus(MemoryStatus); Label1.Caption := IntToStr((MemoryStatus.dwTotalPhys div 1024)-(MemoryStatus.dwAvailPhys div 1024)); end; |
Admin-Rechte habe ich ehrlich gesagt im Moment keine Idee bzw. bin mir bei einer Idee nicht sicher. Werde da nochmal nachgucken und dann nochmal posten. Wenn du noch die CPU-Taktfrequenz rausbekommen willst, da gibt es im Netz sehr viele Codes. Soweit ich weiss, kann man das dann mit nem Assemblercode machen. Such einfach mal in Google oder im Swissdelphicenter. Ansonsten kannste für so Einstellungen aller Desktopauflösung, Icongröße oder sowas noch GetSystemMetrics verwenden.
Na ja, ich hoffe, ich konnte dir wenigstens etwas helfen.
_________________ Viele Grüße
Jakob
|
|
DeCodeGuru
Beiträge: 1333
Erhaltene Danke: 1
Arch Linux
Eclipse
|
Verfasst: Di 24.09.02 20:12
Horst hat folgendes geschrieben: |
zu 1) lies mit GetenviromentVariable('WINDIR') einfach die Umgebungsvariable 'WINDIR' aus, dann weißt Du wo Windows installiert wurde. |
Oder so
_________________ Viele Grüße
Jakob
|
|
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Di 24.09.02 20:27
www.luckie-online.de...lphi/downloads.shtml auf der Seite SysInfo runterladen. Ist mit Soße.
|
|
majolo
Beiträge: 334
Ubuntu 8.04, WinXP Prof.
D1, D6Pers, D7 Prof., D8 Prof., D2005 Pers
|
Verfasst: Di 24.09.02 20:41
Danke Luckie, dein tutorial ist wirklich gut, damit ist mir schon sehr viel geholfen.
@andere: Den Windowspfad habe ich irgendwie mit euren Beschreibungen noch nicht rausbekommen.
Gruss
majolo
|
|
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Di 24.09.02 20:46
Tutorial?
SysInfo ist ein Programm und soweit ich mich erinnern kann weitgehend ohne Kommentare
Und wenn du dir mal meine Sourcen etwas genauer angekuckt hättest, dann hättets du in der Unit WinInfo.pas folgendes gefunden:
Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
| function GetWinDir: String; const UNLEN = MAX_PATH; var Size: DWORD; begin Size := UNLEN + 1; SetLength(Result, Size); if GetWindowsDirectory(PChar(Result), Size) <> 0 then SetLength(Result, Size - 1) else Result := ''; end; |
Alles andere steht da auch drin.
|
|
majolo
Beiträge: 334
Ubuntu 8.04, WinXP Prof.
D1, D6Pers, D7 Prof., D8 Prof., D2005 Pers
|
Verfasst: Di 24.09.02 20:55
Sorry,habe mich falsch ausgedrückt.Der Code von dir Luckie ist schon sehr erklärend.Deshalb sage ich ja mit deinem Code ging es. Mit dem der anderen habe ich es nicht geschafft.Sollte eigentlich ein Lob an dich sein. Den anderen auch Danke
Gruss
majolo
|
|
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Mi 25.09.02 08:06
DeCodeGuru hat folgendes geschrieben: | Admin-Rechte habe ich ehrlich gesagt im Moment keine Idee bzw. bin mir bei einer Idee nicht sicher. |
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: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62:
| function GetAdminSid: PSID; const SECURITYNTAUTHORITY: TSIDIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 5)); SECURITYBUILTINDOMAINRID: DWORD = $00000020; DOMAINALIASRIDADMINS: DWORD = $00000220; begin Result := nil; AllocateAndInitializeSid(SECURITYNTAUTHORITY, 2, SECURITYBUILTINDOMAINRID, DOMAINALIASRIDADMINS, 0, 0, 0, 0, 0, 0, Result); end;
function IsAdmin: LongBool; var TokenHandle : THandle; ReturnLength : DWORD; TokenInformation : PTokenGroups; AdminSid : PSID; Loop : Integer; wv : TOSVersionInfo; begin ZeroMemory (@wv,sizeof(TOSVersionInfo)); wv.dwOSVersionInfoSize := sizeof(TOSVersionInfo); GetVersionEx(wv);
Result := (wv.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS);
if(wv.dwPlatformId = VER_PLATFORM_WIN32_NT) then begin TokenHandle := 0; if OpenProcessToken(GetCurrentProcess, TOKEN_QUERY, TokenHandle) then try ReturnLength := 0; GetTokenInformation(TokenHandle, TokenGroups, nil, 0, ReturnLength); TokenInformation := GetMemory(ReturnLength); if Assigned(TokenInformation) then try if GetTokenInformation(TokenHandle, TokenGroups, TokenInformation, ReturnLength, ReturnLength) then begin AdminSid := GetAdminSid; for Loop := 0 to TokenInformation^.GroupCount - 1 do begin if EqualSid(TokenInformation^.Groups[Loop].Sid, AdminSid) then begin Result := True; break; end; end; FreeSid(AdminSid); end; finally FreeMemory(TokenInformation); end; finally CloseHandle(TokenHandle); end; end; end; |
Anwendung:
Delphi-Quelltext 1: 2:
| if(not(isAdmin)) then ShowMessage('Komm wieder, wenn du Admin geworden bist!'); |
Euer Dank für die Funktion geht an NicoDE.
Moderiert von Tino: Code- durch Delphi-Tags ersetzt.
|
|
LCS
Beiträge: 1305
Erhaltene Danke: 1
WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
|
Verfasst: Mi 25.09.02 08:27
Hi Mathias
Obercool, danach hab ich auch schon lange gesucht
Gruss Lothar
_________________ Der BH ist für die Brust, der Plan ist für'n Ar...
|
|
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Mi 25.09.02 11:32
Ist auch genauso in der WinIfo.pas drin von meinem Programm.
|
|
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Mi 25.09.02 12:39
Damit ist wohl bewiesen, dass ich mir das Programm nicht angeguckt habe? Na ja, man kann sich ja nicht um alles kümmern ...
|
|
|