怎样获取程序运行时占用的资源(系统,GDI,用户)

wuxfBrave 2000-11-15 09:41:00
...全文
169 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zzh 2000-11-16
  • 打赏
  • 举报
回复
可以利用API函数来获取。例如GlobalMemory之类的函数,
在Windows系统编程内幕这本书中有讲到的
wuxfBrave 2000-11-16
  • 打赏
  • 举报
回复
那是整个系统的资源状况,我要看的是某个程序占用的资源,因为他可能不断变化
bookhunter 2000-11-15
  • 打赏
  • 举报
回复
#define gfsr_systemresources 0
#define gfsr_gdiresources 1
#define gfsr_userresources 2

typedef long (CALLBACK* getres)(int);

void main()
{
HINSTANCE hinst = LoadLibrary("rsrc32.dll");
if (hinst != null)
{
getres pgetres = (getres)GetProcAddress(hinst, "_MyGetFreeSystemResources32@4");

if (pgetres)
{
long lsysres = (*pgetres)(gfsr_systemresources);
long lgdires = (*pgetres)(gfsr_gdiresources);
long lusrres = (*pgetres)(gfsr_userresources);
printf("system resource: %d\n", lsysres);
printf("gdi resource: %d\n", lgdires);
printf("user resource: %d\n", lusrres);
return;
}
printf("error getting pointer to _mygetfreesystemresources32()\n");
return;
}
printf("error loading rsrc32.dll. you must run this under win95 only and with the resource meter installed.\n\n");
}

2,586

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 资源
社区管理员
  • 资源
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