Delphi .NET (2) Database (71) Delphi IDE (89) Network (39) Printing (3) Strings (12) VCL (83) Windows with Delphi (280)
Exchange Links About this site Links to us 
|
Is PChar(string) ok?
3 comments. Current rating: (2 votes). Leave comments and/ or rate it.
Q: Is it ok to cast a string to a pchar?
A: Yes. Delphi long strings (the default string type in 32-bit Delphi) are designed specifically to allow typecasting to PChar.
The following code is valid (with Delphi 2/3/4):
 | |  | | procedure p;
var
s : string;
begin
s := 'Hello world';
SetWindowText (GetActiveWindow, PChar(s));
end; | |  | |  |
Comments:
|
Maty486 from Czech Republic
|
 |
|
|
yes, i agree
|
|
anonymous from Lithuania
|
|
|
|
absolutely
|
|
anonymous from Singapore
|
 |
|
|
|
|