| | |
Problem with TCHAR/CHAR
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2009
Posts: 24
Reputation:
Solved Threads: 0
Hello DaniWeb. 
I have a problem with char->tchar conversion, that i cant seem to solve. I want to launch another program, anh the relative path to that program is fetched from MYSQL.
I have tried like anything i could find on google, fx MultiByteToWideChar() - i even gone as far as to write it to a char, write the char to a file, read, and then in tchar format, from the file.
The TCHAR just contains some chineese symbols, and the only readable being "/Patcher" and ".exe".
It really just needs to be LPCTSTR-readable, so my ShellExecute will work.
I use the messagebox to monitor how my TCHAR is doing.
I hope anyone can help me solve this problem.
Cheers

I have a problem with char->tchar conversion, that i cant seem to solve. I want to launch another program, anh the relative path to that program is fetched from MYSQL.
updateBox = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG2), hWnd, updateDiag);
hThread = (HANDLE)_beginthreadex(NULL, 0, Blah::Start, NULL, NULL, NULL);
_stprintf(patcherLoc, _T("%s/Patcher %s.exe"), UPDATE_DIR, row[2]);
strcpy(patcherUrl, row[3]);I have tried like anything i could find on google, fx MultiByteToWideChar() - i even gone as far as to write it to a char, write the char to a file, read, and then in tchar format, from the file.
The TCHAR just contains some chineese symbols, and the only readable being "/Patcher" and ".exe".
It really just needs to be LPCTSTR-readable, so my ShellExecute will work.
MessageBox(hWnd, patcherLoc, _T("Error"), MB_OK | MB_ICONEXCLAMATION);
ShellExecute(NULL, NULL, patcherLoc, NULL, NULL, SW_SHOWNORMAL);I hope anyone can help me solve this problem.
Cheers
-7
#2 33 Days Ago
1) Are you compiling for UNICODE?
2) what compiler
3) how is UPDATE_DIR declared
4) note that %s and %S are not the same thing. See this
2) what compiler
3) how is UPDATE_DIR declared
4) note that %s and %S are not the same thing. See this
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
0
#3 33 Days Ago
Try
wcstombs, strcpy are deprecated..
More secure versions are available..
Take care..
c++ Syntax (Toggle Plain Text)
// wcstombs(char *mbstr,const wchar_t *wcstr, size_t count) // ... CHAR *mbBuf= new CHAR[100]; TCHAR *wcBuf=_T("hello"); #ifdef _UNICODE wcstombs(mbBuf,wcBuf,100); #else strcpy(mbBuf,wcBuf); #endif ... delete[]mbBuf; ...
More secure versions are available..
Take care..
Last edited by cikara21; 33 Days Ago at 6:22 pm.
•
•
Join Date: Oct 2009
Posts: 24
Reputation:
Solved Threads: 0
0
#4 33 Days Ago
•
•
•
•
1) Are you compiling for UNICODE?
2) what compiler
3) how is UPDATE_DIR declared
4) note that %s and %S are not the same thing. See this
2) VC++
3) #define UPDATE_DIR "updateContent"
4) I'll read that, thanks.
•
•
•
•
Try
wcstombs, strcpy are deprecated..c++ Syntax (Toggle Plain Text)
// wcstombs(char *mbstr,const wchar_t *wcstr, size_t count) // ... CHAR *mbBuf= new CHAR[100]; TCHAR *wcBuf=_T("hello"); #ifdef _UNICODE wcstombs(mbBuf,wcBuf,100); #else strcpy(mbBuf,wcBuf); #endif ... delete[]mbBuf; ...
More secure versions are available..
Take care..
- But I cant figure out where, in this code, my own stuff is to be placed.
0
#6 33 Days Ago
•
•
•
•
Thank you for the answer.
- But I cant figure out where, in this code, my own stuff is to be placed.
Why dont you try it first..
There is another example for you..
C++ Syntax (Toggle Plain Text)
/* * mbstowcs(wchar_t *wcString,char *mbString,size_t nCount); */ ... TCHAR *wcBuf=new TCHAR[100]; CHAR *mbBuf="MB STRING"; #ifdef _UNICODE mbstowcs(wcBuf,mbBuf,100); #else strcpy(wcBuf,mbBuf); #endif ... delete[]wcBuf; ...
![]() |
Similar Threads
- strange problem with ascii and char in VS 2008 (C++)
- char** for string array problem (C)
- Problem with converting char to int (C++)
- Problem with a string (char array) and self made strcpy (C++)
- assigning a TCHAR char array to std::string (C++)
- pls help me to convert char to integer. (C)
Other Threads in the C++ Forum
- Previous Thread: Developers Say 'Hello World' to IT
- Next Thread: Need help with a function
| Thread Tools | Search this Thread |
api array beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion count data database delete desktop developer directshow dll download dynamic email encryption error file forms fstream function functions game getline google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text text-file tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






