China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-31 20:46
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » Programming for calculating available memory under DOS View 3,236 Replies 4
Original Poster Posted 2008-08-08 16:24 ·  中国 广东 深圳 电信
初级用户
Credits 26
Posts 10
Joined 2006-10-03 22:50
19-year member
UID 64453
Gender Male
From shenzhen
Status Offline
MS C Programming Environment

After reading several articles, I tried using memmax memval, but none worked.

Can't get the correct result as from mem or Cs.com.

I remember using DOS calls to do it originally.

Asking if anyone has done it, show off.
Floor 2 Posted 2010-12-17 16:35 ·  中国 广东 广州 华为云
初级用户
Credits 26
Posts 10
Joined 2006-10-03 22:50
19-year member
UID 64453
Gender Male
From shenzhen
Status Offline
Once again, I would like to ask. Under the MS C programming environment, how to obtain the data of available conventional memory similar to that in C:\DOS> MEM /c?
Floor 3 Posted 2010-12-18 17:01 ·  中国 广东 广州 华为云
初级用户
Credits 26
Posts 10
Joined 2006-10-03 22:50
19-year member
UID 64453
Gender Male
From shenzhen
Status Offline
To redirect the output of `mem /c` to `mem1.txt` using `spawnl`, you need to use a shell to handle the redirection. You can use `cmd.exe` with the `/c` option to execute the command and redirect the output. Here's how you can modify the code:

```c
spawnl(_P_WAIT, "cmd.exe", "cmd.exe", "/c", "c:\\dos\\MEM.exe mem /c > mem1.txt", NULL);
```

This will use the Windows command prompt (`cmd.exe`) to execute the `MEM.exe` command with the `/c` option and redirect the output to `mem1.txt`.
Floor 4 Posted 2011-01-05 10:11 ·  中国 北京 联通
高级用户
★★
Credits 506
Posts 187
Joined 2005-12-04 22:41
20-year member
UID 46500
Gender Male
Status Offline
You can check the materials. There is a fixed memory address that marks the available memory. You can directly read the value there to get the available memory.
Floor 5 Posted 2011-01-11 09:11 ·  中国 广东 深圳 电信
中级用户
★★
部落守望者
Credits 351
Posts 140
Joined 2006-06-19 17:11
20-year member
UID 57261
Gender Male
Status Offline
一切从底层开始
Forum Jump: