1

I have made use of function gethostbyname function to get the host information.The function expects a const char * string but i have a string of type LPWSTR and hence i'm getting the error as

 error C2664: 'gethostbyname' : cannot convert parameter 1 from 'LPWSTR' to 'const char *'

i tried performing a type cast from LPWSTR to const char * as below but the compiler errors seem to go but its not giving the intended result .

  host = gethostbyname((const char *)resource.lpRemoteName); 

i followed up google and made use of Cstring as below for the same but the the function seems to fail.Please let me know the conversion .

    CString strFullName =resource.lpRemoteName;
    host = gethostbyname(strFullName);
Santhosh Pai
  • 2,535
  • 8
  • 28
  • 49

0 Answers0