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
1 answer

Issues Converting wstring to TCHAR

I'm fairly new to programming, and I'm trying to write a program where a user inputs a date, then that date is added to the file directory name, then that file directory is searched. Here is what I'm working with below. I have a number of functions…
Deksam
  • 1
  • 1
  • 1
0
votes
1 answer

Using SHGetSpecialFolderPath+SubFolder with SHFileOperation

I want to delete the folder C:\Users\username\AppData\Roaming\appname when the users uninstall the application appname. First, I use the following code to get the path C:\Users\username\AppData\Roaming: TCHAR dir[MAX_PATH]; dir[0] = '\0'; BOOL ok =…
user565739
  • 1,302
  • 4
  • 23
  • 46
0
votes
1 answer

Store numericals in TCHAR array into an INTEGER variable in VC++. (in UNICODE environment)

I had asked a question very much similar to this in the thread: https://stackoverflow.com/questions/11259474/store-the-numericals-in-char-array-into-an-integer-variable-in-vc W.R.T. the above thread, my question is as follows:: I am working in…
codeLover
  • 3,720
  • 10
  • 65
  • 121
-1
votes
2 answers

How to concatenate an hex to a string in C

I'm trying to create a string that's composed with multiple parts. It starts as a normal string and at some point a function is called that fills a pointer with an hex number. Like shown below. PVOID hexval = NULL; PCTSTR mystring =…
Diego
  • 17
  • 3
-1
votes
1 answer

cannot convert from 'const char *' to 'LPCTSTR'

I'm trying to convert string to 'LPCTSTR', but, i got following error. Error : cannot convert from 'const char *' to 'LPCTSTR' code: std::string str = "helloworld"; LPCTSTR lp = str.c_str(); Also, tried : LPCTSTR lp = (LPCTSTR)str.c_str(); But,…
Jayesh
  • 4,755
  • 9
  • 32
  • 62
-1
votes
2 answers

Marshal C# string to C++ tchar through streamwriter

Related question In C++, I require a TCHAR string (LPTSTR). C# StreamWriters can output ASCII, Unicode, UTF32, etc... Not TCHAR strings. I am not calling a function in C++, I am sending a string message over a named pipe. C#: using…
HL-SDK
  • 160
  • 10
-1
votes
1 answer

CreateProcess with a custom string

I'm trying to run 'CreateProcess' in c, with a custom string that I build. When I'm using a simple string like: TCHAR command[]= _T("MyApp.exe -OPTION1 -OPTION2") Everything seems to work fine. But as I try to build a custom string (with getting…
Isaac
  • 29
  • 6
-1
votes
2 answers

Find the item in the MAP by TCHAR key-name

So, i have two textboxes (defined early) and two vectors: std::vector v1; std::vector v2; and map: std::map m1; std::map :: iterator i1; Map init: void mapInit() { m1[L"one"] = 1; m1[L"two"] =…
FireForce
  • 23
  • 6
-2
votes
3 answers

Concatenate LPCTSTR for MessageBox

How do I concatenate LPCTSTRs for the MessageBox? The syntax in Java is like this LPCTSTR str1 = "String2"; LPCTSTR str2 = ""; LPCTSTR str3 = "String1"; LPCTSTR finalMsg = ""; finalMsg = str1 + str2 + str3; What is the syntax in C++/Win32? Thanks!
mengmeng
  • 1,266
  • 2
  • 22
  • 46
-2
votes
1 answer

Removing Non-printable Unicode characters from a TChar*

I have a tchar* with the string The system time has changed to ‎2018‎ - ‎09‎ - ‎06T15:13 : 52.257364700Z from ‎2018‎ - ‎09‎ - ‎06T15 : 13 : 52.257364700Z. When I put that string here I see characters around my date values and when I print it using…
-2
votes
1 answer

Fastest and elegant way to transform a CHAR to a TCHAR

I usually need to convert a CHAR or CHAR* to a TCHAR or TCHAR* CHAR chDecimal = 'A'; TCHAR Decimal = '\0'; int written = MultiByteToWideChar(CP_ACP, 0, &chDecimal, 1, &Decimal, 1); std::wcout << Decimal << endl; getchar(); Is there a better and…
-2
votes
3 answers

Convert SHORT to TCHAR?

I am coding a Win32 Program,and I want to text out the X pos and Y pos to the Screen, and I want to know how to convert SHORT to TCHAR. don't use the atoi or itoa function. This is a toy program, and I want to text out the position of the mouse,…
user3116182
  • 45
  • 1
  • 4
-3
votes
3 answers

Macro alternative to _T("char") or _TEXT("char")

I know that the _T(x) macro converts a string literal to a unicode/multibyte string based on a define, however I find it very annoying that I must make a underscore and the parenthesis, it really confuses me, I'm not quiet fluent with macros so I…
NULL
  • 31
  • 1
  • 1
  • 6
-5
votes
1 answer

Memory allocation error when simply assigning values

I have the following code in order to obtain a parent directory from a given path. Note: size_t is a typedef for unsigned int. /**************************************************** This function takes a full path to a file, and returns the directory…
Aashishkebab
  • 295
  • 3
  • 10
1 2 3
10
11