QT中使用 WinExec API 参数不支持中文路径的解决办法

在QT中使用WinExec时,发现如果调用外部程序,如果路径或者参数含有中文路径,可能导致无法打开应用程序或者无法使用参数,解决办法,下面是简单的解决办法:

QString strImagePath = "c:/中文路径/测试/0000.mp4"
std::string strVideoPath = strImagePath.toLocal8Bit().toStdString();//
std::string strPath = "TyFilePlayer\\TyFilePlayer.exe "+ strVideoPath ;//第一个参数为exe的路径
WinExec(strPath.c_str(),SW_SHOW);

结论

不支持中文还是编码问题,虽然打印出来,路径是乱码,但是实际上能运行程序

Guess you like

Origin blog.csdn.net/abcd552191868/article/details/110549209