I am only 16, and an "alright" programmer (ie. not expert by any means).
However, I am trying to write a program which uses the modem in Delphi. I have
found that to use the Win API calls, I have to use PChar arrays. Here is my
question : how can I convert a string into a PChar array, and how can I
convert a PChar array into a string?
I had a look in the help and discovered that a PChar array was an array of char
with the last been a #0. So, logicially, I tried using x[1], x is pchar, but
the program stuffed up with a GPF fault.
Also, how can I execute a program from within my Delphi app? Tried using
Pascals "exec" command, but the crt unit isn't there, so it doesn't work!
Any help would be appreiciated.
Kind Regards
Luke Kenny
: I am only 16, and an "alright" programmer (ie. not expert by any means).
: However, I am trying to write a program which uses the modem in Delphi. I have
: found that to use the Win API calls, I have to use PChar arrays. Here is my
: question : how can I convert a string into a PChar array, and how can I
: convert a PChar array into a string?
Lookup stringhandling routines and you'll find StrPCopy which convert a
Pascal-type string into an string usable with the Windows API functions.
: I had a look in the help and discovered that a PChar array was an array of char
: with the last been a #0. So, logicially, I tried using x[1], x is pchar, but
: the program stuffed up with a GPF fault.
: Also, how can I execute a program from within my Delphi app? Tried using
: Pascals "exec" command, but the crt unit isn't there, so it doesn't work!
Procedure Exec_NotePad;
Var
CmdLine : Array(.0..79.) Of Char;
Begin
StrPCopy(CmdLine,'NOTEPAD.EXE');
WinExec(CmdLine,SW_SHOW);
End;
: Any help would be appreiciated.
: Kind Regards
: Luke Kenny
: --
: l...@netspace.net.au
Have fun,
/Johan...!
Try this:
var
s: String;
pc: PChar;
begin
s := 'Anything...' + Chr[0];
pc := @s[1];
{ your code here }
end;
Not sure what your other question means. I've used WinExec successfully
in my Delphi programs.
Good luck.
--
Jon Williams
Riverside, CA USA
jon...@ix.netcom.com
>Hi All,
>I am only 16, and an "alright" programmer (ie. not expert by any means).
>However, I am trying to write a program which uses the modem in Delphi. I have
>found that to use the Win API calls, I have to use PChar arrays. Here is my
>question : how can I convert a string into a PChar array, and how can I
>convert a PChar array into a string?
>I had a look in the help and discovered that a PChar array was an array of char
>with the last been a #0. So, logicially, I tried using x[1], x is pchar, but
>the program stuffed up with a GPF fault.
Delphi has a wealth of functions to help you do this, such as StrPCopy
and StrPas which do what you are looking for. Check in Delphi help
under "Procedures and Functions (Categorical), and select
"String-handling routines (null terminated)". This should point you
in the right direction (har har).
Phil