nExtMem() difference

Post Reply
Romeo
Posts: 328
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)

nExtMem() difference

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: nExtMem() difference

Post 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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: nExtMem() difference

Post 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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: nExtMem() difference

Post 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
 
João Santos - São Paulo - Brasil
Romeo
Posts: 328
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)

Re: nExtMem() difference

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: nExtMem() difference

Post 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 );
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
Romeo
Posts: 328
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)

Re: nExtMem() difference

Post by Romeo »

This can resolve my problem.

I'll try

Tks
R
Post Reply