Hot to declare a LPTSTR

This is a discussion on Hot to declare a LPTSTR within the Windows Programming forums, part of the Platform Specific Boards category; Code: char* winPath[MAX_PATH]; GetWindowsDirectory(winPath, MAX_PATH); printf("%s\n", winPath); [Warning] passing arg 1 of `GetWindowsDirectoryA' from incompatible pointer type from http://msdn.microsoft.com/library/de...sdirectory.asp : ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    161

    Talking Hot to declare a LPTSTR

    Code:
    char* winPath[MAX_PATH];
      
      GetWindowsDirectory(winPath, MAX_PATH);
      printf("%s\n", winPath);
    [Warning] passing arg 1 of `GetWindowsDirectoryA' from incompatible pointer type
    from http://msdn.microsoft.com/library/de...sdirectory.asp :

    LPTSTR lpBuffer, Pointer to the buffer to receive the null-terminated string..
    How should I declare it? thanx!
    This forum is the best one I've ever seen. Great ppl, great coders

  2. #2
    Dump Truck Internet valis's Avatar
    Join Date
    Jul 2005
    Posts
    357
    GetWindowsDirectory((LPTSTR) winPath, MAX_PATH);
    Here are the definitions:
    Code:
    #define FAR                 far
    typedef wchar_t     TCHAR;
    typedef TCHAR FAR *			LPTSTR;

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    161
    thanx
    This forum is the best one I've ever seen. Great ppl, great coders

  4. #4
    Registered User
    Join Date
    Jul 2005
    Posts
    69
    Actually this is what you want to do:
    Code:
    	TCHAR winPath[MAX_PATH];
    	GetWindowsDirectory(winPath, MAX_PATH);
    The name of a char, or TCHAR, array is already a pointer.

    Regards,
    Brian

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. People sure are serious about their hot sauce...
    By indigo0086 in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 06-26-2008, 03:55 PM
  2. Can you Microwave Regular Hot dogs?
    By Kleid-0 in forum A Brief History of Cprogramming.com
    Replies: 38
    Last Post: 01-11-2005, 01:53 AM
  3. A Miracle has occurred in the realm of Hot Dogs
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 05-08-2004, 04:18 PM
  4. program won't run properly, help needed asap
    By jlmac2001 in forum C Programming
    Replies: 2
    Last Post: 11-16-2002, 09:52 AM
  5. help getting program to work
    By jlmac2001 in forum C Programming
    Replies: 2
    Last Post: 11-13-2002, 11:04 PM

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