Alpha Video Training
Results 1 to 1 of 1

Thread: Total Physical Memory for Windows 7 and 8 computers

  1. #1
    "Certified" Alphaholic
    Real Name
    Raymond Lyons
    Join Date
    Apr 2000
    Carlsbad, CA

    Default Total Physical Memory for Windows 7 and 8 computers

    As you may know, Win_Memory_Info() is supposed to be able to return the total amount of RAM a computer has. However, for that purpose it only works on Windows XP machines, not on Win7 or Win8. As the "Win" prefix in Alpha indicates, this function makes use of an MS Windows function and it is the MS function that does not work in Win 7 or 8.

    Below is an alternative function that works on XP, Win7 and Win8 (but only returns total memory). For those who may not know it is even possible, note that my function is a 2 in 1 function, i.e., the main function contains a 2nd function that is used by the main one (the 2nd one uses a Windows function). The main (top) function is really there only to convert bytes into gigabytes, something that could have been done in the 2nd function (I have my reasons to keep them separate but it is not a necessity). For the top function I have not used a "Win" prefix (Z_Win instead) because I think Alpha reserves Win_ for functions that use Windows functions and returns the raw windows information, which for memory is always in bytes.

    Edit: Note that Ira Perlow has point out that a5_os_info() can also return total memory using the .TotalVisibleMemorySize property. That function and mine should both return the same number in bytes.

    Raymond Lyons

    'Date Created: 28-Apr-2013 05:59:40 PM
    'Last Updated: 28-Apr-2013 10:44:33 PM
    'Created By  : Ray lyons
    'Updated By  : Ray Lyons
    FUNCTION Z_Win_Total_Ram AS N ()
    'Description:Get total Ram for this computer in Gigabyes
    	dim ptr as P
    	dim Ram_in_kb as n
    '*****Function below used by one above***no need to separate them or use**********
    '*****local variables. It can just be part of the above function in the Control Panel*****
    FUNCTION Win_Physical_Memory AS P (computer = "." as c)
    'DESCRIPTION:Retrieve the computer's physical memory in bytes
    dim objWMIService as p
    dim colItems as p
    dim objItem as p
    if computer = ""
    computer = "."
    end if
    on error resume next
    objWMIService = ole.GetObject("winmgmts:" + chr(92) + chr(92) + computer + "\root\CIMV2")
    colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
        For Each objItem In colItems
    end function
    Last edited by Raymond Lyons; 05-02-2013 at 03:22 PM.

Similar Threads

  1. Total Physical Memory for Windows 7 and 8 computers
    By Raymond Lyons in forum Alpha Five Version 11 - Desktop Applications
    Replies: 5
    Last Post: 05-02-2013, 03:40 PM
  2. Out of windows memory
    By BDennis in forum Alpha Five Version 4
    Replies: 7
    Last Post: 01-11-2003, 06:02 PM
  3. Out of Windows memory
    By Steve Pick in forum Alpha Five Version 5
    Replies: 12
    Last Post: 12-25-2002, 12:48 PM
  4. Out of Windows Memory??
    By Jimmie1234 in forum Alpha Five Version 4
    Replies: 3
    Last Post: 08-07-2002, 03:04 PM
  5. Out Of Windows Memory
    By Phil Rolf in forum Alpha Five Version 4
    Replies: 11
    Last Post: 05-28-2001, 02:30 PM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts