相关疑难解决方法(0)

C++将字符串(或char*)转换为wstring(或wchar_t*)

string s = "????";
wstring ws = FUNCTION(s, ws);
Run Code Online (Sandbox Code Playgroud)

我如何将s的内容分配给ws?

搜索谷歌并使用了一些技术,但他们无法分配确切的内容.内容失真.

c++ string wstring

157
推荐指数
11
解决办法
24万
查看次数

如何在c ++中将字符串转换为LPWSTR

任何人都可以帮助转换stringLPWSTR

string command=obj.getInstallationPath()+"<some string appended>"  
Run Code Online (Sandbox Code Playgroud)

现在我打算把它作为参数传递给 CreateProcessW(xx,command,x...)

但是,createProcessW()只接受LPWSTR,所以我需要转换stringLPWSTR

提前致谢

c++ visual-c++

12
推荐指数
3
解决办法
3万
查看次数

将字符串转换为 LPWSTR

我很难将字符串转换为LPWSTR这样我可以使用该PathStripToRoot()函数。

好吧,MSDN 文档说我需要LPTSTR变量(http://msdn.microsoft.com/en-us/library/windows/desktop/bb773757(v=vs.85).aspx),但 Visual Studio 2013 说我需要LPWSTR.

这是我的函数的代码片段:

fileStat fileCreate(const string& targetFile)
{
    fileStat filez;

    fstream file(targetFile.c_str());
    if (!file)
    {
        cout << "File does not exist" << endl;
    }

    std::ifstream in(targetFile, ios::binary | ios::ate);
    int a = in.tellg();
    cout << "File size(bytes): " << in.tellg() << endl << endl;
    file.close();


    wstring stemp = strChange(targetFile);
    LPCWSTR result = stemp.c_str();

    /* Tried the below code but that did not work
    LPWSTR ws …
Run Code Online (Sandbox Code Playgroud)

c++ string unicode winapi

5
推荐指数
1
解决办法
1万
查看次数

如何在C++中使用没有头的DLL

请帮忙.一个有一个DLL文件.我知道它的功能和参数.如何在Eclipse中使用MinGW?

c++ eclipse dll winapi mingw

2
推荐指数
1
解决办法
9634
查看次数

c ++'CA2W':找不到标识符

为什么我得到'CA2W':找不到标识符

for(DWORD i = 0; i < numMaterials; i++)    // for each material...
    {
        material[i] = tempMaterials[i].MatD3D;    // get the material info
        material[i].Ambient = material[i].Diffuse;    // make ambient the same as diffuse
        USES_CONVERSION;    // allows certain string conversions
        // if there is a texture to load, load it
        D3DXCreateTextureFromFile(d3ddev,
                                            CA2W(tempMaterials[i].pTextureFilename),
                                            &texture[i]);
        texture[i] = NULL;    // if there is no texture, set the texture to NULL
      }
Run Code Online (Sandbox Code Playgroud)

c++ winapi visual-c++

1
推荐指数
1
解决办法
1万
查看次数

如何使用字符串的值将字符串转换为wstring?

我是C++的新手,我遇到了这个问题.我有一个名为DATA_DIR的字符串,我需要将格式化为wstring.

string str = DATA_DIR;
std::wstring temp(L"%s",str); 
Run Code Online (Sandbox Code Playgroud)

Visual Studio告诉我没有与参数列表匹配的构造函数实例.显然,我做错了什么.

我在网上找到了这个例子

std::wstring someText( L"hello world!" );
Run Code Online (Sandbox Code Playgroud)

这显然有效(没有编译错误).我的问题是,如何将存储在DATA_DIR中的字符串值放入wstring构造函数中,而不是像"hello world"这样的任意内容?

c++ string wstring

1
推荐指数
2
解决办法
3437
查看次数

标签 统计

c++ ×6

string ×3

winapi ×3

visual-c++ ×2

wstring ×2

dll ×1

eclipse ×1

mingw ×1

unicode ×1