unit Unit1;
|
|
interface
|
|
uses
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
Dialogs, StdCtrls, TlHelp32, // ÓÃÓÚ½ø³Ì²Ù×÷
|
ShellAPI, ComObj, ActiveX;
|
|
type
|
TForm1 = class(TForm)
|
Button1: TButton;
|
Edit1: TEdit;
|
procedure Button1Click(Sender: TObject);
|
private
|
{ Private declarations }
|
public
|
{ Public declarations }
|
end;
|
|
var
|
Form1: TForm1;
|
|
implementation
|
|
{$R *.dfm}
|
|
procedure KillTabTipProcess;
|
var
|
ContinueLoop: BOOL;
|
FSnapshotHandle: THandle;
|
FProcessEntry32: TProcessEntry32;
|
hProcess: THandle;
|
begin
|
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
if FSnapshotHandle <> INVALID_HANDLE_VALUE then
|
begin
|
FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
|
ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
|
|
while ContinueLoop do
|
begin
|
if ('TabTip.exe' = string(FProcessEntry32.szExeFile)) then
|
begin
|
hProcess := OpenProcess(PROCESS_TERMINATE, False, FProcessEntry32.th32ProcessID);
|
if hProcess <> 0 then
|
begin
|
TerminateProcess(hProcess, 0);
|
CloseHandle(hProcess);
|
end;
|
end;
|
ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
|
end;
|
CloseHandle(FSnapshotHandle);
|
end;
|
end;
|
|
procedure OpenTabTip;
|
var
|
TabTipPath: string;
|
Tip: OleVariant;
|
begin
|
TabTipPath := 'C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe';
|
|
Writeln('IsNewVisable show TabTip');
|
CoInitialize(nil);
|
try
|
Tip := CreateComObject(CLSID_UIHostNoLaunch) as IDispatch;
|
if VarIsClear(Tip) then
|
begin
|
Writeln('tip is nullptr');
|
Exit;
|
end;
|
(Tip as ITipInvocation).Toggle(GetDesktopWindow); // ÏÔʾ´¥Ãþ¼üÅÌ
|
finally
|
CoUninitialize;
|
end;
|
|
end;
|
|
procedure TForm1.Button1Click(Sender: TObject);
|
begin
|
KillTabTipProcess; // È·±£Ã»ÓвÐÁôµÄTabTip½ø³Ì
|
//ShellExecute(0, nil, 'C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe', nil, nil, SW_SHOWNORMAL);
|
OpenTabTip;
|
end;
|
|
end.
|