Delphi sendmessage 外部程序传值

Procedure TForm1.Button1Click(Sender: TObject);
Var
  FormHwd, OKHandle, EDHwd1, EDHwd2: THandle;
Begin
  FormHwd := FindWindow(nil, '用户登录'); //窗口名称
  If FormHwd > 0 Then
  Begin
    OKHandle := FindWindowEx(FormHwd, 0, PChar('TBitBtn'), Pchar('确定'));//按钮
    EDHwd1 := FindWindowEx(FormHwd, 0, PChar('TEdit'), nil);
    SendMessage(EDHwd1, WM_SETTEXT, 255, Longint(PChar('0')));
    EDHwd2 := FindWindowEx(FormHwd, EDHwd1, PChar('TEdit'), nil);
    SendMessage(EDHwd2, WM_SETTEXT, 255, Longint(PChar('jwc01')));
    SendMessage(OKHandle,BM_CLICK,0,0);
  End;
End;

posted on 2011-12-27 15:00  cn三少<script></script>  阅读(405)  评论(0编辑  收藏  举报

导航