DelphiFan Magazine

Top Menu

Main Menu

  • DELPHI
  • CODE SAMPLES
  • FIREMONKEY
  • DATABASE
  • RELEASES
  • VIDEOS
  • REVIEW
  • TECH NEWS

logo

DelphiFan Magazine

  • DELPHI
  • CODE SAMPLES
  • FIREMONKEY
  • DATABASE
  • RELEASES
  • VIDEOS
  • REVIEW
  • TECH NEWS
  • How to add a server application written in UNIGUI to startup?

  • UniGUI Expiry Link Anonymizer

  • UniGUI Add CAPTCHA to the WEB project

  • UniGui. Unique hybrid of Delphi and JS

  • How to transform a blob field into string lines (varchar) in SQL Firebird?

CODE SAMPLESDELPHI
Home›CODE SAMPLES›Several Delphi programs for obtaining Windows system information

Several Delphi programs for obtaining Windows system information

By admin
November 23, 2020
1972
0
Share:

All the window interfaces in this article are omitted, and readers can add various window components according to the program.

1. Get the windows version information

It can be obtained through the Windows API function GetVersionEx.

The specific procedures are as follows:

Procedure Tform1.Button1Click(sender:TObject);
Var
OSVI:OSVERSIONINFO;
begin
OSVI.dwOSversioninfoSize:=Sizeof(OSVERSIONINFO);
GetVersionEx(OSVI);
label1.Caption:=IntToStr(OSVI.dwMinorVersion)+ ‘,’
+IntToStr(OSVI.dwMinorVersion)+ ‘,’
+IntToStr(OSVI.dwBuildNumber)+ ‘,’
+IntToStr(OSVI.dwPlatformId)+ ‘,’
+OSVI.szCSDVersion;
end;

end.

 

2. Get CPU information

Relevant information can be obtained through the Windows API function GetSystemInfo.

The specific procedures are as follows:

 

procedure TForm1.Button1Click(Sender: TObject);
Var
SysInfo:SYSTEM_INFO;
begin
GetSystemInfo(Sysinfo);
Edit1.Text:= ‘In the system’+IntToStr(Sysinfo.dwNumberOfProcessors)+ ‘CPU’
+ ‘,Type is’+IntToStr(Sysinfo.dwProcessorType);
end;

end.

 

3. Get memory information

The memory information can be obtained through the Windows API function GlobalMemoryStatus.

The specific procedures are as follows:

 

procedure TForm1.Button1Click(Sender: TObject);
Var
MemInfo:MEMORYSTATUS;
begin
MemInfo.dwLength:=sizeof(MEMORYSTATUS);
GlobalMemoryStatus(MemInfo);
memo1.Lines.Add(IntToStr(MemInfo.dwMemoryLoad)+ ‘%Of memory is in use’) ;
memo1.Lines.Add( ‘Physical memory shared’+IntToStr(MemInfo.dwTotalPhys)+ ‘byte’);
memo1.Lines.Add( ‘Available physical memory is’+IntToStr(MemInfo.dwAvailPhys)+ ‘byte’);
memo1.Lines.Add( ‘The total size of the swap file is’+IntToStr(MemInfo.dwTotalPageFile)+ ‘byte’) ;
memo1.Lines.Add( ‘The remaining swap file size is’+IntToStr(MemInfo.dwAvailPageFile)+ ‘byte’);
memo1.Lines.Add( ‘Total virtual memory has’+IntToStr(MemInfo.dwTotalVirtual)+ ‘byte’);
memo1.Lines.Add( ‘Unused virtual memory’+IntToStr(MemInfo.dwAvailVirtual)+ ‘byte’);
end;

end.

Or use the following code:

Memo1.Text:=IntToStr(MemInfo.dwMemoryLoad)+ ‘%Of memory is in use’+# 13# 10
+ ‘Available physical memory is’+IntToStr(MemInfo.dwAvailPhys)+ ‘byte’+# 13# 10
+ ‘The total size of the swap file is’+IntToStr(MemInfo.dwTotalPageFile)+ ‘byte’+# 13# 10
+ ‘The exchangeable file size is’+IntToStr(MemInfo.dwAvailPageFile)+ ‘byte’+# 13# 10
+ ‘Total virtual memory has’+IntToStr(MemInfo.dwTotalVirtual)+ ‘byte’+# 13# 10
+ ‘Unused virtual memory’+IntToStr(MemInfo.dwAvailVirtual)+ ‘byte’;

To replace the memo1.line.add(…) part.

 

4. Get Windows and system path

Can be obtained through Windows API functions

The specific procedures are as follows:

 

procedure TForm1.Button1Click(Sender: TObject);
Var
SysDir:array [0..128]  of char;
begin
GetWindowsDirectory(SysDir, 128);
Edit1.Text:= ‘Windows path:’+SysDir;
GetSystemDirectory(SysDir, 128);
Edit1.Text:=Edit1.Text+ ‘; System path:’+SysDir;
end;

end.

Among them, the author changed the value of the series: I found that 128 can be changed to a value not less than 16, if it is less than or equal to 16, abnormalities occur (the author’s operating system is Windows2000). Readers may wish to try.

 

5. Obtain user registration information

As we all know, generally during the software installation process, it will prompt the user to enter the serial number or product number and some user registration information (user’s company name, user name, etc.), as well as the installation directory and path.

