是不是切换输入法啊?<br>下面是切换到智能全拼的。<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Edit1: TEdit;<br> Edit2: TEdit;<br> procedure Edit1Enter(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.Edit1Enter(Sender: TObject);<br>const<br> KbLayoutRegSubkey = 'layout text'; // do not localize<br>var<br>KbList: array[0..63] of HKL;<br>TotalKbLayout,i,Bufsize: Integer;<br>ImeFileName: array [0..1024] of Char;<br>filename:string;<br>myhkl: hkl;<br>j: integer;<br>subkey: array[0..2048] of char;<br>qKey: HKey;<br>begin<br>TotalKbLayout := GetKeyboardLayoutList(64, KbList);<br>for I := 0 to TotalKbLayout - 1 do<br>begin<br> if Imm32IsIME(KbList) then<br> begin<br> strpcopy(subkey,'System/CurrentControlSet/Control/Keyboard Layouts/'+inttohex(KbList,8));<br> if RegOpenKeyEx(HKEY_LOCAL_MACHINE,<br> subkey, 0, KEY_READ,<br> qKey) = ERROR_SUCCESS then<br> begin<br> Bufsize := 1024;<br> if RegQueryValueEx(qKey, KbLayoutRegSubKey, nil, nil,<br> @ImeFileName, @Bufsize) = ERROR_SUCCESS then<br> begin<br> filename:=ImeFileName;<br> j:= pos('智能',filename);<br> if j >= 0 then<br> begin<br> myhkl:= hkl(KbList);<br> activatekeyboardlayout(myhkl,KLF_ACTIVATE);<br> end;<br> end;<br> end;<br> RegCloseKey(qKey);<br> end;<br>end;<br>end;<br><br><br>end.