forked from jrsoftware/issrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TaskbarProgressFunc.pas
61 lines (49 loc) · 1.69 KB
/
TaskbarProgressFunc.pas
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
unit TaskbarProgressFunc;
{
Inno Setup
Copyright (C) 1997-2024 Jordan Russell
Portions by Martijn Laan
For conditions of distribution and use, see LICENSE.TXT.
Wrappers for ITaskbarList3.SetProgressState & SetProgressValue
}
interface
type
TTaskbarProgressState = (tpsNoProgress, tpsIndeterminate, tpsNormal,
tpsError, tpsPaused);
procedure SetAppTaskbarProgressState(const State: TTaskbarProgressState);
procedure SetAppTaskbarProgressValue(const Completed, Total: Cardinal);
implementation
uses
ActiveX, Forms, ShlObj;
var
TaskbarListInitialized: Boolean;
TaskbarListInterface: ITaskbarList3;
function InitializeTaskbarList: Boolean;
var
Intf: ITaskbarList3;
begin
if not TaskbarListInitialized then begin
if CoCreateInstance(CLSID_TaskbarList, nil, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, Intf) = S_OK then
if Intf.HrInit = S_OK then begin
{ Safety: don't allow the instance to be destroyed at shutdown }
Intf._AddRef;
TaskbarListInterface := Intf;
end;
TaskbarListInitialized := True;
end;
Result := Assigned(TaskbarListInterface);
end;
procedure SetAppTaskbarProgressState(const State: TTaskbarProgressState);
const
StateFlags: array[TTaskbarProgressState] of Integer = (
TBPF_NOPROGRESS, TBPF_INDETERMINATE, TBPF_NORMAL, TBPF_ERROR, TBPF_PAUSED);
begin
if InitializeTaskbarList then
TaskbarListInterface.SetProgressState(Application.Handle, StateFlags[State]);
end;
procedure SetAppTaskbarProgressValue(const Completed, Total: Cardinal);
begin
if InitializeTaskbarList then
TaskbarListInterface.SetProgressValue(Application.Handle, Completed, Total);
end;
end.