The simplest Program, but an erro , need help

This is a discussion on The simplest Program, but an erro , need help within the Windows Programming forums, part of the Platform Specific Boards category; Hello all, havent been able to resolve this problem, QUite simple actually, Code: #include <windows.h> int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    2

    The simplest Program, but an erro , need help

    Hello all,

    havent been able to resolve this problem, QUite simple actually,

    Code:
    #include <windows.h>
    int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    {
     	
    	MessageBox(NULL, "\tHello World!", "My first windows app", NULL);
    	return 0;
    }


    The error reported on my Borland C++ compiler is "DEclaration SYntax error"

    No clue as to how it coudl be wrong,
    replies eagerly awaited

    Regards
    Kevin

  2. #2
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,262
    Hazarding a guess, change "APIENTRY" to "WINAPI". Also, change the NULL at the end of your MessageBox call to 0.

  3. #3
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    It might also be possible that your version of the Borland compiler doesn't support Windows programming. Which version is it?

  4. #4
    Registered User
    Join Date
    Mar 2005
    Location
    Juneda
    Posts
    287
    the last 'NULL' param should be 'MB_OK' or other defined to use here; maybe an '(int)NULL' will work but I'm not sure about that.
    Niara

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    maybe an '(int)NULL' will work but I'm not sure about that.
    I don't think so.

    Which version of Borland C++ do you have? 5.5?
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #6
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Hazarding a guess, change "APIENTRY" to "WINAPI".
    APIENTRY is defined as WINAPI. They are both just fancy ways of saying __stdcall.

  7. #7
    Registered User
    Join Date
    Mar 2005
    Location
    Juneda
    Posts
    287
    that should work:
    Code:
    #include <windows.h>
    int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    {
     	
    	MessageBox(NULL, "\tHello World!", "My first windows app", (UINT)NULL);
    	return 0;
    }
    Niara

  8. #8
    Registered User
    Join Date
    Oct 2005
    Posts
    2
    thanx for the prompt replies, tried everything suggested, none worked, not a problem with compiler as was able to develop other applicatiosn with it, ( a program to indicate memory available) , so it is not with the compiler,

    the program that Niara suggested doesn't seem to work, neither do any of the changes suggested, all combinations have been made and tried.

    Well sometimes the simplest of things bewilder us,
    Looking forward to more replies

    kevin

  9. #9
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Code:
    #include <windows.h>
    #include <tchar.h>
    int __stdcall WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    {
     	
    	MessageBox(NULL, _T("Hello World!"), _T("My first windows app"), MB_OK);
    	return 0;
    }
    If that code doesn't work, then you have a problem with your compiler.

  10. #10
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    > The error reported on my Borland C++ compiler
    Of course, we still have no clue as to which version of the compiler you're using.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  11. #11
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Maybe use HWND_DESKTOP as the first argument of MessageBox:
    Code:
    #include <windows.h>
    int WINAPI WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    {
     	
    	MessageBox(HWND_DESKTOP,"Hello","Hello", MB_OK);
    	return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 12:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 12:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 09:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21