Page 1 of 1

nExtMem() difference

Posted: Fri May 06, 2016 6:04 pm
by Romeo
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

Re: nExtMem() difference

Posted: Fri May 06, 2016 6:12 pm
by Antonio Linares
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/librar ... s.85).aspx

And we are going to keep using it.

Re: nExtMem() difference

Posted: Fri May 06, 2016 6:16 pm
by Antonio Linares
If you need your old values you could call GlobalMemoryStatus() but beware of this:

https://msdn.microsoft.com/es-es/librar ... s.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.

Re: nExtMem() difference

Posted: Fri May 06, 2016 6:23 pm
by karinha

Code: Select all

#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
 

Re: nExtMem() difference

Posted: Fri May 06, 2016 6:58 pm
by Romeo
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

Re: nExtMem() difference

Posted: Fri May 06, 2016 8:08 pm
by Antonio Linares
You can implement a function nExtMemOld() that will return the old value:

Code: Select all

HB_FUNC( NEXTMEMOLD )
{
   MEMORYSTATUS mst;

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

   GlobalMemoryStatus( &mst );

   hb_retnl( mst.dwTotalPhys );
}

Re: nExtMem() difference

Posted: Mon May 09, 2016 1:25 pm
by Romeo
This can resolve my problem.

I'll try

Tks
R