In the Power Management section, the parameters to be used are:
// Power int npowerstatus; Hmodule hKrnl32; Getsystempowerstatusfunc lpfngetsystempowerstatus; |
To initialize the power supply information:
- LoadLibrary ("kernel32.dll")
- Get the function GetSystemPowerStatus address
- Call _updatepowerstatus
void Hge_impl::_initpowerstatus () { = LoadLibrary ("Kernel32.dll"); if (HKrnl32! = NULL ) " GetSystemPowerStatus " ); _updatepowerstatus ();} _initpowerstatus |
Get power information.
voidHge_impl::_updatepowerstatus () {system_power_status ps; if(Lpfngetsystempowerstatus! = NULL && lpfngetsystempowerstatus (&PS)) { if(Ps. ACLineStatus = =1) {Npowerstatus=Hgepwr_ac; } Else if(Ps. Batteryflag < -) {Npowerstatus=PS. BatteryLifePercent; } Else{npowerstatus=hgepwr_unsupported; } } Else{npowerstatus=hgepwr_unsupported; }} _updatepowerstatus |
End, release the dynamic link library.
void Hge_impl::_donepowerstatus () { if(hKrnl32! = NULL) freelibrary (HKRNL32);} _donepowerstatus |
The random number is provided in this module, and the only parameter is the seed of the random number.
Sets the seed of the random number.
void Call Hge_impl::random_seed (int Seed) { if(!seed) g_seed=timegettime (); Else g_seed=seed;} Random_seed |
random_int (int min, int max) |
Linear and congruential produce an integer random number with a range of (Min,max).
int Call Hge_impl::random_int (intint max) { g_seed=214013*g_seed+2531011 ; return min+ (g_seed ^ g_seed>>)% (max-min+1);} Random_int |
random_float (float min, float max) |
Generates a floating-point random number with a range of (Min,max).
float min, float Max) {g_seed =214013 *g_seed+2531011 // return min+g_seed* (1.0f/ 4294967295.0f) * (max-min); return min+ (g_seed>>16 ) * (1.0f /65535.0f ) * (Max-min);} random_float |
In This section, the data is read and written from the specified INI file, so an INI file is required.
Char Szinifile[_max_path]; |
Set (const char* section,const char* name,type value); |
Write different types of parameters.
voidCall Hge_impl::ini_setint (Const Char*section,Const Char*name,intvalue) { Charbuf[ the]; if(szinifile[0]) {sprintf (buf,"%d", value); WritePrivateProfileString (section, name, buf, Szinifile); }}voidCall Hge_impl::ini_setfloat (Const Char*section,Const Char*name,floatvalue) { Charbuf[ the]; if(szinifile[0]) {sprintf (buf,"%f", value); WritePrivateProfileString (section, name, buf, Szinifile); }}voidCall Hge_impl::ini_setstring (Const Char*section,Const Char*name,Const Char*value) { if(szinifile[0]) writeprivateprofilestring (section, name, value, Szinifile);} Setter |
Get (const char* section,const char* name, type value); |
Read the data.
intCall Hge_impl::ini_getint (Const Char*section,Const Char*name,intdef_val) { Charbuf[ the]; if(szinifile[0]) { if(GetPrivateProfileString (section, name,"", BUF,sizeof(BUF), szinifile)) { returnatoi (BUF);} Else{returnDef_val;} } returnDef_val;}floatCall Hge_impl::ini_getfloat (Const Char*section,Const Char*name,floatdef_val) { Charbuf[ the]; if(szinifile[0]) { if(GetPrivateProfileString (section, name,"", BUF,sizeof(BUF), szinifile)) { return(float) atof (BUF); } Else{returnDef_val;} } returnDef_val;}Char* Call Hge_impl::ini_getstring (Const Char*section,Const Char*name,Const Char*def_val) { if(szinifile[0]) getprivateprofilestring (section, name, Def_val, Szinistring,sizeof(szinistring), szinifile); Elsestrcpy (szinistring, def_val); returnszinistring;} Getter |
The next thing is graphics!
Hge source Explor 0x9 Power & Random & Ini