nExtMem() difference

nExtMem() difference

Postby Romeo » Fri May 06, 2016 6: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
Romeo
 
Posts: 340
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)

Re: nExtMem() difference

Postby Antonio Linares » Fri May 06, 2016 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: nExtMem() difference

Postby Antonio Linares » Fri May 06, 2016 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: nExtMem() difference

Postby karinha » Fri May 06, 2016 6:23 pm

Code: Select all  Expand view

#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
User avatar
karinha
 
Posts: 7814
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: nExtMem() difference

Postby Romeo » Fri May 06, 2016 6: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
Romeo
 
Posts: 340
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)

Re: nExtMem() difference

Postby Antonio Linares » Fri May 06, 2016 8:08 pm

You can implement a function nExtMemOld() that will return the old value:

Code: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: nExtMem() difference

Postby Romeo » Mon May 09, 2016 1:25 pm

This can resolve my problem.

I'll try

Tks
R
Romeo
 
Posts: 340
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 54 guests