Home > Back-end >  E2034 always convert 'would be *' to 'const char *' (XE2)
E2034 always convert 'would be *' to 'const char *' (XE2)

Time:10-11

HANDLE hf=CreateFile (AnsiString (Edit1 - & gt; The Text). C_str (),
GENERIC_READ,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL.
NULL);
The first parameter to this function when the character conversion to the problem, and seek counsel

CodePudding user response:

What version are you using c + + builder, looks with cb2009 above the unicode version
Why are you turn widestring ANSI again

CreateFile to HANDLE hf=CreateFileA (...
Or HANDLE hf=CreateFileW (Edit1 - & gt; Text. B_str (),...

CodePudding user response:

Your input CreateFile (in the IDE, and see what are the requirements for all types of parameters, to want what type to what type, don't want disorderly to you

If the request is a wchar * and if you give a ansichar *, the natural to make mistakes

CodePudding user response:

Just see write back have XE2
XE2 is the default unicode
CreateFile==CreateFileW
The first parameter is the WCHAR *, don't turn AnsiString,
Edit1 - & gt; Text. B_str had ()

Or 1/f, said the change the CreateFile CreateFileA
HANDLE hf= CreateFileA (AnsiString (Edit1 - & gt; The Text). C_str (),
GENERIC_READ,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL.
NULL);

CodePudding user response:

Has been in the project options of XE2 _TCHAR mapping set, so the CreateFile are mapped to W or A, engineering options, so just write:

HANDLE hf=CreateFileW (Edit1 - & gt; Text. C_str ()...
Or
HANDLE hf=CreateFileA (AnsiString (Edit1 - & gt; The Text). C_str ()...

CodePudding user response:

Total feeling is called function is needed is a char *, but the 'would be *
Always the convert 'would be *' to 'const char *
  • Related