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

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

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

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

        <bdo id='KuNTL'></bdo><ul id='KuNTL'></ul>
      1. 如何在 _T 包装器中使用变量?

        时间:2023-10-06
      2. <tfoot id='W4GKN'></tfoot>
            • <bdo id='W4GKN'></bdo><ul id='W4GKN'></ul>
                <tbody id='W4GKN'></tbody>
              <legend id='W4GKN'><style id='W4GKN'><dir id='W4GKN'><q id='W4GKN'></q></dir></style></legend>

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

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

                  本文介绍了如何在 _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 包装器中使用变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

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

                  相关文章

                  最新文章

                  • <bdo id='lch2Z'></bdo><ul id='lch2Z'></ul>
                2. <small id='lch2Z'></small><noframes id='lch2Z'>

                    <tfoot id='lch2Z'></tfoot>

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