dcsimg
December 4, 2016
Hot Topics:

Exploring RapiDemo Initializations

  • June 24, 2004
  • By Nancy Nicolaisen
  • Send Email »
  • More Articles »

The next call, CeGetSystemPowerStatusEx(), queries the power status of the CE device. The members of the returned structure specify whether the system is running on AC (wall outlet) or DC (battery) power, whether or not the batteries are currently charging, and the remaining life of main and backup batteries. If the system being queried doesn't support all these status requests, it returns -1 in unsupported members. Its arguments, in the order shown, are the address of a SYSTEM_POWER_STATUS_EX structure, and a Boolean flag that instructs the function to acquire the most current information directly from the driver, as opposed to using older, cached information.

Notice the use of the sprintf() format string "%x" for ACLineStatus, BatteryFlag, BatteryLifePercent, BackupBatteryFlag, and BackupBatteryLifePercent structure members. These are all single byte values. We haven't used the CE side analog of this function in previous articles, and so include the typedef of the SYSTEM_POWER_STATUS_EX structure:

typedef struct _SYSTEM_POWER_STATUS_EX {
   BYTE ACLineStatus;
   BYTE BatteryFlag;
   BYTE BatteryLifePercent;
   BYTE Reserved1;
   DWORD BatteryLifeTime;
   DWORD BatteryFullLifeTime;
   BYTE Reserved2;
   BYTE BackupBatteryFlag;
   BYTE BackupBatteryLifePercent;
   BYTE Reserved3;
   DWORD BackupBatteryLifeTime;
   DWORD BackupBatteryFullLifeTime;
}   SYSTEM_POWER_STATUS_EX;


CeGetSystemPowerStatusEx(
                        (PSYSTEM_POWER_STATUS_EX) &PowerStats, TRUE);
sprintf( szInfoBuff, "%s", "CE Power Stats:" );
m_SysStatsList.InsertString( -1, szInfoBuff );

sprintf( szInfoBuff, "    %s : %x", "AC Line Status",
                          PowerStats.ACLineStatus );
m_SysStatsList.InsertString( -1, szInfoBuff );

sprintf( szInfoBuff, "    %s : %x", "Battery Flag",
                          PowerStats.BatteryFlag);
m_SysStatsList.InsertString( -1, szInfoBuff );

sprintf( szInfoBuff, "    %s : %x", "Battery Life Percent",
         PowerStats.BatteryLifePercent);
m_SysStatsList.InsertString( -1, szInfoBuff );

sprintf( szInfoBuff, "    %s : %li", "Battery Full LifeTime",
         PowerStats.BatteryFullLifeTime);
m_SysStatsList.InsertString( -1, szInfoBuff );

sprintf( szInfoBuff, "    %s : %x", "Backup Battery Flag",
         PowerStats.BackupBatteryFlag);
m_SysStatsList.InsertString( -1, szInfoBuff );

sprintf( szInfoBuff, "    %s : %x", "Backup Battery Life Percent",
         PowerStats.BackupBatteryLifePercent);
m_SysStatsList.InsertString( -1, szInfoBuff );

sprintf( szInfoBuff, "    %s : %li", "Backup Battery Full LifeTime",
         PowerStats.BackupBatteryFullLifeTime);
m_SysStatsList.InsertString( -1, szInfoBuff );

m_SysStatsList.InsertString( -1, "  " );

Next, we retrieve storage status information with a call to CeGetStoreInformation(). The returned structure gives the size of the CE device's object store and the unused space in the object store.

CeGetStoreInformation((LPSTORE_INFORMATION) &StoreInfo);
sprintf( szInfoBuff, "%s", "CE Store Information:" );
m_SysStatsList.InsertString( -1, szInfoBuff );

sprintf( szInfoBuff, "    %s : %li", "Store Size",
                          StoreInfo.dwStoreSize );
m_SysStatsList.InsertString( -1, szInfoBuff );

sprintf( szInfoBuff, "    %s : %li", "Free Size",
                          StoreInfo.dwFreeSize );
m_SysStatsList.InsertString( -1, szInfoBuff );
m_SysStatsList.InsertString( -1, "  " );

Now, we get detailed information on the CE device's processor, with a call to CeGetSystemInfo(). (Several of the processor constants are omitted from the switch() code below, but they are shown in their in their entirety in the SystemStatusPage.cpp file listing.)

CeGetSystemInfo((LPSYSTEM_INFO) &SystemInfo);

sprintf( szInfoBuff, "%s", "CE System Info:" );
m_SysStatsList.InsertString( -1, szInfoBuff );

sprintf( szInfoBuff, "    %s : %li", "Page Size",
                          SystemInfo.dwPageSize );
m_SysStatsList.InsertString( -1, szInfoBuff );

char szProcessorType[48];
switch(SystemInfo.dwProcessorType )
{
   case PROCESSOR_INTEL_386:
      sprintf( szProcessorType, "%s", " PROCESSOR_INTEL_386 ");
      break;
         .
         .
         .
   case PROCESSOR_HITACHI_SH4: 
   default:
      sprintf( szProcessorType, "%s", " Unknown ");
      break;
}    //end switch

   sprintf( szInfoBuff, "    %s : %s", "Processor Type",
                             szProcessorType );
m_SysStatsList.InsertString( -1, szInfoBuff );

sprintf( szInfoBuff, "    %s : %li", "Allocation Granularity",
                          SystemInfo.dwAllocationGranularity);
m_SysStatsList.InsertString( -1, szInfoBuff );

m_SysStatsList.InsertString( -1, "  " );

Finally, we uninitialize RAPI, and make a clean exit from the SystemStatusPage initialization member.

      CeRapiUninit();
return TRUE;

Looking Ahead

In the next installment, we'll look into initializing the System Status and Remote File Access pages of the property sheet control.

About the Author

Nancy Nicolaisen is a software engineer who has designed and implemented highly modular Windows CE products that include features such as full remote diagnostics, CE-side data compression, dynamically constructed user interface, automatic screen size detection, and entry time data validation.

In addition to writing for Developer.com, she has written several books, including Making Win 32 Applications Mobile.





Page 3 of 3



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel