Windows API one-day training (79) globalmemorystatusex Function

Source: Internet
Author: User
Windows API one-day training (79) globalmemorystatusex Function

During software development, the PC System Configurations of different users are often different. For example, some users have poor system memory configurations. when processing a large amount of data, they cannot read a large amount of data into the memory for processing. Some users have a large amount of memory, or the machines are relatively new, so they can load a large amount of data to the memory for processing, so that as the system updates, the processing capability of the software can greatly improve the performance. In this way, you need to understand the system configuration information. One of the most important resources is the memory, which needs to be understood most. You need to call the globalmemorystatusex function to understand the memory allocation.

The globalmemorystatusex function declaration is as follows:

Winbaseapi
Bool
Winapi
Globalmemorystatusex (
_ Out lpmemorystatusex lpbuffer
);

Lpbuffer is the structure of the received memory information.

An example of calling a function is as follows:
#001 //
#002 // current system memory information.
#003 // Cai junsheng 2007/11/27 QQ: 9073204 Shenzhen
#004 void meminfo (void)
#005 {
#006 // obtain the memory information.
#007 memorystatusex memstatex;
#008 memstatex. dwlength = sizeof (memstatex );
#009
#010 if (globalmemorystatusex (& memstatex ))
#011 {
#012 //
#013 const int nbufsize = 512;
#014 tchar chbuf [nbufsize];
#015 zeromemory (chbuf, nbufsize );
#016
#017 // memory usage.
#018 wsprintf (chbuf, _ T ("memory usage: % u %/N"), memstatex. dwmemoryload );
#019 outputdebugstring (chbuf );
#020
#021 // total physical memory.
#022 wsprintf (chbuf, _ T ("total physical memory: % u/N"), memstatex. ulltotalphys );
#023 outputdebugstring (chbuf );
#024
#025 // available physical memory.
#026 wsprintf (chbuf, _ T ("available physical memory: % u/N"), memstatex. ullavailphys );
#027 outputdebugstring (chbuf );
#028
#029 // all memory.
#030 wsprintf (chbuf, _ T ("all memory: % u/N"), memstatex. ulltotalpagefile );
#031 outputdebugstring (chbuf );
#032
#033 // all available memory.
#034 wsprintf (chbuf, _ T ("all available memory: % u/N"), memstatex. ullavailpagefile );
#035 outputdebugstring (chbuf );
#036
#037 // all virtual memory.
#038 wsprintf (chbuf, _ T ("all memory: % u/N"), memstatex. ulltotalvirtual );
#039 outputdebugstring (chbuf );
#040
#041}
#042}

Related Article

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.