Delphi .NET (2) Database (71) Delphi IDE (90) Network (39) Printing (3) Strings (12) VCL (83) Windows with Delphi (280)
Exchange Links About this site Links to us 
|
Is PChar(string) ok?
1 comments. Current rating: (1 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:
|