error: conversion from 'QByteArray' to 'LPCWSTR {aka const wchar_t*}' is ambiguous NULL);

直接粘贴错误的代码:

	mutex = ::CreateFile(
            QString(gCfgPath + gMainPluginName + "_mutex").toLatin1(),
			GENERIC_READ,
			FILE_SHARE_READ,
			&sa,
			OPEN_ALWAYS,
			0,
			NULL);
	}

其实,主要是下面这一行的问题。返回类型是QByteArray。

            QString(gCfgPath + gMainPluginName + "_mutex").toLatin1(),

改为

QString(gCfgPath + gMainPluginName + "_mutex").toStdWString().c_str(),
即可。返回值是 const wchar_t* ,也就是 LPCWSTR 。

猜你喜欢

转载自blog.csdn.net/caokunchao/article/details/79853186
今日推荐