Level of battery

Level of battery

Postby Maurizio » Fri Nov 11, 2005 4:51 pm

It is possible to have in the programm the level of battery ,
the level of WiFi signal , the amount of memory free ?

Regards Maurizio
www.nipeservice.com
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Postby pawelu » Fri Nov 11, 2005 8:50 pm

Maurizio,

try this:
Code: Select all  Expand view
HB_FUNC (BATTERYINFO)
{
   BOOL iRet;
   SYSTEM_POWER_STATUS_EX status;
   iRet = GetSystemPowerStatusEx (&status, TRUE);

   hb_reta (9);
   hb_stornl ((INT) status.ACLineStatus, -1, 1);
   hb_stornl ((INT) status.BatteryFlag, -1, 2);
   hb_stornl ((INT) status.BatteryLifePercent, -1, 3);
   hb_stornl ((ULONG) status.BatteryLifeTime, -1, 4);
   hb_stornl ((ULONG) status.BatteryFullLifeTime, -1, 5);
   hb_stornl ((INT) status.BackupBatteryFlag, -1, 6);
   hb_stornl ((INT) status.BackupBatteryLifePercent, -1, 7);
   hb_stornl ((ULONG) status.BackupBatteryLifeTime, -1, 8);
   hb_stornl ((ULONG) status.BackupBatteryFullLifeTime, -1, 9);
}
HB_FUNC (MEMINFO)
{
   MEMORYSTATUS st;
   GlobalMemoryStatus (&st);
   
   hb_reta (4);
   hb_stornl ((ULONG) st.dwMemoryLoad, -1, 1);
   hb_stornl ((ULONG) st.dwTotalPhys, -1, 2);
   hb_stornl ((ULONG) st.dwTotalVirtual, -1, 3);
   hb_stornl ((ULONG) st.dwAvailVirtual, -1, 4);
}
HB_FUNC (DISKINFO)
{
  BOOL iRet;
  unsigned __int64 iFreeBytesToCaller, iTotalBytes, iFreeBytes;

  iRet = GetDiskFreeSpaceEx(NULL,
  (PULARGE_INTEGER) &iFreeBytesToCaller,
  (PULARGE_INTEGER) &iTotalBytes,
  (PULARGE_INTEGER) &iFreeBytes);   
  hb_reta (2);
  hb_stornl ((ULONG) iTotalBytes, -1, 1);
  hb_stornl ((ULONG) iFreeBytes, -1, 2);
}


Regards
Pawel
pawelu
 
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland

Postby Maurizio » Sat Nov 12, 2005 9:47 am

Hello Antonio

what include I hav e to link to ?

I try
#include "hbapi.h"

Regards MAurizio
www.nipeservice.com
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Postby Maurizio » Sat Nov 12, 2005 9:50 am

OK I Found

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>
#include <aygshell.h>

Maurizio
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Postby Maurizio » Sat Nov 12, 2005 10:20 am

Hello Antonio
do not work

Regards Maurizio
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Postby josevalle » Sat Nov 12, 2005 10:22 am

Hello.

I know nothing about C and I want to use that functions.

With the code you post I did a File util1.c and put there the function posted by Pawelo and the headers posted by Maurizio. Changed the build.bat for compiling... but How do I use them?

Thanks for your help
Jose Valle
Bilbao
Spain
User avatar
josevalle
 
Posts: 65
Joined: Fri Oct 14, 2005 6:20 pm
Location: Bilbao

Postby Maurizio » Sat Nov 12, 2005 10:27 am

You can put it in a prg with

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>
#include <aygshell.h>

Regards Maurizio
www.nipeservice.com
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Postby pawelu » Sat Nov 12, 2005 11:50 am

to include C source code (Prg file)

Code: Select all  Expand view
#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>
#include <aygshell.h>

// HB_FUNC (NAME)
// {
// }

#pragma ENDDUMP

I have tested info function and return value is Ok. Battery info doesn't work on emulator.

Pawel
pawelu
 
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland

Postby josevalle » Sat Nov 12, 2005 12:50 pm

I have done that but I get an Emty .c file.

Please tell me how do I call that function. I use

BATTERYINFO()

And get a linker error
pda.obj : error LNK2001: unresolved external symbol "void __cdecl HB_FUN_BATTERYINFO(void)" (?HB_FUN_BATTERYINFO@@YAXXZ)
pda.exe : fatal error LNK1120: 1 unresolved externals

Thanks for your help
Jose Valle
Bilbao
Spain
User avatar
josevalle
 
Posts: 65
Joined: Fri Oct 14, 2005 6:20 pm
Location: Bilbao

Postby pawelu » Sat Nov 12, 2005 4:51 pm

Jose,

Function BATTERYINFO must be declared with #pragma BEGINDUMP and #pragma ENDDUMP section. Return value is 9-elements array. Function should be include in .prg file.

Code: Select all  Expand view
Function Test ()

   Local aBatInfo := BatteryInfo ()

Return .T.

#pragma BEGINDUMP

// #include file

HB_FUNC (BATTERYINFO)
{
   // function body
}

#pragma ENDDUMP


This works.
Pawel
pawelu
 
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland

Postby josevalle » Sat Nov 12, 2005 7:32 pm

Thanks Pawel, now it also works for me.

I did not thing that it was so easy to use C functions.
Jose Valle
Bilbao
Spain
User avatar
josevalle
 
Posts: 65
Joined: Fri Oct 14, 2005 6:20 pm
Location: Bilbao

Postby Maurizio » Mon Nov 14, 2005 9:22 am

Hello Antonio

Thanks it works very well , it is possible check the level of the wireless to ?

Regards Maurizio
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm


Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 4 guests

cron