gpt4 book ai didi

c - 以编程方式在 Windows 中获取可用 RAM?

转载 作者:太空宇宙 更新时间:2023-11-04 05:03:11 25 4
gpt4 key购买 nike

全部, 这里需要一些帮助。我来自纯Java背景,对C编程了解不多。基本上我需要编写一个 C 程序(并创建一个可执行文件)来输出 Windows 机器 (XP/2008/7) 上的可用字节数 (RAM)

我对此做了一些研究,发现有一个名为 GlobalMemoryStatusEx 的函数,还有一个链接: http://msdn.microsoft.com/en-us/library/aa366589(v=vs.85).aspx

我已经用 gcc 安装了 cygwin,但上面的程序甚至不能为我编译。我知道我在这里做了一些愚蠢的事情..

$ gcc hello.c -o hello.exe
hello.c:3:19: error: tchar.h: No such file or directory
hello.c: In function `main':
hello.c:7: error: `MEMORYSTATUSEX' undeclared (first use in this function)
hello.c:7: error: (Each undeclared identifier is reported only once
hello.c:7: error: for each function it appears in.)
hello.c:7: error: expected `;' before `statex'
hello.c:9: error: `statex' undeclared (first use in this function)

非常感谢任何帮助!

最佳答案

正如 larsmans 所说,cygwin 不是 Windows native 编译器。除了 MinGW,您还可以考虑 Visual C++ 2010 Express .

关于c - 以编程方式在 Windows 中获取可用 RAM?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5031791/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com