Qt在Win10下調用系統的軟鍵盤

1.在windows下使用Qt調用系統的軟鍵盤可以使用:

QDesktopServices::openUrl(QUrl("osk.exe", QUrl::TolerantMode)); 

在win7系統下可以使用,但是換到win10下則出現錯誤

ShellExecute 'osk.exe' failed (error 2).

win10下調用系統的軟鍵盤:

  PVOID OldValue = nullptr;
    BOOL bRet = Wow64DisableWow64FsRedirection(&OldValue);
    QString csProcess = "C:\\Windows\\System32\\osk.exe";
    QString params="";
    ShellExecute(nullptr, L"open", (LPCWSTR)csProcess.utf16(), (LPCWSTR)params.utf16(), nullptr, SW_SHOWNORMAL);
    if (bRet)
    {
        Wow64RevertWow64FsRedirection(OldValue);
    }

親測可行。

大家也可以學習一下該博客:https://blog.csdn.net/flushhip/article/details/83008317

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章