hello everyone..i'm trying to create a simple window using Win API in visual studio 2010 using the code below

#include <Windows.h>

LPCTSTR  g_lptstrClassName="myWindowClass";

LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
    switch(msg)
    {
    case WM_CLOSE:
        DestroyWindow(hwnd);
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hwnd,msg,wParam,lParam);
    }
    return 0;
}

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
    WNDCLASSEX wc;
    HWND hwnd;
    MSG msg;

    wc.cbSize=sizeof(WNDCLASSEX);
    wc.style=0;
    wc.lpfnWndProc=WndProc;
    wc.cbClsExtra=0;
    wc.cbWndExtra=0;
    wc.hInstance=hInstance;
    wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);
    wc.hCursor=LoadCursor(NULL,IDC_ARROW);
    wc.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);
    wc.lpszMenuName=NULL;
    wc.lpszClassName=g_lptstrClassName;
    wc.hIconSm=LoadIcon(NULL,IDI_APPLICATION);

    if(!RegisterClassEx(&wc))
    {
        MessageBox(NULL,"Registration Failed!!","Error!",MB_ICONEXCLAMATION|MB_OK);
        return 0;
    }

    MessageBox(NULL,"Registration successful!!!","OK",MB_OK);

    hwnd=CreateWindowEx(WS_EX_CLIENTEDGE,g_lptstrClassName,"TITLE",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,
        240,120,NULL,NULL,hInstance,NULL);

    if(hwnd==NULL)
    {
        MessageBox(NULL,"Window Creation Failed!","Error",MB_ICONEXCLAMATION|MB_OK);
        return 0;
    }

    ShowWindow(hwnd,nCmdShow);
    UpdateWindow(hwnd);

    while(GetMessage(&msg,NULL,0,0)>0)
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    return msg.wParam;
}

but when i try the following code..i get the following 7 errors

Error 1 error C2146: syntax error : missing ';' before identifier 'PVOID64' c:\program files\microsoft sdks\windows\v5.0\include\winnt.h 222 1 winapi_1

Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft sdks\windows\v5.0\include\winnt.h 222 1 winapi_1

Error 3 error C2146: syntax error : missing ';' before identifier 'Buffer' c:\program files\microsoft sdks\windows\v5.0\include\winnt.h 5940 1 winapi_1

Error 4 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft sdks\windows\v5.0\include\winnt.h 5940 1 winapi_1

Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft sdks\windows\v5.0\include\winnt.h 5940 1 winapi_1

6   IntelliSense: expected a ';'    c:\program files\microsoft sdks\windows\v5.0\include\winnt.h    222 27  

7   IntelliSense: identifier "PVOID64" is undefined c:\program files\microsoft sdks\windows\v5.0\include\winnt.h    5940    5   

could you please tell me what error is this..and where I am going wrong?? thank you.

I tried your code and it worked fine on my x86 computer. Maybe there is something wrong with the VC compiler or with the visual studio. Is it an "Empty project"? If not you need to add #include "stdafx.h" at the beginning of the file.

Yup.. compiled on mine too.. Agree with teo..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.