向记事本发送中文字符串,你作到了吗??? ( 积分: 0 )

  • 主题发起人 主题发起人 wp231957
  • 开始时间 开始时间
W

wp231957

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button1Click(Sender: TObject);<br>var<br> &nbsp;notepadhandle:thandle;<br> &nbsp;childhandle,child:thandle;<br> &nbsp;s:string;<br> &nbsp;length1:integer;<br> &nbsp;i:integer;<br>begin<br> &nbsp;s:='1234中asdfg国258';<br> &nbsp;length1:=length(s);<br> &nbsp;i:=1;<br> &nbsp;if winexec('c:/windows/notepad.exe',SW_NORMAL)&gt;31 then begin<br> &nbsp; &nbsp;notepadhandle:= findwindow('notepad',nil);<br> &nbsp; &nbsp;if notepadhandle&lt;&gt;0 then begin<br> &nbsp; &nbsp; &nbsp;childhandle:=findwindowex(notepadhandle,0,'edit',nil);<br> &nbsp; &nbsp; &nbsp;if childhandle&lt;&gt;0 then begin<br> &nbsp; &nbsp; &nbsp; &nbsp;while &nbsp;i&lt;=length1 do begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ord(s)&gt;127 then begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sendmessage(childhandle,WM_CHAR,ord(s),0);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sendmessage(childhandle,WM_CHAR,ord(s[i+1]),0);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;i:=i+2;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end else begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sendmessage(childhandle,WM_CHAR,ord(s),0);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;inc(i);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp;END;<br> &nbsp;end;<br>end;
 
procedure TForm1.Button1Click(Sender: TObject);<br>var<br> &nbsp;notepadhandle:thandle;<br> &nbsp;childhandle,child:thandle;<br> &nbsp;s:string;<br> &nbsp;length1:integer;<br> &nbsp;i:integer;<br>begin<br> &nbsp;s:='1234中asdfg国258';<br> &nbsp;length1:=length(s);<br> &nbsp;i:=1;<br> &nbsp;if winexec('c:/windows/notepad.exe',SW_NORMAL)&gt;31 then begin<br> &nbsp; &nbsp;notepadhandle:= findwindow('notepad',nil);<br> &nbsp; &nbsp;if notepadhandle&lt;&gt;0 then begin<br> &nbsp; &nbsp; &nbsp;childhandle:=findwindowex(notepadhandle,0,'edit',nil);<br> &nbsp; &nbsp; &nbsp;if childhandle&lt;&gt;0 then begin<br> &nbsp; &nbsp; &nbsp; &nbsp;while &nbsp;i&lt;=length1 do begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ord(s)&gt;127 then begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sendmessage(childhandle,WM_CHAR,ord(s),0);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sendmessage(childhandle,WM_CHAR,ord(s[i+1]),0);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;i:=i+2;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end else begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sendmessage(childhandle,WM_CHAR,ord(s),0);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;inc(i);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp;END;<br> &nbsp;end;<br>end;
 
后退
顶部