Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert char* to TCHAR[ ]? [duplicate]

char*  stheParameterFileName = argv[1]; //I'm passing the file name as  a parameter.
TCHAR szName [512];

How can I convert char* to TCHAR []?

like image 596
parth patel Avatar asked Dec 27 '22 04:12

parth patel


1 Answers

If you include the header file:

#include "atlstr.h"

Then you can use the A2T macro as below:

// You'd need this line if using earlier versions of ATL/Visual Studio
// USES_CONVERSION;

char*  stheParameterFileName = argv[1];
TCHAR szName [512];
_tcscpy(szName, A2T(stheParameterFileName));
MessageBox(NULL, szName, szName, MB_OK);

Details on MSDN

like image 139
John Sibly Avatar answered Dec 31 '22 14:12

John Sibly