Compared with desktop PCs, Windows Mobile devices have very limited resources. At present, the latest equipment is generally 128M RAM + 256M Flash, and then externally expanded 4G memory card. However, the resources and RAM and Flash of Windows Mobile devices are still quite impressive for an 8-bit microcontroller whose RAM and Flash are calculated by Byte. When programming, there is no need to stingy into calculating global variables with Byte as before. Although this is the case, both the program and the OS run in RAM. The most depressing thing is that because the RAM is not large enough, when running some software, you have to close the running program to make room for it. Such hard-pressed days were often encountered in the past.
As you all know, on Windows Mobile devices, we can check the current usage status of device resources through settings->system->memory, but this requires a few hands, clicks on the screen, and troublesome. We generally like to be lazy. It would be great to let this information be displayed on the interface in real time. Therefore, many companies’ software displays the usage status of equipment resources on the interface in real time, such as Spb, Resco, many, many.
In fact, there is a related program in the Sample that comes with the WM6.0 SDK, which is located in the "\PocketPC\CPP\win32\MemWatcher" folder. This project is a plug-in for today's interface written in native code. After compilation, a dll file and a cab installation file are generated. We can install the cab file directly on the device, and then display it in the settings of the today interface. As shown in Figure 1 below:
Figure 1: MemWatcher's today plug-in
Of course, we can also introduce GetDiskFreeSpaceEx in coredll through platform invoke, and calculate the current resource usage based on the Total Free Bytes and Total Bytes obtained. As shown in Figure 2: The left side is the running effect of the program, and the right side is the information of settings->system->memory. Through comparison, it can be found that the resource information displayed by them is the same.
Figure 2: Program for calculating memory usage
Attach the MemWatcher installation package of today's plug-in: memwatchercab.CAB.rar , after downloading, directly change the file name to memwatchercab.CAB, and then install it on the device. And the source file of the resource program: GetStorageCard.zip
Reference article: Display Device memory information with P/Invoke