Windows system info

Source: Internet
Author: User
Tags configuration settings repetition
(1 ).
Sendmessage (Application-> handle, wm_syscommand, SC _monitorpower, 1); // disable the monitor
Sendmessage (application. Handle, wm_syscommand, SC _monitorpower,-1); // enable the monitor

Sendmessage (hwnd, wm_syscommand, SC _monitorpower, 0); // disable the monitor
Sendmessage (hwnd, wm_syscommand, SC _monitorpower,-1); // enable the monitor

: Sendmessage (getsafehwnd (), wm_syscommand, SC _monitorpower, 1); // disable the monitor
: Sendmessage (getsafehwnd (), wm_syscommand, SC _monitorpower,-1); // enable the monitor

Monitor. Shutdown ()

(2)
I started to follow the sendmessagege (getjavastopwindow (), wm_syscommand, SC _monitorpower, 2) mentioned in many articles on the Internet. I found that I couldn't close the monitor. I haven't found any problem for a long time. After the monitor is closed, the program can exit. If the keyboard and the mouse are used, the monitor will automatically turn on. Wndclass; wndclass. hinstance = hinstance; wndclass. lpszclassname = szappname; hwnd = createwindow (szappname, text (/"lcddown/"), ws_overlappedwindow, cw_usedefault, null, null, hinstance, null );

(3)
When writing programs such as monitoring, multimedia, and large-scale data processing, we often need to disable screen protection and power management to ensure the normal operation of the program. Generally, screen protection and power management under 95 can be disabled by simulating mouse and keyboard actions, but the same method is applied to 2000/NT, but it is often ineffective, this is related to system settings.
Using the interface API of the Windows platform SDK, you can easily disable screen protection and power management. The only drawback is that this method cannot be applied to Win32 applications under Windows 95. Below, I will introduce the specific method.

Use the systemparametersinfo API to disable screen protection and power management:
Bool systemparametersinfo (
Uint uiaction, // system parameter to retrieve or set
Uint uiparam, // depends on action to be taken
Pvoid pvparam, // depends on action to be taken
Uint fwinini // user profile update Option
);

The following code disables Screen Protection:
Void disablescrsaver ()
{
Bool bscractive;
Systemparametersinfo (spi_getscreensaveactive, 0, & bscractive, 0 );
If (bscractive)
{
Systemparametersinfo (spi_setscreensaveactive, false, null, 0 );
}
}
The following code enables Screen Saver:
Void maid ()
{
Systemparametersinfo (spi_setscreensaveactive, true, null, 0 );
}
Since disabling power protection cannot be used by Win32 applications under Win95, you must first determine whether the current operating system is Win95. Here we assume that the function bool iswin95 () has been used.
The following code disables power protection:
Void disablepmmsaver ()
{
//
// Due to the special nature of power management, the spi_setlowpoweractive command cannot be used directly, but the latency must be set.
//
Systemparametersinfo (spi_getlowpowertimeout, 0, & m_nlowpowertimeout, 0 );
Systemparametersinfo (spi_getpowerofftimeout, 0, & m_npowerofftimeout, 0 );
Systemparametersinfo (spi_setlowpowertimeout, 0, null, 0 );
Systemparametersinfo (spi_setpowerofftimeout, 0, null, 0 );
}

The following code enables power protection:
Void enablepmmsaver ()
{
Systemparametersinfo (spi_setlowpowertimeout, m_nlowpowertimeout, null, 0 );
Systemparametersinfo (spi_setpowerofftimeout, m_npowerofftimeout, null, 0 );
M_nlowpowertimeout = 0;
M_npowerofftimeout = 0;
}
Note:
1 m_nlowpowertimeout and m_npowerofftimeout are used to store the original latency variables. When restoring power protection, set the power protection delay back to the original value;
2 The above code is only used to describe the call sequence. In actual applications, a considerable amount of error handling code is added, which is ignored here.
When writing programs such as monitoring, multimedia, and large-scale data processing, we often need to disable screen protection and power management to ensure the normal operation of the program. Generally, screen protection and power management under 95 can be disabled by simulating mouse and keyboard actions, but the same method is applied to 2000/NT, but it is often ineffective, this is related to system settings.
Using the interface API of the Windows platform SDK, you can easily disable screen protection and power management. The only drawback is that this method cannot be applied to Win32 applications under Windows 95. Below, I will introduce the specific method.

