What is PWideChar?
PWideChar is a pointer to a null-terminated string of WideChar values, that is, Unicode characters. PWideChar defines a pointer to a memory location that contains WideChar values (including the #0 character).
What is PChar in Delphi?
PChar defines a pointer to a memory location that contains WideChar values (including the #0 character). In Delphi, one can obtain a PChar value from a string or a WideString, allowing seamless integration with C or C++ applications that expect null-terminated Unicode strings.
What is PChar in C?
PChar is defined as a pointer to a Char type, but allows additional operations. The PChar type can be understood best as the Pascal equivalent of a C-style null-terminated string, i. e. a variable of type PChar is a pointer that points to an array of type Char, which is ended by a null-character (#0).
What is a PChar?
How to convert Unicode PChar to PAnsiChar?
On your Unicode Delphi your PChar maps to PWideChar. But gethostbyname receives PAnsiChar. You need to convert from Unicode to ANSI. In other words, convert your string to AnsiString, and then cast as PAnsiChar. Personally I’d declare the AIP parameter to be AnsiString. That untyped var parameter looks dubious to me.
What is PChar in C++?
The PChar type is a pointer to an Char value. It can also be used to point to characters within a string, as in the example code.
How to convert PChar to AnsiString in Delphi?
On your Unicode Delphi your PChar maps to PWideChar. But gethostbyname receives PAnsiChar. You need to convert from Unicode to ANSI. In other words, convert your string to AnsiString, and then cast as PAnsiChar.
What is pwidechar in Delphi XE8?
The PChar is an alias of PAnsiChar in Delphi 6 and stands for a PWideChar in Delphi XE8. You can solve this issue at line #8 declaring you function (and calling it accordingly) like this: To solve the issue at line #25, change the function declaration like: