This site is temporarily down. Please come back. Is PChar(string) ok?
DelphiFAQ Home Search:

Is PChar(string) ok?

 

comments4 comments. Current rating: 5 stars (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';
  // set the current window's caption
  SetWindowText (GetActiveWindow, PChar(s));
end;

Content-type: text/html

Comments:

2006-08-12, 15:41:55
Maty486 from Czech Republic  
rating
yes, i agree
2009-06-16, 13:09:27
anonymous from Lithuania  
absolutely
2009-09-18, 02:09:23
anonymous from Singapore  
rating
2012-11-12, 05:33:16
anonymous from United States  

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: