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
6
  • 1
    How to get video memory size 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 ? and this StackOverflow answer are likely worth reading as well, depending on what you're trying to do. Commented Aug 9, 2016 at 0: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) 😀 Commented Aug 10, 2016 at 5:35
  • Could someone post some QB64 code with a get GPU RAM sample? Commented Aug 23, 2016 at 3:31
  • 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? Commented Sep 17, 2016 at 7:47
  • 1
    Also, there is a bug that affects all versions of Windows 7 and older. 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! Commented Sep 17, 2016 at 7:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.