The user registration information can be viewed through the following code:

procedure TForm1.Button1Click(Sender: TObject);
Var
Reg:TRegistry;
begin
Reg:=TRegistry.Create;
Reg.RootKey:=HKEY_LOCAL_MACHINE;
Reg.OpenKey( ‘Software/Microsoft/Windows NT/CurrentVersion’,False);
Edit1.Text:= ‘Current path:’+Reg.CurrentPath;
Edit2.Text:= ‘Product serial number:’+Reg.ReadString( ‘ProductId’);
Edit3.Text:= ‘product name:’+Reg.ReadString( ‘ProductName’);
Edit4.Text:= ‘Registered company name:’+Reg.ReadString( ‘RegisteredOrganization’);
Edit5.Text:= ‘username:’+Reg.ReadString( ‘RegisteredOwner’);
Edit6.Text:= ‘Software type:’+Reg.ReadString( ‘SoftwareType’);
Reg.CloseKey;
Reg.Free;
end;

end.

 

Note: Before the program is compiled, the registry unit must be added under the USES statement.

 

6. Close Widows

Widows can be closed through the Windows API function ExitWindowsEx.

procedure TForm1.Button1Click(Sender: TObject);
begin
if RadioButton1.Checked=true  then
ExitWindowsEx(EWX_LOGOFF, 0)  //Log in as another user
else  if RadioButton2.Checked=true  then
ExitWindowsEx(EWX_SHUTDOWN, 1)  //Safe shutdown
else  if RadioButton3.Checked=true  then
ExitWindowsEx(EWX_REBOOT, 2)  //重Newly booted computer
else  if RadioButton4.Checked=true  then
ExitWindowsEx(EWX_FORCE, 4)  //Forced shutdown
else  if RadioButton5.Checked=true  then
ExitWindowsEx(EWX_POWEROFF, 8);  //Shut down the system and power off

end;

end.

 

 

Tagsdelphidelphi win infodelphi windows informationswindowswindows informationswindows system
Previous Article

Example of how to use Intraweb

Next Article

DBGrid beautification and SQLite display problem

0
Shares
  • 0
  • +
  • 0
  • 0
  • 0
  • 0

admin

Related articles More from author

  • CODE SAMPLESDELPHI

    View the output function list of DLL

    January 1, 2021
    By admin
  • CODE SAMPLESDELPHIFIREMONKEY

    Get device ID on Android from Delphi

    December 4, 2020
    By admin
  • CODE SAMPLESDELPHI

    Socket error codes and possible problems

    December 7, 2020
    By admin
  • CODE SAMPLESDELPHI

    Connect And Manage A SQLite Database For Delphi

    October 8, 2020
    By admin
  • CODE SAMPLESDELPHI

    Internationalizing your application in Delphi

    January 7, 2021
    By admin
  • DELPHIVIDEOS

    Per Form VCL Styling

    September 29, 2020
    By admin

Leave a reply Cancel reply

You may interested

  • DELPHIRELEASES

    Custom High Performance VCL Component Suite For Delphi/C++ Builder By ErrorSoft

  • CODE SAMPLESDELPHI

    Talk about the application of SSL protocol in Delphi [transfer]

  • DELPHIRELEASES

    Bold for Delphi is Open Source

  • LATEST REVIEWS

  • TOP REVIEWS

Timeline

  • January 27, 2021

    How to add a server application written in UNIGUI to startup?

  • January 27, 2021

    UniGUI Expiry Link Anonymizer

  • January 26, 2021

    UniGUI Add CAPTCHA to the WEB project

  • January 26, 2021

    UniGui. Unique hybrid of Delphi and JS

  • January 13, 2021

    How to transform a blob field into string lines (varchar) in SQL Firebird?

Latest Comments

Find us on Facebook

Follow Us on Instagram

logo

Our website, law, laws, copyright and aims to be respectful of individual rights. Our site, as defined in the law of 5651 serves as a provider of space. According to the law, contrary to the law of site management has no obligation to monitor content. Therefore, our site has adopted the principle of fit and remove. Works are subject to copyright laws and is shared in a manner that violated their legal rights, or professional associations, rights holders who, adsdelphi@gmail.com I can reach us at e-mail address. Complaints considered to be infringing on the examination of the content will be removed from our site.

About us

  • 660 Pennsylvania Avenue Southeast #100 Washington, DC 20003
  • 0123456789
  • adsdelphi@gmail.com
  • Recent

  • Popular

  • Comments

  • How to add a server application written in UNIGUI to startup?

    By admin
    January 27, 2021
  • UniGUI Expiry Link Anonymizer

    By admin
    January 27, 2021
  • UniGUI Add CAPTCHA to the WEB project

    By admin
    January 26, 2021
  • UniGui. Unique hybrid of Delphi and JS

    By admin
    January 26, 2021
  • How to add a server application written in UNIGUI to startup?

    By admin
    January 27, 2021
  • Amazing Cross Platform Email App Sample In Delphi 10.4.1 FireMonkey For Android And IOS

    By admin
    August 13, 2020
  • Critical Update Available For Delphi FireMonkey 10.4.1 On Android, IOS, OSX, Windows, And Linux

    By admin
    September 4, 2020
  • Setting up the IDE for your first Android Application in Delphi

    By admin
    September 7, 2020

Follow us

Find us on Facebook

© Copyright Delphifan Forum. All rights reserved.