QFileInfo info("./records.db"); std::string str = info.absoluteFilePath().toStdString(); //將QString轉換為string std::wstring wstr(str.length(), L' '); //初始化寬字節wstr std::copy(str.begin(), str.end(), wstr.begin()); //將str復制到wstr LPCWSTR path = wstr.c_str(); //將wstr轉換為C字符串的指針,然后賦值給path
轉換過程:QString->string->wstring->LPCWSTR
