Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Convert a string to PWideChar ??

2,944 views
Skip to first unread message

Reddy Palle

unread,
Aug 13, 2002, 10:28:49 AM8/13/02
to
Lookup function StringToWideChar() in the online Help.

-- Reddy Palle.

"Peter Falkesand" <pe...@datavara.se>
> Hi, i need to convert a edit1.text (TCaption) to an PWideChar , how do i
> do??
>
> I have a DLL that want's a PWideChar as a parameter, which is a path to a
> file, so how do i convert a path i have in a edit field into an pWideChar
??
>

Peter Falkesand

unread,
Aug 13, 2002, 10:23:08 AM8/13/02
to
Hi, i need to convert a edit1.text (TCaption) to an PWideChar , how do i
do??

I have a DLL that want's a PWideChar as a parameter, which is a path to a
file, so how do i convert a path i have in a edit field into an pWideChar ??

Rgrds, Peter


Peter Falkesand

unread,
Aug 13, 2002, 10:36:08 AM8/13/02
to
i'we tried that, but it gives me an access violation..

Could you show me an small example ??

Rgrds, Peter

"Reddy Palle" <reddyp@> skrev i meddelandet news:3d5917a1@dnews...

Reddy Palle

unread,
Aug 13, 2002, 12:14:46 PM8/13/02
to

"Peter Falkesand" <pe...@datavara.se> wrote in message
news:3d59195e@dnews...

> i'we tried that, but it gives me an access violation..
>
> Could you show me an small example ??

function TestWideString(const S: string): Boolean;
var
PW: PWideChar;
Len: Integer;
begin
Len := 2 * (Length(S) + 1);
PW := AllocMem(Len);
try
StringToWideChar(S, PW, Len);
{ Your function Call }
finally
FreeMem(PW);
end;
end;

-- Reddy Palle


Andy Hill

unread,
Aug 13, 2002, 2:05:44 PM8/13/02
to

I think you can just use a wide string like:

var
WideSt: WideString;
pWideCh: PWideChar;
begin
Wide:=Edit1.Text;
pWideCh:=@WideSt[1];
CallProcWithPWideChar(pWideCh);

Andy.

Andy Hill

unread,
Aug 13, 2002, 2:06:42 PM8/13/02
to
Ooops, I mean:

var
WideSt: WideString;
pWideCh: PWideChar;
begin

WideSt:=Edit1.Text;
pWideCh:=@WideSt[1];
CallProcWithPWideChar(pWideCh);

lemz

unread,
Oct 18, 2002, 9:40:12 AM10/18/02
to
var
pch : PWideChar;

pch := PWideChar(edit1.text);


0 new messages