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

标签 c windows memory-management

全部, 这里需要一些帮助。我来自纯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/

相关文章:

windows - 根据部分文件名批量创建文件夹并将文件移动到该文件夹​​中

tensorflow - TensorFlow 如何在 Windows 10 上的 GPU 上同时使用共享和专用 GPU 内存?

python - 从 c 字符数组创建 PyString 而不复制

c# - 如何在没有 WMI 的情况下获取在远程计算机上运行的进程的所有者

c++ - JNI system.loadlibrary 问题 - 使用 C 库的 native C++ dll

c - 如何从错误偏移中确定调用的 kernel32.dll 函数

ios - Swift 对象的安全内存

c++ - 是否需要在析构函数中删除指针?

c - 从函数返回值

c - 我的结构设置是否正确,可以将城市(顶点)添加到无向加权图中以找到最短路径?