How can I set the time for disabling the monitor through a program?
Modify the registry:
HKEY_LOCAL_MACHINE // system // CurrentControlSet // control // Session Manager // power // acpolicy
HKEY_LOCAL_MACHINE // system // CurrentControlSet // control // Session Manager // power // dcpolicy
HKEY_USERS //. Default // Control Panel // powercfg // powerpolicies // 3 // policies
Systemparametersinfo, systemparametersinfobyval
VB statement
Declare function systemparametersinfo & lib/"USER32/" Alias/"systemparametersinfoa/" (byval uaction as long, byval uparam as long, lpvparam as any, byval fuwinini as long)
Declare function systemparametersinfobyval & lib/"USER32/" Alias/"systemparametersinfoa/" (byval uaction as long, byval uparam as long, byval lpvparam as any, byval fuwinini as long)
Description
Allows you to obtain and set a large number of windows system parameters.
Return Value
Long, non-zero indicates success, and zero indicates failure. Getlasterror is set.
Parameter table
Parameter type and description
Uaction long, which specifies the parameter to be set. Refer to the uaction constant table.
Uparam long, refer to the uaction constant table
Lpvparam any, which is based on the integer, long, and data structure called by reference. For string data, use the systemparametersinfobyval function. For detailed usage, refer to the uaction constant table.
Fuwinini long depends on different parameters and operating systems. The user configuration parameters set with this function are stored in win. ini or the registry, or both. This parameter specifies whether to update user-defined parameters when setting system parameters. It can be zero (update prohibited), or any of the following constants:
Spif_updateinifile updates the user configuration files in the win. ini and (or) registries.
Spif_sendwininichange if spif_updateinifile is set, send a wm_wininichange message to all applications. Otherwise, it does not work. The message indicates that the application has changed the user configuration settings.
Annotation
Before calling this function, pay special attention to defining the lpvparam parameter as a correct data type.
========================================================== ======================================
Uaction constant table -- see systemparametersinfo Function
For more information about these parameters and the Registry or win. ini file, see the Windows user manual. If the parameter is not specified for an action, it is not used. In many cases, system parameters have their own get and set actions, such as spi_getaccesstimeout and spi_setaccesstimeout. In these cases, unless otherwise specified, the only difference between them is that one is used to obtain information and the other is set information. For set entries, only the differences between parameters are listed.
Constant meaning
Spi_getaccesstimeout lpvparam is an accesstimeout structure, in which the timing information of the secondary access feature should be loaded. Before calling a function, uparam must be set to the size of the accesstimeout structure.
Spi_getanimation lpvparam is an animationinfo structure that minimizes and restores animation information during loading windows. Cannot be used in NT 3.51
Spi_getbeep lpvparam is a long data type. If the bell sound is enabled, it is set to true.
Spi_getborder lpvparam is a long-type data that receives a multiplier and controls the border size of a Variable Window.
Spi_getdefaultinputlang lpvparam is a long-type data that receives a 32-bit handle from the default keyboard layout. Cannot be used for NT 3.51
Spi_getdragfullwindows lpvparam is a long data type. If you drag the data in the window, it is set to true. If only one rectangular profile is dragged out, the value is false. NT 4.0 or Windows 95 is required. Windows 95 must have a plus! Yes, or install Windows 95 osr2 directly
Spi_getfasttaskswitch lpvparam is a long data type. It is true if fast task switching is allowed. It must be true in Windows 95 and NT 4.0
Spi_getfilterkeys lpvparam is a filterkeys structure used to load auxiliary access feature information related to the keyboard.
Spi_getfontsmoothing lpvparam is a long data type. If the edge modifier is enabled (to make the font more mellow), it is true. Applicable only to NT 4.0 and with plus! Supported Windows 95
Spi_getgridgranularity lpvparam is a long data, which is set to the grid interval size value.
Spi_gethighcontrast lpvparam is a highcontrast structure used to load auxiliary access feature information related to user monitors. Applicable only to Win95
Spi_geticonmetrics lpvparam is an iconmetrics structure used to load information related to the proportions and arrangement of icons. Applicable only to Windows 95 and NT 4.0
Spi_geticontitlelogfont lpvparam points to a logfont structure. The setting content depends on the font used by the icon title.
Spi_geticontitlewrap lpvparam is a long data type. If you allow automatic line feed on the icon title, set it to true.
Spi_getkeyboarddelay lpvparam is a long-type data set as a keyboard repetition Delay
Spi_getkeyboardpref lpvparam is a long data type. If you prefer to use a keyboard instead of a mouse, set it to true. If this parameter is true, Windows displays the attached keyboard interface information, only applicable to Win95
Spi_getkeyboardspeed lpvparam is a long-type data set as the repeat rate of the keyboard
Spi_getmenudropalignment lpvparam is a long data type. If the pop-up menu is left aligned (default), it is set to false. Otherwise, it is true.
Spi_getminimizedmetrics lpvparam is a minimizedmetrics structure used to load information related to minimizing the ratio and arrangement of windows. Applicable only to Win95
Spi_getmouse lpvparam is the first entry in the long array of three elements. Entry 0 is set to the mousethreshold1 field configured for the user, entry 1 is set to the mousethreshold2 field, and entry 2 is set to mousespeed.
Spi_getmousekeys lpvparam is a mousekeys structure in which secondary access information related to the mouse needs to be loaded. Cannot be used in NT 3.51
Spi_getnonclientmetrics lpvparam is a nonclientmetrics structure in which information about fonts and environments should be loaded. This information will be involved in describing non-customer areas of a window, such as borders and titles. Applicable only to Win95
Spi_getscreensaveactive lpvparam points to an integer. If the Screen Saver is active, set it to true; otherwise, set it to false.
Spi_getscreensavetimeout lpvparam points to an integer. It is set to screen protection latency (in seconds)
Spi_getserialkeys lpvparam is a serialkeys structure used to load auxiliary access feature information related to the input device (used to simulate keyboard input. Applicable only to Win95
Spi_getshowsounds lpvparam is a long data type. If the application should replace the sound with a visual clue, set it to true. It serves the same purpose as the sm_getshowsounds option of the getsystemmetrics function.
Spi_getsnaptodefbutton lpvparam is a long data type. If the cursor is automatically moved to the default button in the new dialog box, it is set to true. Applicable only to NT 4.0
Spi_getsoundsentry lpvparam is a soundsentry structure that is used to load auxiliary access feature information involved in providing visual signs (rather than system sounds) for Windows. Before calling, you must set uparam to the length of the soundsentry structure.
Spi_getstickykeys lpvparam is a stickykeys structure used to load auxiliary access feature information that is involved when a user-ordered key is allowed (rather than simultaneously pressed. Examples of simultaneous buttons include SHIFT +, CTRL +, and ALT +. Before calling, you must set uparam to the length of the stickykeys structure.
Spi_gettogglekeys lpvparam is a ToggleKeys structure. It is required to load the secondary access feature information involved in playing sound prompts after the next enable key (numlock, capslock, scrolllock) is loaded. Windows uses a different voice to indicate the ON or OFF status. Before calling, you must set uparam to the length of the ToggleKeys structure.
Spi_getworkarea lpvparam is a rect structure used to load the workspace of the screen.
Spi_iconhorizontalspacing. If lpvparam is null, uparam indicates the new horizontal distance of the desktop icon, in pixels.
Spi_iconverticalspacing is similar to spi_iconhorizontalspacing, but it only specifies the Vertical spacing of the icon.
Spi_langdriver lpvparam is a string used to hold the name of the new language driver File
The parameters of spi_setaccesstimeout and spi_getaccesstimeout are the same.
The parameters of spi_setanimation and spi_getanimation are the same.
If spi_setbeep uparam is set to true, enable the bell function. If false, disable the function.
Spi_setborder uparam represents a multiplier used to control the size of the window border with variable sizes.
The parameters of spi_setdefaultinputlang and spi_getdefaultinputlang are the same.
Spi_setpattern pattern forces the window from the registry or win. ini to restore the current desktop Solution
Spi_setdeskwallpaper lpvparam represents a string used to hold the name of a bitmap file used as a desktop Wallpaper
Spi_setdoubleclicktime uparam indicates the interval (in milliseconds) between two consecutive double-click operations)
Spi_setdoubleclkheight uparam indicates the new double-click height. For details, refer to the annotation of the getsystemmetrics function.
Spi_setdoubleclkwidth uparam indicates the new double-click width. For details, refer to the annotation of the getsystemmetrics function.
If spi_dragfullwindows uparam is set to true, open the entire window and drag it. Otherwise, set it to false. Applicable only to Win95
Spi_setdragheight uparam indicates the height of a rectangle (in pixels), used to determine when the drag operation starts. Applicable only to Win95
Spi_setdragwidth uparam indicates the width of a rectangle (in pixels), used to determine when the drag operation starts. Applicable only to Win95
If the value of spi_setfasttaskswitch uparam is true, enable quick Task Switching. If the value is false, disable quick task switching.
The parameter spi_filterkeys is the same as that of spi_getfilterkeys.
If spi_setfontsmoothing uparam is set to true, the font is rounded ). Only NT 4.0 and get plus! Supported Win95 (or Windows 95 osr2)
Spi_setgridgranularity uparam indicates the new grid spacing.
The parameter spi_sethighcontrast is the same as that of spi_gethighcontrast.
The parameter spi_seticonmetrics is the same as that of spi_geticonmetrics.
Spi_seticontitlelogfont lpvparam is a logfont structure used to define the font used by the icon title. Uparam specifies the size of the logfont structure. If both are null, the font defined at system startup is used.
When spi_seticontitlewrap uparam is set to true, the icon title is automatically wrapped.
Spi_setkeyboarddelay uparam indicates the duplicate latency of the new keyboard.
If the value of spi_setkeyboardpref is true, it indicates that the user prefers the former compared with the keyboard and mouse. Refer to spi_getkeyboardpref
Spi_setkeyboardspeed uparam indicates the new keyboard repetition rate
Spi_setlangtoggle enables the window to reload the hotkey information from the system registry for exchange between keyboard la s
If spi_setlowpoweractive uparam is set to true, the screen saver mode is enabled. Applicable only to Win95
Spi_setlowpowertimeout uparam represents the latency of the new energy-saving screen saver. Applicable only to Win95
When spi_setmenudropalignment uparam is set to false, the left alignment of the pop-up menu is set. If it is true, the right alignment is set.
The parameter spi_setminimizedmetrics is the same as that of spi_getminimizedmetrics.
Spi_setmouse lpvparam is the first entry of a three-element integer array.

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.