为什么CloseToolHelp32Snapshot未定义
zqqq1 2006-08-03 01:29:23 msdn的代码改后如下:
BOOL CPacketSub::IsProcessExist(DWORD dwPid)
{
HANDLE hProcessSnap = NULL;
BOOL bRet = FALSE;
PROCESSENTRY32 pe32 = {0};
// Take a snapshot of all processes in the system.
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hProcessSnap == INVALID_HANDLE_VALUE)
return (FALSE);
// Fill in the size of the structure before using it.
pe32.dwSize = sizeof(PROCESSENTRY32);
// Walk the snapshot of the processes, and for each process,
// display information.
if (Process32First(hProcessSnap, &pe32))
{
MODULEENTRY32 me32 = {0};
do
{
if (pe32.th32ProcessID == dwPid)
{
CloseToolhelp32Snapshot(hProcessSnap);
return TRUE;
}
}
while (Process32Next(hProcessSnap, &pe32));
bRet = FALSE;
}
else
bRet = FALSE; // could not walk the list of processes
// Do not forget to clean up the snapshot object.
CloseToolhelp32Snapshot(hProcessSnap);
return (bRet);
}
开始我用的是Closehandle,但是发现长时间运行后会出现虚拟内存耗尽的情况,查msdn,说必须用CloseToolhelp32Snapshot,改后,却报CloseToolhelp32Snapshot' : undeclared identifier的错误,我在头文件中包含了#include <Tlhelp32.h>,也 Toolhelp.lib了,可是为什么还出这样的错误