char array to LPCTSTR conversion in c

前端 未结 8 850

Does anyone know how to convert a char array to a LPCTSTR in c?

Edit:

For more reference, I need to add an integer to a string then convert that string to LP

8条回答
  •  北海茫月
    2021-01-02 03:49

    I'm not sure if you figured something out in the end but I had the same problem and following worked well for me:

    int  comPortNum = 5;
    char comPortName[32];
    sprintf((LPTSTR)comPortName, TEXT("\\\\.\\COM%d"), comPortNum);
    HANDLE h = CreateFile(comPortName,other arguments);
    

提交回复
热议问题