none
昨天还可以,今天就出错,我的VS有问题吗? RRS feed

  • 问题

  • 就是这个例子,msdn上的。昨晚上还正常运行,今天在运行就好多错误。我自己写的也是。为什么?

    // Forward declarations: BOOL GetProcessList( ); BOOL ListProcessModules( DWORD dwPID ); BOOL ListProcessThreads( DWORD dwOwnerPID ); void printError( TCHAR* msg ); void main( ) { GetProcessList( ); } BOOL GetProcessList( ) { HANDLE hProcessSnap; HANDLE hProcess; PROCESSENTRY32 pe32; DWORD dwPriorityClass; // Take a snapshot of all processes in the system. hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ); if( hProcessSnap == INVALID_HANDLE_VALUE ) { printError( TEXT("CreateToolhelp32Snapshot (of processes)") ); return( FALSE ); } // Set the size of the structure before using it. pe32.dwSize = sizeof( PROCESSENTRY32 ); // Retrieve information about the first process, // and exit if unsuccessful if( !Process32First( hProcessSnap, &pe32 ) ) { printError( TEXT("Process32First") ); // show cause of failure CloseHandle( hProcessSnap ); // clean the snapshot object return( FALSE ); } // Now walk the snapshot of processes, and // display information about each process in turn do { printf( "\n\n=====================================================" ); _tprintf( TEXT("\nPROCESS NAME: %s"), pe32.szExeFile ); printf( "\n-----------------------------------------------------" ); // Retrieve the priority class. dwPriorityClass = 0; hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID ); if( hProcess == NULL ) printError( TEXT("OpenProcess") ); else { dwPriorityClass = GetPriorityClass( hProcess ); if( !dwPriorityClass ) printError( TEXT("GetPriorityClass") ); CloseHandle( hProcess ); } printf( "\n Process ID = 0x%08X", pe32.th32ProcessID ); printf( "\n Thread count = %d", pe32.cntThreads ); printf( "\n Parent process ID = 0x%08X", pe32.th32ParentProcessID ); printf( "\n Priority base = %d", pe32.pcPriClassBase ); if( dwPriorityClass ) printf( "\n Priority class = %d", dwPriorityClass ); // List the modules and threads associated with this process ListProcessModules( pe32.th32ProcessID ); ListProcessThreads( pe32.th32ProcessID ); } while( Process32Next( hProcessSnap, &pe32 ) ); CloseHandle( hProcessSnap ); return( TRUE ); } BOOL ListProcessModules( DWORD dwPID ) { HANDLE hModuleSnap = INVALID_HANDLE_VALUE; MODULEENTRY32 me32; // Take a snapshot of all modules in the specified process. hModuleSnap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, dwPID ); if( hModuleSnap == INVALID_HANDLE_VALUE ) { printError( TEXT("CreateToolhelp32Snapshot (of modules)") ); return( FALSE ); } // Set the size of the structure before using it. me32.dwSize = sizeof( MODULEENTRY32 ); // Retrieve information about the first module, // and exit if unsuccessful if( !Module32First( hModuleSnap, &me32 ) ) { printError( TEXT("Module32First") ); // show cause of failure CloseHandle( hModuleSnap ); // clean the snapshot object return( FALSE ); } // Now walk the module list of the process, // and display information about each module do { _tprintf( TEXT("\n\n MODULE NAME: %s"), me32.szModule ); _tprintf( TEXT("\n Executable = %s"), me32.szExePath ); printf( "\n Process ID = 0x%08X", me32.th32ProcessID ); printf( "\n Ref count (g) = 0x%04X", me32.GlblcntUsage ); printf( "\n Ref count (p) = 0x%04X", me32.ProccntUsage ); printf( "\n Base address = 0x%08X", (DWORD) me32.modBaseAddr ); printf( "\n Base size = %d", me32.modBaseSize ); } while( Module32Next( hModuleSnap, &me32 ) ); CloseHandle( hModuleSnap ); return( TRUE ); } BOOL ListProcessThreads( DWORD dwOwnerPID ) { HANDLE hThreadSnap = INVALID_HANDLE_VALUE; THREADENTRY32 te32; // Take a snapshot of all running threads hThreadSnap = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 ); if( hThreadSnap == INVALID_HANDLE_VALUE ) return( FALSE ); // Fill in the size of the structure before using it. te32.dwSize = sizeof(THREADENTRY32 ); // Retrieve information about the first thread, // and exit if unsuccessful if( !Thread32First( hThreadSnap, &te32 ) ) { printError( TEXT("Thread32First") ); // show cause of failure CloseHandle( hThreadSnap ); // clean the snapshot object return( FALSE ); } // Now walk the thread list of the system, // and display information about each thread // associated with the specified process do { if( te32.th32OwnerProcessID == dwOwnerPID ) { printf( "\n\n THREAD ID = 0x%08X", te32.th32ThreadID ); printf( "\n Base priority = %d", te32.tpBasePri ); printf( "\n Delta priority = %d", te32.tpDeltaPri ); } } while( Thread32Next(hThreadSnap, &te32 ) ); CloseHandle( hThreadSnap ); return( TRUE ); } void printError( TCHAR* msg ) { DWORD eNum; TCHAR sysMsg[256]; TCHAR* p; eNum = GetLastError( ); FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, eNum, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language sysMsg, 256, NULL ); // Trim the end of the line and terminate it with a null p = sysMsg; while( ( *p > 31 ) || ( *p == 9 ) ) ++p; do { *p-- = 0; } while( ( p >= sysMsg ) && ( ( *p == '.' ) || ( *p < 33 ) ) ); // Display the message _tprintf( TEXT("\n WARNING: %s failed with error %d (%s)"), msg, eNum, sysMsg ); }

    错误:

    1>------ 已启动生成: 项目: processthread, 配置: Debug Win32 ------
    1>  processthread.cpp
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(3): warning C4627: “#include <windows.h>”: 在查找预编译头使用时跳过
    1>          将指令添加到“stdafx.h”或重新生成预编译头
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(4): warning C4627: “#include <tlhelp32.h>”: 在查找预编译头使用时跳过
    1>          将指令添加到“stdafx.h”或重新生成预编译头
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(48): error C2146: 语法错误: 缺少“;”(在标识符“GetProcessList”的前面)
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(48): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(49): error C2146: 语法错误: 缺少“;”(在标识符“ListProcessModules”的前面)
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(49): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(49): error C2086: “int BOOL”: 重定义
    1>          f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(48) : 参见“BOOL”的声明
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(49): error C2065: “DWORD”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(49): error C2146: 语法错误: 缺少“)”(在标识符“dwPID”的前面)
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(49): error C2059: 语法错误:“)”
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(50): error C2146: 语法错误: 缺少“;”(在标识符“ListProcessThreads”的前面)
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(50): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(50): error C2086: “int BOOL”: 重定义
    1>          f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(48) : 参见“BOOL”的声明
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(50): error C2065: “DWORD”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(50): error C2146: 语法错误: 缺少“)”(在标识符“dwOwnerPID”的前面)
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(50): error C2059: 语法错误:“)”
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(58): error C2146: 语法错误: 缺少“;”(在标识符“GetProcessList”的前面)
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(58): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(58): error C2086: “int BOOL”: 重定义
    1>          f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(48) : 参见“BOOL”的声明
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(59): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(60): error C2065: “HANDLE”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(60): error C2146: 语法错误: 缺少“;”(在标识符“hProcessSnap”的前面)
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(60): error C2065: “hProcessSnap”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(61): error C2065: “HANDLE”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(61): error C2146: 语法错误: 缺少“;”(在标识符“hProcess”的前面)
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(61): error C2065: “hProcess”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(62): error C2065: “PROCESSENTRY32”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(62): error C2146: 语法错误: 缺少“;”(在标识符“pe32”的前面)
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(62): error C2065: “pe32”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(63): error C2065: “DWORD”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(63): error C2146: 语法错误: 缺少“;”(在标识符“dwPriorityClass”的前面)
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(63): error C2065: “dwPriorityClass”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(66): error C2065: “hProcessSnap”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(66): error C2065: “TH32CS_SNAPPROCESS”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(66): error C3861: “CreateToolhelp32Snapshot”: 找不到标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(67): error C2065: “hProcessSnap”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(67): error C2065: “INVALID_HANDLE_VALUE”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(69): error C3861: “TEXT”: 找不到标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(70): error C2065: “FALSE”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(74): error C2065: “pe32”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(74): error C2228: “.dwSize”的左边必须有类/结构/联合
    1>          类型是“'unknown-type'”
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(74): error C2065: “PROCESSENTRY32”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(74): error C2070: “'unknown-type'”: 非法的 sizeof 操作数
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(78): error C2065: “hProcessSnap”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(78): error C2065: “pe32”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(78): error C3861: “Process32First”: 找不到标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(80): error C3861: “TEXT”: 找不到标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(81): error C2065: “hProcessSnap”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(81): error C3861: “CloseHandle”: 找不到标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(82): error C2065: “FALSE”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(90): error C2065: “pe32”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(90): error C2228: “.szExeFile”的左边必须有类/结构/联合
    1>          类型是“'unknown-type'”
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(90): error C3861: “TEXT”: 找不到标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(94): error C2065: “dwPriorityClass”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(95): error C2065: “hProcess”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(95): error C2065: “PROCESS_ALL_ACCESS”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(95): error C2065: “FALSE”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(95): error C2065: “pe32”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(95): error C2228: “.th32ProcessID”的左边必须有类/结构/联合
    1>          类型是“'unknown-type'”
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(95): error C3861: “OpenProcess”: 找不到标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(96): error C2065: “hProcess”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(97): error C3861: “TEXT”: 找不到标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(100): error C2065: “dwPriorityClass”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(100): error C2065: “hProcess”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(100): error C3861: “GetPriorityClass”: 找不到标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(101): error C2065: “dwPriorityClass”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(102): error C3861: “TEXT”: 找不到标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(103): error C2065: “hProcess”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(103): error C3861: “CloseHandle”: 找不到标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(106): error C2065: “pe32”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(106): error C2228: “.th32ProcessID”的左边必须有类/结构/联合
    1>          类型是“'unknown-type'”
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(107): error C2065: “pe32”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(107): error C2228: “.cntThreads”的左边必须有类/结构/联合
    1>          类型是“'unknown-type'”
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(108): error C2065: “pe32”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(108): error C2228: “.th32ParentProcessID”的左边必须有类/结构/联合
    1>          类型是“'unknown-type'”
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(109): error C2065: “pe32”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(109): error C2228: “.pcPriClassBase”的左边必须有类/结构/联合
    1>          类型是“'unknown-type'”
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(110): error C2065: “dwPriorityClass”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(111): error C2065: “dwPriorityClass”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(114): error C2065: “pe32”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(114): error C2228: “.th32ProcessID”的左边必须有类/结构/联合
    1>          类型是“'unknown-type'”
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(114): error C2064: 项不会计算为接受 1 个参数的函数
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(115): error C2065: “pe32”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(115): error C2228: “.th32ProcessID”的左边必须有类/结构/联合
    1>          类型是“'unknown-type'”
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(115): error C2064: 项不会计算为接受 1 个参数的函数
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(117): error C2065: “hProcessSnap”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(117): error C2065: “pe32”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(117): error C3861: “Process32Next”: 找不到标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(119): error C2065: “hProcessSnap”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(119): error C3861: “CloseHandle”: 找不到标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(120): error C2065: “TRUE”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(124): error C2146: 语法错误: 缺少“;”(在标识符“ListProcessModules”的前面)
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(124): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(124): error C2086: “int BOOL”: 重定义
    1>          f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(48) : 参见“BOOL”的声明
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(124): error C2065: “DWORD”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(124): error C2146: 语法错误: 缺少“)”(在标识符“dwPID”的前面)
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(124): error C2374: “ListProcessModules”: 重定义;多次初始化
    1>          f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(49) : 参见“ListProcessModules”的声明
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(124): error C2059: 语法错误:“)”
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(125): error C2143: 语法错误 : 缺少“;”(在“{”的前面)
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(125): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(167): error C2146: 语法错误: 缺少“;”(在标识符“ListProcessThreads”的前面)
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(167): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(167): error C2086: “int BOOL”: 重定义
    1>          f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(48) : 参见“BOOL”的声明
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(167): error C2065: “DWORD”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(167): error C2146: 语法错误: 缺少“)”(在标识符“dwOwnerPID”的前面)
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(167): error C2374: “ListProcessThreads”: 重定义;多次初始化
    1>          f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(50) : 参见“ListProcessThreads”的声明
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(167): error C2059: 语法错误:“)”
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(168): error C2143: 语法错误 : 缺少“;”(在“{”的前面)
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(168): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(208): error C2065: “DWORD”: 未声明的标识符
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(208): fatal error C1003: 错误计数超过 100;正在停止编译
    ========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========

    为什么?这样?

    VS有问题?

    2013年1月24日 8:47

答案

  • 谢谢,

    把它和windows.h都加里才行。

    这是为什么?昨晚我不是这么做的也行啊。

    但这在控制台里可以。

    我的是MFC程序,我还按这个方法加进去。就出错:

     fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>

    不加windows.h又是上面那些错误,怎么回事?

    MFC程序的话,不用添加 #include <windows.h>,我假设你的这些代码写在 processthread.cpp 文件中,

    那么你需要在 processthread.cpp 文件头部添加

    #include "stdafx.h"
    #include <TlHelp32.h>

    • 已标记为答案 angel725 2013年1月26日 3:59
    2013年1月25日 1:17
  • 1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(3): warning C4627: “#include <windows.h>”: 在查找预编译头使用时跳过
    1>          将指令添加到“stdafx.h”或重新生成预编译头
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(4): warning C4627: “#include <tlhelp32.h>”: 在查找预编译头使用时跳过
    1>          将指令添加到“stdafx.h”或重新生成预编译头

    ----------------------------------------------------------------------
    看这两个warning,您是不是将#include <xxx.h>放到#include "stdafx.h"的前面去了?


    Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.

    • 已标记为答案 angel725 2013年1月26日 4:00
    2013年1月25日 0:56
    版主

全部回复

  • 你新建一个 Win32 控制台应用程序,然后在 stdafx.h 中增加:“#include <tlhelp32.h>”,再把你的代码复制过去。
    2013年1月24日 9:03
  • 谢谢,

    把它和windows.h都加里才行。

    这是为什么?昨晚我不是这么做的也行啊。

    但这在控制台里可以。

    我的是MFC程序,我还按这个方法加进去。就出错:

     fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>

    不加windows.h又是上面那些错误,怎么回事?

    2013年1月24日 10:56
  • 1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(3): warning C4627: “#include <windows.h>”: 在查找预编译头使用时跳过
    1>          将指令添加到“stdafx.h”或重新生成预编译头
    1>f:\visual studio 2012\projects\processthread\processthread\processthread.cpp(4): warning C4627: “#include <tlhelp32.h>”: 在查找预编译头使用时跳过
    1>          将指令添加到“stdafx.h”或重新生成预编译头

    ----------------------------------------------------------------------
    看这两个warning,您是不是将#include <xxx.h>放到#include "stdafx.h"的前面去了?


    Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.

    • 已标记为答案 angel725 2013年1月26日 4:00
    2013年1月25日 0:56
    版主
  • 谢谢,

    把它和windows.h都加里才行。

    这是为什么?昨晚我不是这么做的也行啊。

    但这在控制台里可以。

    我的是MFC程序,我还按这个方法加进去。就出错:

     fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>

    不加windows.h又是上面那些错误,怎么回事?

    MFC程序的话,不用添加 #include <windows.h>,我假设你的这些代码写在 processthread.cpp 文件中,

    那么你需要在 processthread.cpp 文件头部添加

    #include "stdafx.h"
    #include <TlHelp32.h>

    • 已标记为答案 angel725 2013年1月26日 3:59
    2013年1月25日 1:17
  • MFC不用包含WINDOWS.H了

    框架已经包含掉了


    新浪微博http://weibo.com/xianglitian,欢迎围观

    2013年1月25日 2:38