1

Am using the following code to get total physical memory in QB64.

How do I get the total physical memory of the graphics adapter?

Contents of MEM.H

#include<windows.h>
#include<stdio.h>   
#include<tchar.h>
uint64 TotalPhysicalMem ();
uint64 TotalPhysicalMem () {
  MEMORYSTATUSEX statex;
  statex.dwLength = sizeof (statex);
  GlobalMemoryStatusEx (&statex);
  return statex.ullTotalPhys;
}

Contents of MEM.BAS

REM Mem.bas source:
DECLARE LIBRARY "mem"
    FUNCTION TotalPhysicalMem~&&
END DECLARE
PRINT "Total Physical Memory: "
PRINT TotalPhysicalMem
END
eoredson
  • 1,167
  • 2
  • 14
  • 29
  • 1
    [How to get video memory size](http://idebug.blogspot.com/2011/12/how-to-get-video-memory-size.html) might help, but I'm assuming you're familiar with C++ when I recommend that, plus you'd need to see some code or documentation at least. However, the answer to [How get video card memory size ?](https://social.msdn.microsoft.com/Forums/en-US/55b12819-f3bf-472f-9393-307b7acd3e6c/-how-get-video-card-memory-size-?forum=Vsexpressvc) and [this StackOverflow answer](http://stackoverflow.com/a/1866429) are likely worth reading as well, depending on what you're trying to do. –  Aug 09 '16 at 00:08
  • 1
    Nothing wrong with mixing languages if one can't do what another can (or if one does it faster or better than another) –  Aug 10 '16 at 05:35
  • Could someone post some QB64 code with a get GPU RAM sample? – eoredson Aug 23 '16 at 03:31
  • Found the Sys_GetVideoRam() function but don't know how to declare or use it. – eoredson Sep 16 '16 at 22:51
  • 1
    As for actually compiling the function, it's a part of Doom 3's source for idlib, and it appears to rely a lot on ATL/MFC -- something only available with a paid version of Microsoft Visual Studio (incompatible with GNU/MinGW-w64 toolchain that QB64 uses). However, if the preprocessor macro `ID_DEDICATED` is defined, the function simply returns 0, suggesting that it won't actually get video RAM for dedicated graphics cards. For others, I think it returns the amount of system RAM that Windows itself has dedicated to graphics processing, meaning Windows might not know the amount otherwise? –  Sep 17 '16 at 07:47
  • 1
    Also, there is [a bug that affects all versions of Windows 7 and older](https://support.microsoft.com/en-us/kb/2495801). The source code for `Sys_GetVideoRam()` appears to do the same thing as Msinfo32.exe -- returning a signed `int` rather than an `unsigned int`, meaning it might also have the bug where >2 GB of RAM results in a value less than 2 GB! –  Sep 17 '16 at 07:50

0 Answers0