Several Delphi programs for obtaining Windows System Information

Source: Internet
Author: User
All the form interfaces in this article are omitted. You can add various window components according to the program.
1. Obtain Windows Version Information
You can use the Windows API function getversionex.
The specific procedure is 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. Obtain CPU Information
You can use the Windows API function getsysteminfo to obtain related information.
The specific procedure is as follows:
Procedure tform1.button1click (Sender: tobject );
VaR
Sysinfo: system_info;
Begin
Getsysteminfo (sysinfo );
Edit1.text: = 'System has '+ inttostr (sysinfo. dwnumberofprocessors) + 'cpus'
+ ', Type:' + inttostr (sysinfo. dwprocessortype );
End;
End.
3. Obtain memory information
You can use Windows API function globalmemorystatus to obtain memory information.
The specific procedure is 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 in use ');
Memo1.lines. Add ('total physical memory '+ inttostr (meminfo. dwtotalphys) + 'byte ');
Memo1.lines. Add ('available physical memory '+ inttostr (meminfo. dwavailphys) + 'byte ');
Memo1.lines. Add ('the total swap file size is '+ inttostr (meminfo. dwtotalpagefile) + 'byte ');
Memo1.lines. Add ('swable file size: '+ inttostr (meminfo. dwavailpagefile) + 'byte ');
Memo1.lines. Add ('total virtual memory '+ 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 in use' + #13 #10
+ 'Available physical memory '+ inttostr (meminfo. dwavailphys) + 'byte' + #13 #10
+ 'Total swap file size: '+ inttostr (meminfo. dwtotalpagefile) + 'byte' + #13 #10
+ 'Interchangeable file size: '+ inttostr (meminfo. dwavailpagefile) + 'byte' + #13 #10
+ 'Total virtual memory '+ inttostr (meminfo. dwtotalvirtual) + 'byte' + #13 #10
+ 'Unused virtual memory '+ inttostr (meminfo. dwavailvirtual) + 'byte ';
To replace memo1.line. Add (...) .
4. Obtain the windows and system paths
You can use Windows API functions to obtain
The specific procedure is 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 changes the value of the Series: 128 of which can be changed to a value not less than 16. If it is less than or equal to 16, an exception occurs (the author's operating system is Windows2000 ). Readers may wish to try it.
5. Get User Registration Information
We all know that during the software installation process, it will prompt the user to enter the serial number or product number and some user registration information (the user's company name, user name, etc) and the installation directory and path.
Run the following code to view User Registration Information:
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 series: '+ Reg. readstring ('produd D ');
Edit3.text: = 'product name: '+ Reg. readstring ('productname ');
Edit4.text: = 'registered Company Name: '+ Reg. readstring ('registeredorganization ');
Edit5.text: = 'user name: '+ Reg. readstring ('registeredowner ');
Edit6.text: = 'Software type: '+ Reg. readstring ('softwaretype ');
Reg. closekey;
Reg. Free;
End;
End.
Note: Before compiling a program, you must add a Registry Unit under the uses statement.
6. Disable widows.
You can use the Windows API function exitwindowsex to disable widows.
Procedure tform1.button1click (Sender: tobject );
Begin
If radiobutton1.checked = true then
Exitwindowsex (ewx_logoff, 0) // Log On As another user
Else if radiobutton2.checked = true then
Exitwindowsex (ewx_shutdown, 1) // safely shut down

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.