Difference between revisions of "PChar"
From Lazarus wiki
Jump to navigationJump to search (common spelling...) |
(Content moved from "Pchar") |
||
Line 1: | Line 1: | ||
− | + | {{Pchar}} | |
+ | |||
+ | A '''PChar''' is [[Data type]] and a [[Pointer]] to a null-terminated string. The most important application of a PChar is interaction with system libraries like dll's. | ||
+ | |||
+ | Messagebox: | ||
+ | <syntaxhighlight> | ||
+ | var | ||
+ | s: String; | ||
+ | begin | ||
+ | s := 'Test' | ||
+ | Application.MessageBox( PChar(s)),'Title', MB_OK ); | ||
+ | end; | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | Declaration: | ||
+ | <syntaxhighlight> | ||
+ | var | ||
+ | p: PChar; | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | Valid assignments: | ||
+ | <syntaxhighlight> | ||
+ | p := 'This is a null-terminated string.'; | ||
+ | p := IntToStr(45); | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | Invalid assignments: | ||
+ | <syntaxhighlight> | ||
+ | p := 45; | ||
+ | </syntaxhighlight> | ||
+ | The integer value is not casted to a PChar as might be expected. | ||
+ | |||
+ | == See also == | ||
+ | * [[Character and string types]] | ||
+ | |||
+ | [[Category:Data types]] |
Revision as of 21:18, 21 July 2016
A PChar is Data type and a Pointer to a null-terminated string. The most important application of a PChar is interaction with system libraries like dll's.
Messagebox:
var
s: String;
begin
s := 'Test'
Application.MessageBox( PChar(s)),'Title', MB_OK );
end;
Declaration:
var
p: PChar;
Valid assignments:
p := 'This is a null-terminated string.';
p := IntToStr(45);
Invalid assignments:
p := 45;
The integer value is not casted to a PChar as might be expected.