Board index » delphi » What am I doing wrong (Win API stuff, 2nd part)

What am I doing wrong (Win API stuff, 2nd part)

This is my code:

---------------------- Start code --------------------------

procedure TForm1.btnDailyBackupClick(Sender: TObject);

var
   MyHandle: HWND;
   ProgramPath: PChar;
   Msg: Char;
   S: string;
begin
     Msg := 't';
     ProgramPath := StrAlloc(256);
     StrPCopy(ProgramPath, '\windows\notepad.exe');
     ShellExecute(0,nil,ProgramPath,nil,nil,SW_SHOWNORMAL);
     MyHandle := FindWindow('Notepad',nil);
     SendMessage(MyHandle,WM_CHAR,null,Word(Msg));
end;

---------------------- End code --------------------------

As I step through the code, everything goes fine until I reach the
SendMessage line.  It gives me an error:

Project XXXXX raised exception class EVariantError with message 'Invalid
variant type conversion'.

Say wha??????

--
Joseph I. Ceasar (Yossi)
CLS Computer Solutions

 

Re:What am I doing wrong (Win API stuff, 2nd part)


I believe that your 'null' should be a nil longint, or 0.  I haven;t looked
WM_CHAR in a while and don;t remember the wParam lParam structure for it.

Andy Satori
http://theclassifieds.com/kdWare

Joseph I. Ceasar <j...@nyc.pipeline.com> wrote in article
<50poau$...@news1.t1.usa.pipeline.com>...

Quote

> This is my code:

> ---------------------- Start code --------------------------

> procedure TForm1.btnDailyBackupClick(Sender: TObject);

> var
>    MyHandle: HWND;
>    ProgramPath: PChar;
>    Msg: Char;
>    S: string;
> begin
>      Msg := 't';
>      ProgramPath := StrAlloc(256);
>      StrPCopy(ProgramPath, '\windows\notepad.exe');
>      ShellExecute(0,nil,ProgramPath,nil,nil,SW_SHOWNORMAL);
>      MyHandle := FindWindow('Notepad',nil);
>      SendMessage(MyHandle,WM_CHAR,null,Word(Msg));
> end;

> ---------------------- End code --------------------------

> As I step through the code, everything goes fine until I reach the
> SendMessage line.  It gives me an error:

> Project XXXXX raised exception class EVariantError with message 'Invalid
> variant type conversion'.

> Say wha??????

> --
> Joseph I. Ceasar (Yossi)
> CLS Computer Solutions

Other Threads