Function tform1.getlocaleinformation (FLAG: integer): string;
VaR
Pclca: array [0 .. 20] of char;
Begin
If (getlocaleinfo (locale_system_default, flag, pclca, 19) <= 0) then begin
Pclca [0]: = #0;
End;
Result: = pclca;
End;
Procedure tform1.button1click (Sender: tobject );
Begin
Showmessage (getlocaleinformation (locale_senglanguage ));
End;
The parameter "flag" can take the following values:
Locale_nouseroverride {do not use user overrides}
Locale_use_cp_acp {use the system ACP}
Locale_ilanguage {language code}
Locale_slanguage {local language name}
Locale_senglanguage {English name of the language}
Locale_sabbrevlangname {abbreviated language name}
Locale_snativelangname {local language name}
Locale_icountry {Country Code}
Locale_scountry {country name}
Locale_sengcountry {English name of the country}
Locale_sabbrevctryname {country name abbreviation}
Locale_snativectryname {country name}
Locale_idefaultlanguage {default language code}
Locale_idefacouncountry {default Country Code}
Locale_idefacodecodepage {default OEM code page}
Locale_idefaultansicodepage {default ANSI code page}
Locale_idefamacmaccodepage {default Mac page}
Locale_slist {list item delimiter}
Locale_imeasure {measurement unit 0 = meter, 1 = imperial}
Locale_sdecimal {decimal point}
Locale_sthousand {delimiter}
Locale_sgrouping {digit grouping}
Locale_idigits {Number of fractional digits}
Locale_ilzero {leading zeros for decimal}
Locale_inegnumber {negative number mode}
Locale_snativedigits {native ASCII 0-9}
Locale_scurrency {local currency symbol}
Locale_sintlsymbol {International Currency symbol}
Locale_smondecimalsep {decimal point delimiter}
Locale_smonthousandsep {currency delimiter}
Locale_smongrouping {monetary grouping}
Locale_icurrdigits {# local monetary digits}
Locale_iintlcurrdigits {# Intl monetary digits}
Locale_icurrency {positive currency mode}
Locale_inegcurr {negative currency mode}
Locale_sdate {date delimiter}
Locale_stime {time delimiter}
Locale_s1_date {short date string}
Locale_slongdate {long date string}
Locale_stimeformat {time format string}
Locale_idate {short date format ordering}
Locale_ildate {long Date Format ordering}
Locale_itime {time format specifier}
Locale_itimemarkposn {time marker position}
Locale_icentury {century format specifier (short date )}
Locale_itlzero {leading zeros in time field}
Locale_idaylzero {leading zeros in day field (short date )}
Locale_imonlzero {leading zeros in month field (short date )}
Locale_s1159 {AM designator}
Locale_s2359 {PM designator}
Locale_icalendartype {type of calendar specifier}
Locale_ioptionalcalendar {additional calendar types specifier}
Locale_ifirstdayofweek {First day of week specifier}
Locale_ifirstweekofyear {first week of year specifier}
Locale_sdayname1 {long name for Monday}
Locale_sdayname2 {long name for Tuesday}
Locale_sdayname3 {long name for Wednesday}
Locale_sdayname4 {long name for Thursday}
Locale_sdayname5 {long name for Friday}
Locale_sdayname6 {long name for Saturday}
Locale_sdayname7 {long name for Sunday}
Locale_sabbrevdayname1 {abbreviation of Monday}
Locale_sabbrevdayname2 {abbreviation of Tuesday}
Locale_sabbrevdayname3 {abbreviation of Wednesday}
Locale_sabbrevdayname4 {abbreviation of Thursday}
Locale_sabbrevdayname5 {abbreviation of Friday}
Locale_sabbrevdayname6 {abbreviation of Saturday}
Locale_sabbrevdayname7 {abbreviation of Sunday}
Locale_smonthname1 {long name for January}
Locale_smonthname2 {long name for February}
Locale_smonthname3 {long name for March}
Locale_smonthname4 {long name for each l}
Locale_smonthname5 {long name for May}
Locale_smonthname6 {long name for June}
Locale_smonthname7 {long name for July}
Locale_smonthname8 {long name for August}
Locale_smonthname9 {long name for September}
Locale_smonthname10 {long name for October}
Locale_smonthname11 {long name for November}
Locale_smonthname12 {long name for December}
Locale_smonthname13 {long name for 13th month (if exists )}
Locale_sabbrevmonthname1 {abbreviation of January 1, January}
Locale_sabbrevmonthname2 {abbreviation for January 1, February}
Locale_sabbrevmonthname3 {abbreviation of January 3, March}
Locale_sabbrevmonthname4 {abbreviation of January 4, April}
Locale_sabbrevmonthname5 {abbreviation of January 5, May}
Locale_sabbrevmonthname6 {abbreviation of January 6, June}
Locale_sabbrevmonthname7 {abbreviation of January 7, July}
Locale_sabbrevmonthname8 {abbreviation of January 8, August}
Locale_sabbrevmonthname9 {abbreviation of January 9, September}
Locale_sabbrevmonthname10 {abbreviation of January 10, October}
Locale_sabbrevmonthname11 {abbreviation of January 11, November}
Locale_sabbrevmonthname12 {abbreviation of January 12, December}
Locale_sabbrevmonthname13 {the abbreviation of the 13th month (if any )}
Locale_spositivesign {positive ID}
Locale_snegativesign {negative number}
Locale_ipossignposn {positive position}
Locale_inegsignposn {position of the negative number}
Locale_ipossymprecedes {mon sym precedes pos amt}
Locale_ipossepbyspace {mon sym Sep by space from pos amt}
Locale_inegsymprecedes {mon sym precedes neg AMT}
Locale_inegsepbyspace {mon sym Sep by space from neg AMT}
Locale_fontsignature {font signature}
Locale_siso639langname {ISO abbreviation language name}
Locale_siso1_6ctryname {ISO abbreviation country name}
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
It can be obtained through windows (API functions)
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;
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 (User
Company Name, user name, and so on) as well as 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;
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
Elseif radiobutton2.checked = true then
Exitwindowsex (ewx_shutdown, 1) // safely shut down
Elseif radiobutton3.checked = true then
Exitwindowsex (ewx_reboot, 2) // restart the computer
Elseif radiobutton4.checked = true then
Exitwindowsex (ewx_force, 4) // Force Shutdown
Elseif radiobutton5.checked = true then
Exitwindowsex (ewx_poweroff, 8); // turn off the system and power off
End;