What are you trying to do with it? The C in LPCTSTR stands for Constant. So you are maybe better off without changing it's permissions.

I think you need to use _tcscpy() to do the conversion.

Hope this helps

No. LPCTSTR is defined as const char *. No conversion needed except typecasting to remove the const attribute. Depending upon what is going to be done this may or may not be a good idea.

Example:

int main()
{
  LPCTSTR s = "Hello";
  char *p = const_cast<char*>(s);
  return 0;
}

No. LPCTSTR is defined as const char *. No conversion needed except typecasting to remove the const attribute. Depending upon what is going to be done this may or may not be a good idea.

Example:

int main()
{
  LPCTSTR s = "Hello";
  char *p = const_cast<char*>(s);
  return 0;
}

thank you ,i write your cord ....

LPCTSTR s = _T("Hello");
char *p = const_cast<char*>(s);

error C2440: 'const_cast' : cannot convert from 'LPCTSTR' to 'char *'

help me ,thank you :)

are you compiling for UNICODE. If you are using VC++ 2005 that is the default.

If yes, then typecasting won't work. you have to use a conversion function to convert from wchar_t* to char*

This article has been dead for over six months. Start a new discussion instead.