How can I solve this error?

#include <windows.h>
#include <iostream>
using namespace std;
int main() {
char* file="d:/tester";
WIN32_FIND_DATA FindFileData;
    HANDLE hFind;
hFind = FindFirstFile(file, &FindFileData);  // line of error says argument of type char* is incompatible with parameter of type LPCWSTR
}

I can not understand the error. What is it and how can I solve this error?

I am making a console application and must check if the files are in a directory.

+5
source share
3 answers

You call a function that expects a wide string of characters ( FindFirstFileW). You either change the file to use wchar_t* file = L"d:\\tester";, or use the ASCII version of the function FindFirstFileA.

+1
source

type LPCWSTRis a const pointer to wide char

filein char* file="d:/tester";is a pointer to a regular char

char 1 , char 2 . , ? , . API Windows FindFirstFile, . , L"foo_bar", . wchar_t* file = L"d:\\tester"; , .

+4

UNICODE, ANSI . char *

TCHAR * file = TEXT ( "d:\tester" );

.

+1

All Articles