与“ LPCWSTR”类型的参数不兼容; [英] Incompatible with parameter of type "LPCWSTR"

查看:152
本文介绍了与“ LPCWSTR”类型的参数不兼容;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <iostream>
#include <dos.h>
using namespace std;

class Dir
{
public:
    char* cat;
    Dir()
    {
        cout << "(C:/*)\n";
        cat = new char[50];
        cin >> cat;
    }

    void virtual ShowFiles()
    {
    }

};


class Inside : public Dir
{
public:
    void virtual ShowFiles()
    {
        HANDLE hSearch;
        WIN32_FIND_DATA pFileData;

        hSearch = FindFirstFile(cat, &pFileData);
        if (hSearch != INVALID_HANDLE_VALUE)
            do
            {
                //  if ((pFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
                cout << pFileData.cFileName << "\n";
            } while (FindNextFile(hSearch, &pFileData));
            FindClose(hSearch);
    }
};
int main()
{
    Dir *obj1[2];
    obj1[1] = new Inside;
    obj1[1]->ShowFiles();
    return 0;
}

所以我有一个程序,我需要用动态char cat显示所有文件在目录中,但是它可以在Borland C ++中编译,但是在Visual Studio 15 + Resharper中不起作用。 严重性代码说明项目文件行
类型为 char *的错误(活动)参数与类型为 LPCWSTR的参数不兼容

So I have a program, I need to show with dynamic char cat all file in directory, but it is compilable in Borland C++ but in Visual Studio 15 + Resharper it doesn't work. Severity Code Description Project File Line Error (active) argument of type "char *" is incompatible with parameter of type "LPCWSTR"

推荐答案

要在Visual C ++中编译代码,您需要使用多字节char WinAPI函数而不是Wide char函数。

To compile your code in Visual C++ you need to use Multi-Byte char WinAPI functions instead of Wide char ones.

项目->属性->常规->字符集选项设置为使用多字节字符集

这篇关于与“ LPCWSTR”类型的参数不兼容;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