TCHAR concatenation?

This is a discussion on TCHAR concatenation? within the C++ Programming forums, part of the General Programming Boards category; Hey, I'm trying to launch a browser window when I click on a dialog button in a vis c++ app. ...

  1. #1
    Registered User gazsux's Avatar
    Join Date
    Mar 2002
    Posts
    72

    TCHAR concatenation?

    Hey,

    I'm trying to launch a browser window when I click on a dialog button in a vis c++ app. However, the function i'm using only launches if a specific path to a html file is given. I don't know where the user may run the application from so i'm getting the current directory. However, I need to be able to add in the local path to the file and I don't know how to add that path to the current directory I get. Here's what i'm currently doing:

    Code:
    if(!::GetCurrentDirectory(sizeof(currentDirectory)-1, currentDirectory)){
    				ShellExecute(NULL, "open", currentDirectory, NULL, NULL, SW_SHOWNORMAL);
    			}

    currentDirectory is an array of TCHARs. I'm wanting to launch from currentDirectory + "/game/index.html".

    Any ideas how I can concatenate the local path to currentDirectory?

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    What type does currentDirectory have to be? Maybe make a small program and work on combining an array of char types with a string literal via strcpy(), and then see if that works with an array of TCHAR's.

  3. #3
    Registered User gazsux's Avatar
    Join Date
    Mar 2002
    Posts
    72
    It has to be LPTSTR, which is some Microsoft specific format and that's pretty much all I know about it.

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,265
    Use the function _tcscat().

    LPTSTR is defined as either wchar_t* or char* depending on if _UNICODE is defined. If _UNICODE isn't defined, then you could just use strcat(), but it's best to use _tcscat() to handle either case.

  5. #5
    Registered User gazsux's Avatar
    Join Date
    Mar 2002
    Posts
    72
    That sorted it, thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My progress.. thnx to Cprogramming forumites
    By csonx_p in forum Windows Programming
    Replies: 6
    Last Post: 05-21-2008, 02:17 AM
  2. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 01:17 AM
  3. String types and conversions (TCHAR)
    By csonx_p in forum Windows Programming
    Replies: 3
    Last Post: 05-07-2008, 03:33 AM
  4. How to use FTP?
    By maxorator in forum C++ Programming
    Replies: 8
    Last Post: 11-04-2005, 03:17 PM
  5. How does fwrite handle tchar?
    By MiamiCuse in forum C Programming
    Replies: 7
    Last Post: 11-03-2005, 11:44 AM

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