我正在使用 Shell 命令启动一个进程。我的开发环境是 C++/QT Creator/QT Libraries 和 Windows APIs。
如何处理 HINSTANCE 返回值? if (hInstance < 32) 代码抛出编译错误
437: error: ISO C++ forbids comparison between pointer and integer
HINSTANCE hInstance = ShellExecute(0, QString("open").toStdWString().c_str(), Path.toStdWString().c_str(), 0, 0, SW_SHOWNORMAL);
if (hInstance < 32)
qDebug() << "Error";
最佳答案
如果有人仍在为此苦苦挣扎,这里有一个避免警告的解决方案:
int retValue = static_cast<int>(reinterpret_cast<uintptr_t>(ShellExecute(<etc>)));
参见 When is uintptr_t preferred over intptr_t?有关 uintptr_t 的更多评论
关于c++ - 如何在QT Creator中检查ShellExecute命令返回(HINSTANCE)代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10905648/