線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1273
推到 Plurk!
推到 Facebook!

請問如何取得虛擬記憶體大小?

尚未結案
nlj859
資深會員


發表:139
回覆:375
積分:322
註冊:2004-03-20

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-08-20 00:47:10 IP:219.80.xxx.xxx 未訂閱
請問如何取得虛擬記憶體大小及其相關資訊? 謝謝.
zilch
中階會員


發表:5
回覆:87
積分:78
註冊:2002-09-24

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-08-20 01:25:44 IP:218.166.xxx.xxx 未訂閱
GlobalMemoryStatus The GlobalMemoryStatus function obtains information about the system's current usage of both physical and virtual memory.     To obtain information about the extended portion of the virtual address space, or if your application may run on computers with more than 4 GB of main memory, use the GlobalMemoryStatusEx function.     VOID GlobalMemoryStatus(   LPMEMORYSTATUS lpBuffer   // memory status structure ); Parameters lpBuffer  [out] Pointer to a MEMORYSTATUS structure. The GlobalMemoryStatus function stores information about current memory availability into this structure.  Return Values This function does not return a value.     Remarks You can use the GlobalMemoryStatus function to determine how much memory your application can allocate without severely impacting other applications.     The information returned by the GlobalMemoryStatus function is volatile. There is no guarantee that two sequential calls to this function will return the same information.     On computers with more than 4 GB of memory, the GlobalMemoryStatus function can return incorrect information. Windows 2000 reports a value of -1 to indicate an overflow. Earlier versions of Windows NT report a value that is the real amount of memory, modulo 4 GB. For this reason, on Windows 2000, use the GlobalMemoryStatusEx function instead.    On Intel x86 computers with more than 2 GB and less than 4 GB of memory, the GlobalMemoryStatus function will always return 2 GB in the dwTotalPhys member of the MEMORYSTATUS structure. Similarly, if the total available memory is between 2 and 4 GB, the dwAvailPhys member of the MEMORYSTATUS structure will be rounded down to 2 GB. If the executable is linked using the /LARGEADDRESSWARE linker option, then the GlobalMemoryStatus function will return the correct amount of physical memory in both members.     Example The program following shows a simple use of the GlobalMemoryStatus function.
//  Sample output:
//  c:>global
//  The MemoryStatus structure is 32 bytes long.
//  It should be 32.
//  78 percent of memory is in use.
//  There are   65076 total Kbytes of physical memory.
//  There are   13756 free Kbytes of physical memory.
//  There are  150960 total Kbytes of paging file.
//  There are   87816 free Kbytes of paging file.
//  There are  1fff80 total Kbytes of virtual memory.
//  There are  1fe770 free Kbytes of virtual memory.    #include     // Use to change the divisor from Kb to Mb.    #define DIV 1024
// #define DIV 1    char *divisor = "K";
// char *divisor = "";    // Handle the width of the field in which to print numbers this way to
// make changes easier. The asterisk in the print format specifier
// "%*ld" takes an int from the argument list, and uses it to pad and
// right-justify the number being formatted.
#define WIDTH 7    void main(int argc, char *argv[])
{
  MEMORYSTATUS stat;      GlobalMemoryStatus (&stat);      printf ("The MemoryStatus structure is %ld bytes long.
",
          stat.dwLength);
  printf ("It should be %d.
", sizeof (stat));
  printf ("%ld percent of memory is in use.
",
          stat.dwMemoryLoad);
  printf ("There are %*ld total %sbytes of physical memory.
",
          WIDTH, stat.dwTotalPhys/DIV, divisor);
  printf ("There are %*ld free %sbytes of physical memory.
",
          WIDTH, stat.dwAvailPhys/DIV, divisor);
  printf ("There are %*ld total %sbytes of paging file.
",
          WIDTH, stat.dwTotalPageFile/DIV, divisor);
  printf ("There are %*ld free %sbytes of paging file.
",
          WIDTH, stat.dwAvailPageFile/DIV, divisor);
  printf ("There are %*lx total %sbytes of virtual memory.
",
          WIDTH, stat.dwTotalVirtual/DIV, divisor);
  printf ("There are %*lx free %sbytes of virtual memory.
",
          WIDTH, stat.dwAvailVirtual/DIV, divisor);
}
 
nlj859
資深會員


發表:139
回覆:375
積分:322
註冊:2004-03-20

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-08-20 09:29:05 IP:219.80.xxx.xxx 未訂閱
我使用AIDA32所看到的情形是像底下那樣: 使用GlobalMemoryStatus所看到的是"交換空間"的大小,不曉得它所秀出來的"虛擬記憶體是指什麼,還有沒有其它API可顯示相關資訊的? 謝謝. 發表人 - nlj859 於 2004/08/20 15:15:41
conundrum
尊榮會員


發表:893
回覆:1272
積分:643
註冊:2004-01-06

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-08-20 13:43:50 IP:61.221.xxx.xxx 未訂閱
類似EVEREST Home Edition http://www.snapfiles.com/get/everest.html 在KTOP內就有了 找找有原始碼不過不一定是你要的 基本上 那都是調用系統的資訊 也可以說參考值和 reg 等資料 虛擬記憶體 2000 xp 2003 pagefile.sys 這檔案交換 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=54467 http://delphi.ktop.com.tw/topic.php?topic_id=18624 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=28254 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=25676 很多 請自行收尋把 http://delphi.ktop.com.tw/topic.php?topic_id=47103 http://delphi.ktop.com.tw/topic.php?topic_id=32546 發表人 - conundrum 於 2004/08/20 20:56:09
系統時間:2024-04-29 11:18:15
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!