Results 1 to 3 of 3

Thread: How does this code work...

  1. #1

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    I got the following code from parksie, that had a messagebox show the Windows Dir.
    But I don't understand what the first line does:

    The first line:
    Code:
    TCHAR pcBuf[MAX_PATH];
    The entire code:
    Code:
    TCHAR pcBuf[MAX_PATH];
    	GetWindowsDirectory(pcBuf, MAX_PATH);
    	MessageBox(pcBuf, "Windows folder!", MB_OK);
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    TCHAR is a universal character type -- if you compile for ANSI or MBCS (multi-byte character set) then it resolves to char. If you compile for Unicode it resolves to wchar_t (a 2-byte type).

    So, the first line:
    Code:
    TCHAR pcBuf[MAX_PATH];
    This allocates an array of TCHAR with size MAX_PATH (a constant defined in the Windows header files, and I think it's 260).
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    Thank you! That helped!
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width