FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour nExtMem() difference
Posts: 340
Joined: Thu Jan 25, 2007 03:53 PM
nExtMem() difference
Posted: Fri May 06, 2016 06:04 PM

Hi all,

My PC has Windows 7 32bit with 4 Gb/RAM

In my old version of FWH (8.10) the function nExtMem() gives 2147483647 (2GB)

In my new version of FWH (16.01 build 2) the same function nExtMem() gives 3219574784 (2,998... gb)

Is there any logic relation between them ?

I need to know it because i implemented a protection of my sw on hardware customer pc (memory,HD,CPU,...) and when i upgrade my the software on customer pc, i must be sure that is the same PC.

Any help ?

Tks
Romeo

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: nExtMem() difference
Posted: Fri May 06, 2016 06:12 PM
Romeo,

We migrated to Windows API GlobalMemoryStatusEx() as it provides a better result than GlobalMemoryStatus(), thats why it changed.

https://msdn.microsoft.com/es-es/library/windows/desktop/aa366589(v=vs.85).aspx

And we are going to keep using it.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: nExtMem() difference
Posted: Fri May 06, 2016 06:16 PM
If you need your old values you could call GlobalMemoryStatus() but beware of this:

https://msdn.microsoft.com/es-es/library/windows/desktop/aa366586(v=vs.85).aspx

On computers with more than 4 GB of memory, the GlobalMemoryStatus function can return incorrect information, reporting a value of –1 to indicate an overflow. For this reason, applications should use the GlobalMemoryStatusEx function instead.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM
Re: nExtMem() difference
Posted: Fri May 06, 2016 06:23 PM
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   LOCAL cMemoria, nBytes, nKBytes, nMBytes, nGBytes

   nBytes  := nExtMem()
 
   nKBytes := nBytes / 1014
 
   nMBytes := nKBytes / 1024
 
   nGBytes := nMBytes / 1014

   // Com erro - With Error
   //  aAdd( ::aTexto,"Memória: " + cValToChar( Int( nExtMem() / ( 1024 * 1024 ) ) + 1 ) + " MBs" )
   // ? ( "Memóry Error: " + cValToChar( Int( nExtMem() / ( 1024 * 1024 ) ) + 1 ) + " MBs" )

   ? cMemoria := Trans( nExtMem(), "@E 9,999,999,999 Bytes free" )

   ? cMemoria := Trans( ( nExtMem() / ( 1024 * 1024 * 1014 ) ), "@E 999.99 GB Free" )

                                                       // or .97 = 4 Gbs.
   ? cMemoria := Trans( ( nExtMem() / ( 1024 * 1024 * 1014 ) + 1 ), "@E 999.99 GB Total" )

RETURN NIL

// END OF PROGRAM


João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 340
Joined: Thu Jan 25, 2007 03:53 PM
Re: nExtMem() difference
Posted: Fri May 06, 2016 06:58 PM

Understood the new function works well, BUT this not resolved my problem ! :-(

I will be not not able to detect the old RAM detected.

And i cannot sum 1 gb, as suggested, to the total RAM, because if a custmer has just 2 GB of real RAM i will get more than 2 GB of calculate RAM.

Thanks any

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: nExtMem() difference
Posted: Fri May 06, 2016 08:08 PM
You can implement a function nExtMemOld() that will return the old value:

Code (fw): Select all Collapse
HB_FUNC( NEXTMEMOLD )
{
   MEMORYSTATUS mst;

   memset( &mst, 0, sizeof( MEMORYSTATUS ) );
   mst.dwLength = sizeof( MEMORYSTATUS );

   GlobalMemoryStatus( &mst );

   hb_retnl( mst.dwTotalPhys );
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 340
Joined: Thu Jan 25, 2007 03:53 PM
Re: nExtMem() difference
Posted: Mon May 09, 2016 01:25 PM

This can resolve my problem.

I'll try

Tks
R

Continue the discussion