Program returns an error of, expected PWideChar instead of string
procedure TForm1.Button1Click(Sender: TObject);
var
mailtoStr, subject, body : string;
begin
mailtostr := 'mailto:theirEmail@hotmail.com';
subject := '?Subject=Email Subject';
body := '&Body=Email Body';
ShellExecute(Self.Handle,
nil,
mailtostr +
subject+
body,
nil,
nil,
SW_NORMAL);
end;
so I changed my code to …
StringToWideChar('mailto:'+MailToStr+'?Subject=' + edSubject.Text+'&Body=' + edBody.Text, MailToWideChar, Length('mailto:'+MailToStr+'?Subject=' + edSubject.Text+'&Body=' + edBody.Text));
in otherwords put it all on one line and changed the rest of the procedure to…
ShellExecute(Self.Handle,
nil,
MailToWideChar,
nil,
nil,
SW_NORMAL);
But getting a run-time exception error at the StringToWideCharLine :S
..any idea why?
All you have to do is to put the string inside
PChar()to ‘cast’ it to aPChar.