#include <windows.h> 
#include <winperf.h>   // for Windows NT 
#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 
#include <tlhelp32.h>  // for Windows 95 
#include <psapi.h>.......func() {
    .........    HANDLE         hProcessSnap = NULL; 
    BOOL           bRet      = FALSE; 
    PROCESSENTRY32 pe32      = {0};    hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
    pe32.dwSize = sizeof(PROCESSENTRY32);     BOOL pOK = Process32First( hProcessSnap, pe32 );    for ( ; pOK; pOK = Process32Next( hProcessSnap, pe32 ) ) {

    }
    
    .........}
编译报错:
    --------------------Configuration: WatchDog - Win32 Debug--------------------
Compiling...
WatchDogDlg.cpp
E:\VCProject\chinalife\WatchDog\WatchDogDlg.cpp(277) : error C2065: 'PROCESSENTRY32' : undeclared identifierE:\VCProject\chinalife\WatchDog\WatchDogDlg.cpp(277) : error C2065: 'pe32' : undeclared identifierE:\VCProject\chinalife\WatchDog\WatchDogDlg.cpp(279) : error C2065: 'CreateToolhelp32Snapshot' : undeclared identifierE:\VCProject\chinalife\WatchDog\WatchDogDlg.cpp(279) : error C2065: 'TH32CS_SNAPPROCESS' : undeclared identifierE:\VCProject\chinalife\WatchDog\WatchDogDlg.cpp(279) : error C2440: '=' : cannot convert from 'int' to 'void *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style castE:\VCProject\chinalife\WatchDog\WatchDogDlg.cpp(282) : error C2065: 'Process32First' : undeclared identifier
E:\VCProject\chinalife\WatchDog\WatchDogDlg.cpp(284) : error C2065: 'Process32Next' : undeclared identifier..........怎么会这样?我是在2000Server上编译的,难道跟系统有关?我把msdn上的sample code拿过来编译也是如此!!哪位高手指点一二,小弟不胜感激!

解决方案 »

  1.   

    下载一个Microsoft Platform SDK
      

  2.   

    我也是在sdk中用的,下个sdk,把sdk的include加到工程的option里。
      

  3.   

    #include <tlhelp32.h> 改成 #include "tlhelp32.h"
      

  4.   

    #include <tlhelp32.h> 改成 #include "tlhelp32.h"试过,不行。
    下载SDK应该是一个办法,但在微软网站上找不到,不知哪儿有下载
      

  5.   

    http://www.microsoft.com/downloads/details.aspx?FamilyID=eba0128f-a770-45f1-86f3-7ab010b398a3&displaylang=en