HP\李良庭
2025-07-08 868daf94f29ce1ffdd799a68c07bb668cd373bcd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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.