• <tfoot id='d6Q8U'></tfoot>

    <i id='d6Q8U'><tr id='d6Q8U'><dt id='d6Q8U'><q id='d6Q8U'><span id='d6Q8U'><b id='d6Q8U'><form id='d6Q8U'><ins id='d6Q8U'></ins><ul id='d6Q8U'></ul><sub id='d6Q8U'></sub></form><legend id='d6Q8U'></legend><bdo id='d6Q8U'><pre id='d6Q8U'><center id='d6Q8U'></center></pre></bdo></b><th id='d6Q8U'></th></span></q></dt></tr></i><div id='d6Q8U'><tfoot id='d6Q8U'></tfoot><dl id='d6Q8U'><fieldset id='d6Q8U'></fieldset></dl></div>

  • <legend id='d6Q8U'><style id='d6Q8U'><dir id='d6Q8U'><q id='d6Q8U'></q></dir></style></legend>

    1. <small id='d6Q8U'></small><noframes id='d6Q8U'>

        • <bdo id='d6Q8U'></bdo><ul id='d6Q8U'></ul>

        如何在 _T 包装器中使用变量?

        时间:2023-07-02

        1. <small id='nfYds'></small><noframes id='nfYds'>

          <legend id='nfYds'><style id='nfYds'><dir id='nfYds'><q id='nfYds'></q></dir></style></legend>
            <tbody id='nfYds'></tbody>

            <bdo id='nfYds'></bdo><ul id='nfYds'></ul>
            • <tfoot id='nfYds'></tfoot>
                <i id='nfYds'><tr id='nfYds'><dt id='nfYds'><q id='nfYds'><span id='nfYds'><b id='nfYds'><form id='nfYds'><ins id='nfYds'></ins><ul id='nfYds'></ul><sub id='nfYds'></sub></form><legend id='nfYds'></legend><bdo id='nfYds'><pre id='nfYds'><center id='nfYds'></center></pre></bdo></b><th id='nfYds'></th></span></q></dt></tr></i><div id='nfYds'><tfoot id='nfYds'></tfoot><dl id='nfYds'><fieldset id='nfYds'></fieldset></dl></div>

                  本文介绍了如何在 _T 包装器中使用变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想让这个字符串的主机名部分是可变的..目前,它只修复了这个 URL:

                  _T(" --url=http://www.myurl.com/--out=c:\current.png");

                  我想做这样的东西,所以网址是可变的..

                  _T(" --url=http://www." + myurl + "/--out=c:\current.png");

                  更新.以下是我最近的尝试:

                   CString one = _T(" --url=http://www.");CString 二(url->bstrVal);CString 三 = _T("/--out=c:\current.png");CString full = 一+二+三;外壳执行(0,_T("open"),//要执行的操作_T("c:\IECapt"),//应用名称_T(full),//附加参数0,//默认目录SW_HIDE);

                  错误是:Error 1 error C2065: 'Lfull' : undeclared identifier c: est.cpp

                  解决方案

                  它不起作用,因为 _T() 宏仅适用于 constant 字符串文字._T() 的定义如下所示:

                  #ifdef UNICODE#define _T(str) L##str#别的#define _T(str) str

                  由于您显然是在 Unicode 模式下编译,_T(full) 扩展为 Lfull,这显然不是您想要的.

                  在您的情况下,只需传入 full 而不使用 _T() 宏,因为 CString 定义了一个转换运算符到 constwchar_t* 在 Unicode 模式下,const char* 在非 Unicode 模式下.

                  ShellExecute(0, _T("open"), _T("c:\IECapt"), full, 0, SW_HIDE);

                  <小时>

                  请注意,标准 C++ 还提供了一个 std::string 类型和一个 std::wstring 类型,它们的作用与 CString 的作用差不多,因此字符串操作实际上不需要 MFC.std::string 确实提供转换运算符,但确实通过c_str() 提供对底层 C 样式字符串的访问.

                  I want to make the hostname part of this string to be variable.. Currently, it is only fix to this URL:

                  _T(" --url=http://www.myurl.com/ --out=c:\current.png");
                  

                  I want to make something like this, so the URL is changeable..

                  _T(" --url=http://www." + myurl +  "/ --out=c:\current.png");
                  

                  update. Below is my latest attempt:

                        CString one   = _T(" --url=http://www.");
                        CString two(url->bstrVal);
                        CString three = _T("/ --out=c:\current.png");
                        CString full = one + two + three;
                  
                        ShellExecute(0,                           
                                 _T("open"),        // Operation to perform
                                 _T("c:\IECapt"),  // Application name
                                 _T(full),// Additional parameters
                                 0,                           // Default directory
                                 SW_HIDE);
                  

                  The error is : Error 1 error C2065: 'Lfull' : undeclared identifier c: est.cpp

                  解决方案

                  It doesn't work because the _T() macro works only with constant string literals. The definition for _T() looks something like this:

                  #ifdef UNICODE
                  #define _T(str) L##str
                  #else
                  #define _T(str) str
                  

                  Since you're apparently compiling in Unicode mode, _T(full) expands to Lfull, which is obviously not what you want.

                  In your case, just pass in full without the _T() macro since CString defines a conversion operator to a const wchar_t* in Unicode mode, and const char* in non-Unicode mode.

                  ShellExecute(0, _T("open"), _T("c:\IECapt"), full, 0, SW_HIDE);
                  


                  Note that standard C++ also provides a std::string type and a std::wstring type which does pretty much what CString does, so MFC isn't actually required for string manipulation. std::string does not provide a conversion operator, but does provide access to the underlying C-style string via c_str().

                  这篇关于如何在 _T 包装器中使用变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:MSVC++ 警告标志 下一篇:Visual C++ 在函数末尾附加 0xCC (int3) 字节

                  相关文章

                  <small id='MdSUs'></small><noframes id='MdSUs'>

                    • <bdo id='MdSUs'></bdo><ul id='MdSUs'></ul>
                    <i id='MdSUs'><tr id='MdSUs'><dt id='MdSUs'><q id='MdSUs'><span id='MdSUs'><b id='MdSUs'><form id='MdSUs'><ins id='MdSUs'></ins><ul id='MdSUs'></ul><sub id='MdSUs'></sub></form><legend id='MdSUs'></legend><bdo id='MdSUs'><pre id='MdSUs'><center id='MdSUs'></center></pre></bdo></b><th id='MdSUs'></th></span></q></dt></tr></i><div id='MdSUs'><tfoot id='MdSUs'></tfoot><dl id='MdSUs'><fieldset id='MdSUs'></fieldset></dl></div>
                    <legend id='MdSUs'><style id='MdSUs'><dir id='MdSUs'><q id='MdSUs'></q></dir></style></legend>

                    1. <tfoot id='MdSUs'></tfoot>