CreateProcess() c++ file not found

后端 未结 4 1032
星月不相逢
星月不相逢 2021-01-22 15:18

I\'m trying to use CreateProcess to start a child process, however I keep getting error 2, which, according to the documentation is file not found.

4条回答
  •  北恋
    北恋 (楼主)
    2021-01-22 15:48

    With QT the MSDN function TEXT() it doesn't work: QTCreator's compiler return:

    'Lvar' undeclared (first use in this function)

    where var is input of Text(), because of QT whose enable UNICODE and because of that:

        #ifdef UNICODE
    /*
     * NOTE: This tests UNICODE, which is different from the _UNICODE define
     *       used to differentiate standard C runtime calls.
     */
    typedef WCHAR TCHAR;
    typedef WCHAR _TCHAR;
    /*
     * __TEXT is a private macro whose specific use is to force the expansion of a
     * macro passed as an argument to the macro TEXT.  DO NOT use this
     * macro within your programs.  It's name and function could change without
     * notice.
     */
    #define __TEXT(q) L##q
    #else
    typedef CHAR TCHAR;
    typedef CHAR _TCHAR;
    #define __TEXT(q) q
    #endif
    
    #endif
    

    in particular this passage:

    #define __TEXT(q) L##q
    

    in winnt.h included by windows.h
    So, to solve this problem, we have to add this:

    DEFINES -= UNICODE
    

    in the .pro file of the QTCreator's project and it will work.

提交回复
热议问题