Questions tagged [tchar]

A #define for either char or wchar_t, used for porting ancient windows applications

TCHAR and related preprocessor-defines are used in two places:

  1. Porting ancient windows application to modern UTF-16 APIs.
  2. Describing APIs available in both ANSI and UTF-16 flavor.

If neither of the above fits for you, you really should not be using it:
Is TCHAR still relevant?

#ifdef _UNICODE
    #define TCHAR wchar_t
    // many others
#else
    #define TCHAR char
    // many others
#endif
164 questions
0
votes
2 answers

C++ How can I convert wchar_t* to TCHAR [] (not TCHAR*)

I wants to add a small additional options to a big unit, so I do not want to process a large amount of code. TCHAR szTempFileName[MAX_PATH]; TCHAR lpTempPathBuffer[MAX_PATH]; int uRetVal = 0; GetTempPath(MAX_PATH, // length of the buffer …
Jakooop
  • 19
  • 1
  • 7
0
votes
0 answers

How to create TCHAR array, that contains Upper Case letters from A to Z?

How to create TCHAR array, that contains Upper Case letters from A to Z? Any code samples are welcome! Thank you!
Arthur
  • 3,253
  • 7
  • 43
  • 75
0
votes
2 answers

Compiled Legacy C++ Code in Visual Studio 2015 TCHAR issues

I am working on some legacy code that I am not too familiar with. I encountered an error when I recompiled my project in visual studio 2015 from visual studio 2012. I am having reference errors to function "_getts", which is normally part of…
0
votes
1 answer

C++ help concatenating TCHAR

I recently learned of the ## functionality that i can define in the beginning of my code. I'm trying to compile the following code: #include #include #include #include #include #define paste(x,y)…
Ben Marconi
  • 161
  • 1
  • 1
  • 7
0
votes
1 answer

How do I assign a value to TCHAR* without using a string literal with TEXT()?

I need to assign a value to a TCHAR* variable in C++ and I have been told that this is accomplished using the TEXT() macro. However, I have found that I am only able to do this when using string literals. //This assignment uses a string literal and…
Ben
  • 1,299
  • 3
  • 17
  • 37
0
votes
1 answer

wcscpy Does Not Accept TCHAR in Destination Variable

[VS10] The aim is to copy the drive literal string into the *.dst thus TCHAR *driveIDBase; ... wcscpy_s (driveIDBase, MAX_PATH-3, L"\\\\?\\C:\\*"); This produces the error IntelliSense: no instance of overloaded function "wcscpy_s" matches the…
Laurie Stearn
  • 959
  • 1
  • 13
  • 34
0
votes
2 answers

Array stores name retrieved from GetVolumeInformation weirdly in Visual C++?

I would like to use the GetVolumeInformation call to retrieve the name of a removable device. I can retrieve the name just fine and store into a TCHAR array variable szVolNameBuff. Here is my code for that: // Get Volume Information to check for…
ffrstar777
  • 75
  • 2
  • 10
0
votes
1 answer

How to compare different versions of installed java and print the highest version?

I'm writing a VC++ program that looks for all the installed versions of java in a system (like a single system having java 1.7, 1.8 etc). I want to compare the versions and display them in descending (or ascending order). For instance, it should…
pikaaaaaaaaa
  • 95
  • 12
0
votes
3 answers

Multidimensional array calculating

I've got an array of arrays of TCHAR, where I store file extension. TCHAR *extens[] = { L".*", L".txt", L".bat" }; In order to go through it, I'm calculating it's length. int extCount = sizeof(extens) / sizeof(TCHAR); But for some reason the…
Ivan Petrov
  • 155
  • 2
  • 18
0
votes
1 answer

Gibberish from ReadFile()?

I have redirected the stdout of java.exe using pipe. Now I read the output using ReadFile and char buffer: ReadFile( childStdOUTRd, buffer, sizeof(char) * 4096, &read, NULL); The buffer will be assigned correct data. But if I change it to…
zzy
  • 1,771
  • 1
  • 13
  • 48
0
votes
1 answer

Wrong print out of binary file using _tprintf

I must read a binary file, but I have wrong output. I start from a txt file that contains: 1 100000 Romano Antonio 1250 2 150000 Fabrizi Aldo 2245 3 200000 Verdi Giacomo 11115 4 250000 Rossi Luigi 13630 I generate the relative binary file by with…
Develobeer
  • 425
  • 1
  • 8
  • 19
0
votes
1 answer

Why is there garbage in my TCHAR, even after ZeroMemory()?

I have inherited the following line of code: TCHAR temp[300]; GetModuleFileName(NULL, temp, 300); However, this fails as the first 3 bytes are filled with garbage values (always the same ones though, -128, -13, 23, in that order). I said, well fine…
samoz
  • 56,849
  • 55
  • 141
  • 195
0
votes
1 answer

LPTSTR to LPWSTR conversion using ATL

Suppose I have this: LPTSTR MyString = _T("A string"); void SomeFunction(LPCWSTR param); I can use one of the ATL conversion macros, CT2CW, and the function works as expected: SomeFunction(CT2CW(MyString)); However, if I have something like…
quantumSoup
  • 27,197
  • 9
  • 43
  • 57
0
votes
1 answer

Multi character delimiter in _tcstok_s

I can't find a duplicate for this particular question although there are similar ones for different languages. I am trying to split a string into tokens where my delimiter is a two-character string. My questions is : 1. Is it possible to do it with…
Akshat Goel
  • 538
  • 4
  • 18
0
votes
0 answers

Conversion from TCHAR to std::string, other way than using WideCharToMultiByte?

I have to convert a TCHAR variable (which is a path retrieved with OpenBrowseDir) into a std::string. I'm currently having this code which works. I'm using WideCharToMultiByte. TCHAR path[MAX_PATH]; OpenBrowseDir(path); /*conversion from TCHAR to…
Laura Maftei
  • 1,863
  • 1
  • 15
  • 25