在微软学生中心下的visual studio 2008 Professional,申请product Key安装成功都没问题,可是启动后无论编译什么程序都报错,就连个简单的Hello World,都编译出一百多个错误,这是怎么回事,是我的设置有问题么? 我的系统是Vista Ultimate 32位,
1>------ 已启动生成: 项目: win32app, 配置: Debug Win32 ------
1>正在编译...
1>win32Helloworld.cpp
1>e:\users\administrator\documents\visual studio 2008\projects\win32app\win32app\win32helloworld.cpp(1) : error C2146: 语法错误 : 缺少“;”(在标识符“WinMain”的前面)
1>e:\users\administrator\documents\visual studio 2008\projects\win32app\win32app\win32helloworld.cpp(1) : error C2065: “HINSTANCE”: 未声明的标识符
1>e:\users\administrator\documents\visual studio 2008\projects\win32app\win32app\win32helloworld.cpp(1) : error C2146: 语法错误 : 缺少“)”(在标识符“hInstance”的前面)
1>e:\users\administrator\documents\visual studio 2008\projects\win32app\win32app\win32helloworld.cpp(1) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>e:\users\administrator\documents\visual studio 2008\projects\win32app\win32app\win32helloworld.cpp(4) : error C2059: 语法错误 : “)”
1>e:\users\administrator\documents\visual studio 2008\projects\win32app\win32app\win32helloworld.cpp(5) : error C2143: 语法错误 : 缺少“;”(在“{”的前面)
1>e:\users\administrator\documents\visual studio 2008\projects\win32app\win32app\win32helloworld.cpp(5) : error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
1>e:\users\administrator\documents\visual studio 2008\projects\win32app\win32app\win32helloworld.cpp(77) : error C2146: 语法错误 : 缺少“;”(在标识符“CALLBACK”的前面)
1>e:\users\administrator\documents\visual studio 2008\projects\win32app\win32app\win32helloworld.cpp(77) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>e:\users\administrator\documents\visual studio 2008\projects\win32app\win32app\win32helloworld.cpp(77) : error C2146: 语法错误 : 缺少“;”(在标识符“WndProc”的前面)
1>e:\users\administrator\documents\visual studio 2008\projects\win32app\win32app\win32helloworld.cpp(77) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>e:\users\administrator\documents\visual studio 2008\projects\win32app\win32app\win32helloworld.cpp(77) : error C2065: “HWND”: 未声明的标识符
1>e:\users\administrator\documents\visual studio 2008\projects\win32app\win32app\win32helloworld.cpp(77) : error C2065: “UINT”: 未声明的标识符
1>e:\users\administrator\documents\visual studio 2008\projects\win32app\win32app\win32helloworld.cpp(77) : error C2065: “WPARAM”: 未声明的标识符
1>e:\users\administrator\documents\visual studio 2008\projects\win32app\win32app\win32helloworld.cpp(77) : error C2065: “LPARAM”: 未声明的标识符
1>e:\users\administrator\documents\visual studio 2008\projects\win32app\win32app\win32helloworld.cpp(78) : error C2448: “WndProc”: 函数样式初始值设定项类似函数定义
1>生成日志保存在“file://e:\Users\Administrator\Documents\Visual Studio 2008\Projects\win32app\win32app\Debug\BuildLog.htm”

解决方案 »

  1.   

    应该是包含头文件问题.
    包含windows.h这个头文件
      

  2.   

    安装好像没有什么问题啊
    用向导生成个基于对话框的程序,向导结束处报错:error RC2104:undefined keyword or key name:DS_SHELLFONT

    快疯了,花了两三天下载,重装了两遍,问题依旧
      

  3.   

    把windows.h包含进去也不管用,错误还是跟原来一样多!
    #include <windows.h>
    int WINAPI WinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPSTR lpCmdLine,
                       int nCmdShow)
    {
    WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX);
    wcex.style          = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc    = WndProc;
    wcex.cbClsExtra     = 0;
    wcex.cbWndExtra     = 0;
    wcex.hInstance      = hInstance;
    wcex.hIcon          = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
    wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
    wcex.lpszMenuName   = NULL;
    wcex.lpszClassName  = szWindowClass;
    wcex.hIconSm        = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
    if (!RegisterClassEx(&wcex))
    {
    MessageBox(NULL,
    _T("Call to RegisterClassEx failed!"),
    _T("Win32 Guided Tour"),
    NULL); return 1;
    }
    static TCHAR szWindowClass[] = _T("win32app");
    static TCHAR szTitle[] = _T("Win32 Guided Tour Application");
    // The parameters to CreateWindow explained:
    // szWindowClass: the name of the application
    // szTitle: the text that appears in the title bar
    // WS_OVERLAPPEDWINDOW: the type of window to create
    // CW_USEDEFAULT, CW_USEDEFAULT: initial position (x, y)
    // 500, 100: initial size (width, length)
    // NULL: the parent of this window
    // NULL: this application dows not have a menu bar
    // hInstance: the first parameter from WinMain
    // NULL: not used in this application
    HWND hWnd = CreateWindow(
    szWindowClass,
    szTitle,
    WS_OVERLAPPEDWINDOW,
    CW_USEDEFAULT, CW_USEDEFAULT,
    500, 100,
    NULL,
    NULL,
    hInstance,
    NULL
    );
    if (!hWnd)
    {
    MessageBox(NULL,
    _T("Call to CreateWindow failed!"),
    _T("Win32 Guided Tour"),
    NULL); return 1;
    }
    // The parameters to ShowWindow explained:
    // hWnd: the value returned from CreateWindow
    // nCmdShow: the fourth parameter from WinMain
    ShowWindow(hWnd,
    nCmdShow);
    UpdateWindow(hWnd);
        MSG msg;
        while (GetMessage(&msg, NULL, 0, 0))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }    return (int) msg.wParam;}
    LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM)
    {
           PAINTSTRUCT ps;
        HDC hdc;
        TCHAR greeting[] = _T("Hello, World!");    switch (message)
        {
        case WM_PAINT:
            hdc = BeginPaint(hWnd, &ps);        // Here your application is laid out.
            // For this introduction, we just print out "Hello, World!"
            // in the top left corner.
            TextOut(hdc,
                5, 5,
                greeting, _tcslen(greeting));
            // End application-specific layout section.        EndPaint(hWnd, &ps);
            break;
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
            break;
        }    return 0;}
      

  4.   

    1>------ 已启动生成: 项目: console, 配置: Debug Win32 ------
    1>正在编译...
    1>stdafx.cpp
    1>正在编译...
    1>console.cpp
    1>正在编译资源清单...
    1>Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
    1>Copyright (C) Microsoft Corporation.  All rights reserved.
    1>正在链接...
    1>LINK : fatal error LNK1104: 无法打开文件“msvcirtd.lib”
    1>生成日志保存在“file://e:\Users\Administrator\Documents\Visual Studio 2008\Projects\console\console\Debug\BuildLog.htm”
    1>console - 1 个错误,0 个警告
    ========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
      

  5.   

    这种错误,估计是你的Project类型选错了
      

  6.   

    很有可能是系统Vista Ultimate 32位,和vs的安装问题
      

  7.   

    估计还是安装上的问题,以前我装vc6.0时就遇到过类似的情况反正就是执行不起来,后来我直接将别人安装成功的vc6.0文件夹拷过来就可以成功执行了。我前一段时间也装2008一开始就是安装不成功后来安装成功了。建议你采用自定义安装,不要把所有的安装项都选上,尤其是数据库方向的,而且c盘的空间要足。
      

  8.   

    谢谢各位的回答,果然是安装的问题,这回重装了系统然后采用虚拟光驱加载的方式装好后没问题了
       之前是将下载的ISO文件解压到硬盘再安装。