Thread: New to Windows programming, but a few early questions...

  1. #1
    Registered User
    Join Date
    Sep 2005

    New to Windows programming, but a few early questions...

    I'm used to C++ code and for right now I am working out of the "Windows Game Programming for Dummies" book. This book focuses mostly on C, though at times it integrates some C++. In the window creation function, I see data types (in all caps) like LPCTSTR, DWORD, HWND, HMENU, etc. I don't know if they are old C conventions or not. My question is, what do these different types mean? The other question I had is in the default Windows Application project file for Dev C++, the WinMain function looks like this:
    int WINAPI WinMain (HINSTANCE hThisInstance,
                        HINSTANCE hPrevInstance,
                        LPSTR lpszArgument,
                        int nFunsterStil)
    What is the purpose of WINAPI before WinMain? I know that functions have a return type but I thought that WinMain's was int.

    To sum it all up, (hopefully I haven't made this all sound way too complex) what is the purpose of the 'type' labels in all caps? How are they important to Windows? I would appreciate any decent explanation. Thanks.

  2. #2
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Banks of the River Styx
    They're Window's types. The caps (I guess) let us know that they're types. HINSTANCE is really a void *. (You should use HINSTANCE however.) I suppose that was it's just more descriptive, like you'll know that HFONT is a handle to a font. All of the types you mentioned are specific to the Window API, which is C. (But can be used, of course, with C++).

    As for the WINAPI thing, read this.
    Last edited by Cactus_Hugger; 12-17-2005 at 05:12 PM.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    You may also wish to read MSDN: Windows Data Types.

  4. #4
    Registered User
    Join Date
    Sep 2005
    Ah, thanks, suddenly that makes quite a bit more sense. Alright, then here's my next volley...

    I'm using Dev C++ v and apparently I need a winmm.lib file (or an equivalent, but for now I'm going by what the book says) to process sounds and .wav files in my windows app. The book says you need to insert winmm.lib into the project......I'm not sure if it means to use #include or to attach it as an extra source file...I have mmsystem.h, the other necessary file. The function he uses goes like this:
    I'm trying to follow along with the book but the author is very vague. He doesn't explain how or why you need to do things a certain way, he just says "that's the way it's done" or "I could go into more detail, but...". He also does not allow for different compilers, though he doesn't focus on one either. He only outlines the bare bones of what is going on with windows programming so I'm really confused >_<

  5. #5
    Registered User
    Join Date
    Dec 2005
    You have to type the lib name, winmm.lib in some settings. I'm not sure exactly where since it's been a long time since I've messed with win32 so I forgot.

  6. #6
    Registered User
    Join Date
    Aug 2002
    Hermosa Beach, CA
    The .lib files are inputs to the Linker. The .lib file contains the "stub" entry points so that when the loader starts the program, it can hook up the actual code in some DLL to the stub entry point in your program (most Win32 API calls are functions that exist in some DLL). Usually the .dll has the same name as the .lib file, but with the different extension. In visual studio, you specify the .lib files by going to "Project" on the main menu, clicking "Properties", Then choosing Linker/Input/Additional Dependencies. Probably different with your IDE, but hopefully that gets you going in the right direction.
    The crows maintain that a single crow could destroy the heavens. Doubtless this is so. But it proves nothing against the heavens, for the heavens signify simply: the impossibility of crows.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Script errors - bool unrecognized and struct issues
    By ulillillia in forum Windows Programming
    Replies: 10
    Last Post: 12-18-2006, 04:44 AM
  2. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM
  3. How come this only works in Windows nt/2000?
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 08-30-2002, 06:54 PM
  4. A few Windows prog questions
    By Garfield in forum Windows Programming
    Replies: 10
    Last Post: 11-05-2001, 07:06 PM