├── example
├── VirtDiskExample
│ ├── VirtDiskExample.res
│ ├── VirtDiskExample.dpr
│ ├── VirtDiskExampleMainForm.dfm
│ ├── VirtDiskExample.dproj
│ └── VirtDiskExampleMainForm.pas
├── FirewallExample
│ ├── FirewallExample.dpr
│ ├── FirewallExampleMainForm.dfm
│ ├── FirewallExample.dproj
│ └── FirewallExampleMainForm.pas
└── HeaderPortingExamples.groupproj
├── README.md
├── LICENSE
└── lib
├── VirtDisk.pas
└── NetFwTypeLib_TLB.pas
/example/VirtDiskExample/VirtDiskExample.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yypbd/yypbd-Delphi-HeaderPorting/HEAD/example/VirtDiskExample/VirtDiskExample.res
--------------------------------------------------------------------------------
/example/FirewallExample/FirewallExample.dpr:
--------------------------------------------------------------------------------
1 | program FirewallExample;
2 |
3 | uses
4 | Vcl.Forms,
5 | FirewallExampleMainForm in 'FirewallExampleMainForm.pas' {FormFirewallExampleMain},
6 | NetFwTypeLib_TLB in '..\..\lib\NetFwTypeLib_TLB.pas';
7 |
8 | {$R *.res}
9 |
10 | begin
11 | Application.Initialize;
12 | Application.MainFormOnTaskbar := True;
13 | Application.CreateForm(TFormFirewallExampleMain, FormFirewallExampleMain);
14 | Application.Run;
15 | end.
16 |
--------------------------------------------------------------------------------
/example/VirtDiskExample/VirtDiskExample.dpr:
--------------------------------------------------------------------------------
1 | program VirtDiskExample;
2 |
3 | uses
4 | Vcl.Forms,
5 | VirtDiskExampleMainForm in 'VirtDiskExampleMainForm.pas' {FormVirtDiskExampleMain},
6 | VirtDisk in '..\..\lib\VirtDisk.pas';
7 |
8 | {$R *.res}
9 |
10 | begin
11 | Application.Initialize;
12 | Application.MainFormOnTaskbar := True;
13 | Application.Title := 'VirtDisk Example';
14 | Application.CreateForm(TFormVirtDiskExampleMain, FormVirtDiskExampleMain);
15 | Application.Run;
16 | end.
17 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # yypbd-Delphi-HeaderPorting
2 |
3 | Win32 Header porting libraries
4 |
5 |
6 | ## VirtDisk.pas
7 |
8 | Virtual Hard Disk API
9 |
10 | Microsoft SDKs v7.0 - VirtDisk.h convert to pascal
11 |
12 | http://msdn.microsoft.com/en-us/library/windows/desktop/dd323654(v=vs.85).aspx
13 |
14 |
15 | ## NetFwTypeLib_TLB.pas
16 |
17 | Windows Firewall with Advanced Security Reference
18 |
19 | http://msdn.microsoft.com/en-us/library/windows/desktop/aa366459(v=vs.85).aspx
20 |
21 |
22 | # Usage
23 |
24 | See example folder :)
25 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Young-pil Yang
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/example/HeaderPortingExamples.groupproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | {CD45335E-18BD-4B71-B4BB-D640145F52B5}
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | Default.Personality.12
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 |
--------------------------------------------------------------------------------
/example/VirtDiskExample/VirtDiskExampleMainForm.dfm:
--------------------------------------------------------------------------------
1 | object FormVirtDiskExampleMain: TFormVirtDiskExampleMain
2 | Left = 0
3 | Top = 0
4 | Caption = 'FormVirtDiskExampleMain'
5 | ClientHeight = 166
6 | ClientWidth = 441
7 | Color = clBtnFace
8 | Font.Charset = DEFAULT_CHARSET
9 | Font.Color = clWindowText
10 | Font.Height = -11
11 | Font.Name = 'Tahoma'
12 | Font.Style = []
13 | OldCreateOrder = False
14 | OnCreate = FormCreate
15 | PixelsPerInch = 96
16 | TextHeight = 13
17 | object Button1: TButton
18 | Left = 16
19 | Top = 16
20 | Width = 75
21 | Height = 25
22 | Caption = 'Create'
23 | TabOrder = 0
24 | OnClick = Button1Click
25 | end
26 | object Button2: TButton
27 | Left = 148
28 | Top = 16
29 | Width = 75
30 | Height = 25
31 | Caption = 'Attach'
32 | TabOrder = 1
33 | OnClick = Button2Click
34 | end
35 | object Button3: TButton
36 | Left = 236
37 | Top = 16
38 | Width = 75
39 | Height = 25
40 | Caption = 'Detach'
41 | TabOrder = 2
42 | OnClick = Button3Click
43 | end
44 | object Button4: TButton
45 | Left = 148
46 | Top = 60
47 | Width = 75
48 | Height = 25
49 | Caption = 'Compact'
50 | TabOrder = 3
51 | OnClick = Button4Click
52 | end
53 | object Button5: TButton
54 | Left = 236
55 | Top = 60
56 | Width = 75
57 | Height = 25
58 | Caption = 'Expand'
59 | TabOrder = 4
60 | OnClick = Button5Click
61 | end
62 | object Button6: TButton
63 | Left = 324
64 | Top = 60
65 | Width = 75
66 | Height = 25
67 | Caption = 'Merge'
68 | TabOrder = 5
69 | OnClick = Button6Click
70 | end
71 | object Button7: TButton
72 | Left = 148
73 | Top = 108
74 | Width = 75
75 | Height = 25
76 | Caption = 'GetInfo'
77 | TabOrder = 6
78 | OnClick = Button7Click
79 | end
80 | object Button8: TButton
81 | Left = 236
82 | Top = 108
83 | Width = 75
84 | Height = 25
85 | Caption = 'SetInfo'
86 | TabOrder = 7
87 | OnClick = Button8Click
88 | end
89 | object Button9: TButton
90 | Left = 324
91 | Top = 108
92 | Width = 75
93 | Height = 25
94 | Caption = 'GetPhysVHD'
95 | TabOrder = 8
96 | OnClick = Button9Click
97 | end
98 | end
99 |
--------------------------------------------------------------------------------
/example/FirewallExample/FirewallExampleMainForm.dfm:
--------------------------------------------------------------------------------
1 | object FormFirewallExampleMain: TFormFirewallExampleMain
2 | Left = 0
3 | Top = 0
4 | Caption = 'FormFirewallExampleMain'
5 | ClientHeight = 387
6 | ClientWidth = 872
7 | Color = clBtnFace
8 | Font.Charset = DEFAULT_CHARSET
9 | Font.Color = clWindowText
10 | Font.Height = -11
11 | Font.Name = 'Tahoma'
12 | Font.Style = []
13 | OldCreateOrder = False
14 | PixelsPerInch = 96
15 | TextHeight = 13
16 | object Button1: TButton
17 | Left = 16
18 | Top = 12
19 | Width = 177
20 | Height = 25
21 | Caption = 'Adding a LAN Rule'
22 | TabOrder = 0
23 | OnClick = Button1Click
24 | end
25 | object MemoLog: TMemo
26 | Left = 399
27 | Top = 14
28 | Width = 446
29 | Height = 241
30 | ImeName = 'Microsoft Office IME 2007'
31 | Lines.Strings = (
32 | 'MemoLog')
33 | ScrollBars = ssBoth
34 | TabOrder = 1
35 | end
36 | object Button2: TButton
37 | Left = 16
38 | Top = 43
39 | Width = 177
40 | Height = 25
41 | Caption = 'Adding a per Interface Rule'
42 | TabOrder = 2
43 | OnClick = Button2Click
44 | end
45 | object Button3: TButton
46 | Left = 16
47 | Top = 74
48 | Width = 177
49 | Height = 25
50 | Caption = 'Adding a Protocol Rule'
51 | TabOrder = 3
52 | OnClick = Button3Click
53 | end
54 | object Button4: TButton
55 | Left = 16
56 | Top = 105
57 | Width = 177
58 | Height = 25
59 | Caption = 'Adding a Rule with Edge Traversal'
60 | TabOrder = 4
61 | OnClick = Button4Click
62 | end
63 | object Button5: TButton
64 | Left = 16
65 | Top = 136
66 | Width = 177
67 | Height = 25
68 | Caption = 'Adding a Service Rule'
69 | TabOrder = 5
70 | OnClick = Button5Click
71 | end
72 | object Button6: TButton
73 | Left = 16
74 | Top = 167
75 | Width = 177
76 | Height = 25
77 | Caption = 'Adding an ICMP Rule'
78 | TabOrder = 6
79 | OnClick = Button6Click
80 | end
81 | object Button7: TButton
82 | Left = 16
83 | Top = 199
84 | Width = 177
85 | Height = 25
86 | Caption = 'Adding an Application Rule'
87 | TabOrder = 7
88 | OnClick = Button7Click
89 | end
90 | object Button8: TButton
91 | Left = 16
92 | Top = 230
93 | Width = 177
94 | Height = 25
95 | Caption = 'Adding an Outbound Rule'
96 | TabOrder = 8
97 | OnClick = Button8Click
98 | end
99 | object Button9: TButton
100 | Left = 204
101 | Top = 12
102 | Width = 177
103 | Height = 25
104 | Caption = 'Checking if a Rule is Enabled'
105 | TabOrder = 9
106 | OnClick = Button9Click
107 | end
108 | object Button10: TButton
109 | Left = 212
110 | Top = 43
111 | Width = 177
112 | Height = 25
113 | Caption = 'Disabling the Firewall per Interface'
114 | TabOrder = 10
115 | OnClick = Button10Click
116 | end
117 | object Button11: TButton
118 | Left = 204
119 | Top = 74
120 | Width = 177
121 | Height = 25
122 | Caption = 'Enabling Rule Groups'
123 | TabOrder = 11
124 | OnClick = Button11Click
125 | end
126 | object Button12: TButton
127 | Left = 204
128 | Top = 105
129 | Width = 177
130 | Height = 25
131 | Caption = 'Enumerating Firewall Rules'
132 | TabOrder = 12
133 | OnClick = Button12Click
134 | end
135 | object Button13: TButton
136 | Left = 204
137 | Top = 136
138 | Width = 177
139 | Height = 25
140 | Caption = 'Restricting Service'
141 | TabOrder = 13
142 | OnClick = Button13Click
143 | end
144 | object Button14: TButton
145 | Left = 204
146 | Top = 167
147 | Width = 177
148 | Height = 25
149 | Caption = 'Retrieving Firewall Settings'
150 | TabOrder = 14
151 | OnClick = Button14Click
152 | end
153 | object Button15: TButton
154 | Left = 204
155 | Top = 198
156 | Width = 177
157 | Height = 25
158 | Caption = 'Turning the Firewall Off'
159 | TabOrder = 15
160 | OnClick = Button15Click
161 | end
162 | end
163 |
--------------------------------------------------------------------------------
/example/FirewallExample/FirewallExample.dproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | {3523E665-A2F6-422A-8607-8C648EFE664D}
4 | 13.4
5 | VCL
6 | FirewallExample.dpr
7 | True
8 | Debug
9 | Win32
10 | 1
11 | Application
12 |
13 |
14 | true
15 |
16 |
17 | true
18 | Base
19 | true
20 |
21 |
22 | true
23 | Base
24 | true
25 |
26 |
27 | true
28 | Base
29 | true
30 |
31 |
32 | true
33 | Cfg_1
34 | true
35 | true
36 |
37 |
38 | true
39 | Base
40 | true
41 |
42 |
43 | bindcompfmx;fmx;rtl;dbrtl;IndySystem;DbxClientDriver;bindcomp;inetdb;DBXInterBaseDriver;DataSnapCommon;DataSnapClient;DataSnapServer;DataSnapProviderClient;xmlrtl;DbxCommonDriver;IndyProtocols;DBXMySQLDriver;dbxcds;bindengine;soaprtl;DBXOracleDriver;CustomIPTransport;dsnap;DBXInformixDriver;fmxase;IndyCore;DBXFirebirdDriver;inet;fmxobj;inetdbxpress;DBXSybaseASADriver;fmxdae;IPIndyImpl;dbexpress;DataSnapIndy10ServerTransport;$(DCC_UsePackage)
44 | $(BDS)\bin\delphi_PROJECTICON.ico
45 | System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace)
46 | .\$(Platform)\$(Config)
47 | .\$(Platform)\$(Config)
48 | false
49 | false
50 | false
51 | false
52 | false
53 |
54 |
55 | DBXOdbcDriver;DBXSybaseASEDriver;vclimg;vclactnband;vcldb;vcldsnap;bindcompvcl;vclie;vcltouch;DBXDb2Driver;websnap;VclSmp;vcl;DBXMSSQLDriver;dsnapcon;vclx;webdsnap;$(DCC_UsePackage)
56 |
57 |
58 | vcldbx;TeeDB;Rave100VCL;vclib;Tee;inetdbbde;DBXOdbcDriver;svnui;ibxpress;DBXSybaseASEDriver;vclimg;fmi;intrawebdb_120_160;vclactnband;FMXTee;TeeUI;vcldb;vcldsnap;bindcompvcl;vclie;vcltouch;Intraweb_120_160;DBXDb2Driver;websnap;vclribbon;VclSmp;vcl;DataSnapConnectors;CloudService;DBXMSSQLDriver;CodeSiteExpressPkg;FmxTeeUI;dsnapcon;vclx;webdsnap;svn;bdertl;adortl;$(DCC_UsePackage)
59 | true
60 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)
61 | 1033
62 | $(BDS)\bin\default_app.manifest
63 | CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=
64 |
65 |
66 | DEBUG;$(DCC_Define)
67 | false
68 | true
69 | true
70 | true
71 |
72 |
73 | false
74 |
75 |
76 | false
77 | RELEASE;$(DCC_Define)
78 | 0
79 | false
80 |
81 |
82 |
83 | MainSource
84 |
85 |
86 |
87 | dfm
88 |
89 |
90 |
91 | Cfg_2
92 | Base
93 |
94 |
95 | Base
96 |
97 |
98 | Cfg_1
99 | Base
100 |
101 |
102 |
103 | Delphi.Personality.12
104 |
105 |
106 |
107 |
108 | False
109 | False
110 | 1
111 | 0
112 | 0
113 | 0
114 | False
115 | False
116 | False
117 | False
118 | False
119 | 1042
120 | 949
121 |
122 |
123 |
124 |
125 | 1.0.0.0
126 |
127 |
128 |
129 |
130 |
131 | 1.0.0.0
132 |
133 |
134 |
135 | FirewallExample.dpr
136 |
137 |
138 |
139 |
140 | False
141 | True
142 |
143 |
144 | 12
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/example/VirtDiskExample/VirtDiskExample.dproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | {F17404B1-BA81-4FA5-A55A-8DBF134CD75C}
4 | 13.4
5 | VCL
6 | VirtDiskExample.dpr
7 | True
8 | Debug
9 | Win32
10 | 1
11 | Application
12 |
13 |
14 | true
15 |
16 |
17 | true
18 | Base
19 | true
20 |
21 |
22 | true
23 | Base
24 | true
25 |
26 |
27 | true
28 | Base
29 | true
30 |
31 |
32 | true
33 | Cfg_1
34 | true
35 | true
36 |
37 |
38 | true
39 | Base
40 | true
41 |
42 |
43 | bindcompfmx;fmx;rtl;dbrtl;IndySystem;DbxClientDriver;bindcomp;inetdb;DBXInterBaseDriver;DataSnapCommon;DataSnapClient;DataSnapServer;DataSnapProviderClient;xmlrtl;DbxCommonDriver;IndyProtocols;DBXMySQLDriver;dbxcds;bindengine;soaprtl;DBXOracleDriver;CustomIPTransport;dsnap;DBXInformixDriver;fmxase;IndyCore;DBXFirebirdDriver;inet;fmxobj;inetdbxpress;DBXSybaseASADriver;fmxdae;IPIndyImpl;dbexpress;DataSnapIndy10ServerTransport;$(DCC_UsePackage)
44 | $(BDS)\bin\delphi_PROJECTICON.ico
45 | System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace)
46 | .\$(Platform)\$(Config)
47 | .\$(Platform)\$(Config)
48 | false
49 | false
50 | false
51 | false
52 | false
53 |
54 |
55 | DBXOdbcDriver;DBXSybaseASEDriver;vclimg;vclactnband;vcldb;vcldsnap;bindcompvcl;vclie;vcltouch;DBXDb2Driver;websnap;VclSmp;vcl;DBXMSSQLDriver;dsnapcon;vclx;webdsnap;$(DCC_UsePackage)
56 |
57 |
58 | vcldbx;TeeDB;Rave100VCL;vclib;Tee;inetdbbde;DBXOdbcDriver;svnui;ibxpress;DBXSybaseASEDriver;vclimg;fmi;intrawebdb_120_160;vclactnband;FMXTee;TeeUI;vcldb;vcldsnap;bindcompvcl;vclie;vcltouch;Intraweb_120_160;DBXDb2Driver;websnap;vclribbon;VclSmp;vcl;DataSnapConnectors;CloudService;DBXMSSQLDriver;CodeSiteExpressPkg;FmxTeeUI;dsnapcon;vclx;webdsnap;svn;bdertl;adortl;$(DCC_UsePackage)
59 | true
60 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)
61 | 1033
62 | $(BDS)\bin\default_app.manifest
63 | CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=
64 |
65 |
66 | DEBUG;$(DCC_Define)
67 | false
68 | true
69 | true
70 | true
71 |
72 |
73 | true
74 | 1033
75 | false
76 |
77 |
78 | false
79 | RELEASE;$(DCC_Define)
80 | 0
81 | false
82 |
83 |
84 |
85 | MainSource
86 |
87 |
88 |
89 | dfm
90 |
91 |
92 |
93 | Cfg_2
94 | Base
95 |
96 |
97 | Base
98 |
99 |
100 | Cfg_1
101 | Base
102 |
103 |
104 |
105 | Delphi.Personality.12
106 |
107 |
108 |
109 |
110 | False
111 | False
112 | 1
113 | 0
114 | 0
115 | 0
116 | False
117 | False
118 | False
119 | False
120 | False
121 | 1042
122 | 949
123 |
124 |
125 |
126 |
127 | 1.0.0.0
128 |
129 |
130 |
131 |
132 |
133 | 1.0.0.0
134 |
135 |
136 |
137 | VirtDiskExample.dpr
138 |
139 |
140 | Microsoft Office 2000 Sample Automation Server Wrapper Components
141 | Embarcadero C++Builder Office 2000 Servers Package
142 | Embarcadero C++Builder Office XP Servers Package
143 | Microsoft Office XP Sample Automation Server Wrapper Components
144 |
145 |
146 |
147 |
148 | False
149 | True
150 |
151 |
152 | 12
153 |
154 |
155 |
156 |
157 |
--------------------------------------------------------------------------------
/example/VirtDiskExample/VirtDiskExampleMainForm.pas:
--------------------------------------------------------------------------------
1 | unit VirtDiskExampleMainForm;
2 |
3 | interface
4 |
5 | uses
6 | Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
7 | Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
8 |
9 | const
10 | PHYS_PATH_LEN = 1024+1;
11 |
12 | type
13 | TFormVirtDiskExampleMain = class(TForm)
14 | Button1: TButton;
15 | Button2: TButton;
16 | Button3: TButton;
17 | Button4: TButton;
18 | Button5: TButton;
19 | Button6: TButton;
20 | Button7: TButton;
21 | Button8: TButton;
22 | Button9: TButton;
23 | procedure Button1Click(Sender: TObject);
24 | procedure Button2Click(Sender: TObject);
25 | procedure Button3Click(Sender: TObject);
26 | procedure Button4Click(Sender: TObject);
27 | procedure Button5Click(Sender: TObject);
28 | procedure Button6Click(Sender: TObject);
29 | procedure Button7Click(Sender: TObject);
30 | procedure Button8Click(Sender: TObject);
31 | procedure Button9Click(Sender: TObject);
32 | procedure FormCreate(Sender: TObject);
33 | private
34 | { Private declarations }
35 | function CreateVHD( const AFilePath: string; const ASize: ULONG ): Boolean;
36 | function AttachVHD( const AFilePath: string ): Boolean;
37 | function DetachVHD( const AFilePath: string ): Boolean;
38 | function CompactVHD( const AFilePath: string ): Boolean;
39 | function ExpandVHD( const AFilePath: string; const ANewSize: ULONG ): Boolean;
40 | function MergeVHD( const AFilePath: string ): Boolean;
41 | function GetVHDInfo( const AFilePath: string ): Boolean;
42 | function SetVHDInfo( const AFilePath: string ): Boolean;
43 | function GetPhysVHD( const AFilePath: string ): Boolean;
44 | public
45 | { Public declarations }
46 | end;
47 |
48 | var
49 | FormVirtDiskExampleMain: TFormVirtDiskExampleMain;
50 |
51 | implementation
52 |
53 | uses
54 | VirtDisk;
55 |
56 | {$R *.dfm}
57 |
58 | function TFormVirtDiskExampleMain.AttachVHD(const AFilePath: string): Boolean;
59 | var
60 | oparams: TOpenVirtualDiskParameters;
61 | iparams: TAttachVirtualDiskParameters;
62 | vst: TVirtualStorageType;
63 | Ret: DWORD;
64 | hVhd: THandle;
65 | begin
66 | hVhd := INVALID_HANDLE_VALUE;
67 |
68 | vst.DeviceId := VIRTUAL_STORAGE_TYPE_DEVICE_VHD;
69 | vst.VendorId := VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT;
70 |
71 | oparams.Version := OPEN_VIRTUAL_DISK_VERSION_1;
72 | oparams.Version1.RWDepth := OPEN_VIRTUAL_DISK_RW_DEPTH_DEFAULT;
73 |
74 | iparams.Version := ATTACH_VIRTUAL_DISK_VERSION_1;
75 |
76 | Ret := OpenVirtualDisk(@vst,
77 | PWideChar(AFilePath),
78 | TVIRTUAL_DISK_ACCESS_MASK(DWORD(VIRTUAL_DISK_ACCESS_ATTACH_RW) or DWORD(VIRTUAL_DISK_ACCESS_GET_INFO) or DWORD(VIRTUAL_DISK_ACCESS_DETACH)),
79 | OPEN_VIRTUAL_DISK_FLAG_NONE,
80 | @oparams,
81 | hVhd);
82 |
83 | if Ret = ERROR_SUCCESS then
84 | begin
85 | Ret := AttachVirtualDisk( hVhd,
86 | nil,
87 | ATTACH_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME,
88 | 0,
89 | @iparams,
90 | nil );
91 | end;
92 |
93 | Result := Ret = ERROR_SUCCESS;
94 |
95 | if hvhd <> INVALID_HANDLE_VALUE then
96 | CloseHandle( hvhd )
97 | end;
98 |
99 | procedure TFormVirtDiskExampleMain.Button1Click(Sender: TObject);
100 | begin
101 | CreateVHD( 'c:\aaa.vhd', 256 );
102 | end;
103 |
104 | procedure TFormVirtDiskExampleMain.Button2Click(Sender: TObject);
105 | begin
106 | AttachVHD( 'c:\aaa.vhd' );
107 | end;
108 |
109 | procedure TFormVirtDiskExampleMain.Button3Click(Sender: TObject);
110 | begin
111 | DetachVHD( 'c:\aaa.vhd' );
112 | end;
113 |
114 | procedure TFormVirtDiskExampleMain.Button4Click(Sender: TObject);
115 | begin
116 | CompactVHD( 'c:\aaa.vhd' )
117 | end;
118 |
119 | procedure TFormVirtDiskExampleMain.Button5Click(Sender: TObject);
120 | begin
121 | ExpandVHD( 'c:\aaa.vhd', 512 );
122 | end;
123 |
124 | procedure TFormVirtDiskExampleMain.Button6Click(Sender: TObject);
125 | begin
126 | MergeVHD( 'c:\aaa.vhd' )
127 | end;
128 |
129 | procedure TFormVirtDiskExampleMain.Button7Click(Sender: TObject);
130 | begin
131 | GetVHDInfo( 'c:\aaa.vhd' );
132 | end;
133 |
134 | procedure TFormVirtDiskExampleMain.Button8Click(Sender: TObject);
135 | begin
136 | SetVHDInfo( 'c:\aaa.vhd' );
137 | end;
138 |
139 | procedure TFormVirtDiskExampleMain.Button9Click(Sender: TObject);
140 | begin
141 | GetPhysVHD( 'c:\aaa.vhd' );
142 | end;
143 |
144 | function TFormVirtDiskExampleMain.CompactVHD(const AFilePath: string): Boolean;
145 | var
146 | Ret: DWORD;
147 | hVhd: THandle;
148 | oparams: TOpenVirtualDiskParameters;
149 | parameters: TCompactVirtualDiskParameters;
150 | vst: TVirtualStorageType;
151 | begin
152 | vst.DeviceId := VIRTUAL_STORAGE_TYPE_DEVICE_VHD;
153 | vst.VendorId := VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT;
154 |
155 | oparams.Version := OPEN_VIRTUAL_DISK_VERSION_1;
156 | oparams.Version1.RWDepth := OPEN_VIRTUAL_DISK_RW_DEPTH_DEFAULT;
157 |
158 | Ret := OpenVirtualDisk(@vst,
159 | PWideChar(AFilePath),
160 | VIRTUAL_DISK_ACCESS_METAOPS,
161 | OPEN_VIRTUAL_DISK_FLAG_NONE,
162 | @oparams,
163 | hVhd);
164 |
165 | if Ret = ERROR_SUCCESS then
166 | begin
167 | { TODO : Need test }
168 | parameters.Version := COMPACT_VIRTUAL_DISK_VERSION_1;
169 | parameters.Version1.Reserved := 0;
170 |
171 | Ret := CompactVirtualDisk( hVhd,
172 | COMPACT_VIRTUAL_DISK_FLAG_NONE,
173 | @parameters,
174 | nil );
175 | end;
176 |
177 | Result := Ret = ERROR_SUCCESS;
178 |
179 | if hvhd <> INVALID_HANDLE_VALUE then
180 | CloseHandle( hvhd )
181 | end;
182 |
183 | function TFormVirtDiskExampleMain.CreateVHD(const AFilePath: string; const ASize: ULONG): Boolean;
184 | var
185 | params: TCreateVirtualDiskParameters;
186 | mask: TVIRTUAL_DISK_ACCESS_MASK;
187 | vst: TVirtualStorageType;
188 | Ret: DWORD;
189 | hvhd: THandle;
190 | begin
191 | hVhd := INVALID_HANDLE_VALUE;
192 |
193 | vst.DeviceId := VIRTUAL_STORAGE_TYPE_DEVICE_VHD;
194 | vst.VendorId := VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT;
195 |
196 | params.Version:= CREATE_VIRTUAL_DISK_VERSION_1;
197 | params.Version1.UniqueId := TGUID.Empty;
198 | params.Version1.BlockSizeInBytes := 0;
199 | params.Version1.MaximumSize:= ASize * 1024 * 1024;
200 | params.Version1.ParentPath := nil;
201 | params.Version1.SourcePath := nil;
202 | params.Version1.BlockSizeInBytes := CREATE_VIRTUAL_DISK_PARAMETERS_DEFAULT_BLOCK_SIZE;
203 | params.Version1.SectorSizeInBytes := CREATE_VIRTUAL_DISK_PARAMETERS_DEFAULT_SECTOR_SIZE;
204 | mask := VIRTUAL_DISK_ACCESS_CREATE;
205 |
206 | Ret := CreateVirtualDisk(
207 | @vst,
208 | PChar(AFilePath),
209 | mask,
210 | nil,
211 | CREATE_VIRTUAL_DISK_FLAG_FULL_PHYSICAL_ALLOCATION,
212 | 0,
213 | @params,
214 | nil,
215 | hvhd);
216 | Result := Ret = ERROR_SUCCESS;
217 |
218 | if hvhd <> INVALID_HANDLE_VALUE then
219 | CloseHandle( hvhd )
220 | end;
221 |
222 | function TFormVirtDiskExampleMain.DetachVHD(const AFilePath: string): Boolean;
223 | var
224 | oparams: TOpenVirtualDiskParameters;
225 | vst: TVirtualStorageType;
226 | Ret: DWORD;
227 | hVhd: THandle;
228 | Flags: TDETACH_VIRTUAL_DISK_FLAG;
229 | begin
230 | vst.DeviceId := VIRTUAL_STORAGE_TYPE_DEVICE_VHD;
231 | vst.VendorId := VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT;
232 |
233 | oparams.Version := OPEN_VIRTUAL_DISK_VERSION_1;
234 | oparams.Version1.RWDepth := OPEN_VIRTUAL_DISK_RW_DEPTH_DEFAULT;
235 |
236 | Ret := OpenVirtualDisk(@vst,
237 | PWideChar(AFilePath),
238 | VIRTUAL_DISK_ACCESS_DETACH,
239 | OPEN_VIRTUAL_DISK_FLAG_NONE,
240 | nil,
241 | hVhd);
242 |
243 | if Ret = ERROR_SUCCESS then
244 | begin
245 | Flags := DETACH_VIRTUAL_DISK_FLAG_NONE;
246 | Ret := DetachVirtualDisk(hVhd, Flags, 0);
247 | end;
248 |
249 | Result := Ret = ERROR_SUCCESS;
250 |
251 | if hvhd <> INVALID_HANDLE_VALUE then
252 | CloseHandle( hvhd )
253 | end;
254 |
255 | function TFormVirtDiskExampleMain.ExpandVHD(const AFilePath: string;
256 | const ANewSize: ULONG): Boolean;
257 | var
258 | Ret: DWORD;
259 | hVhd: THandle;
260 | xparams: TExpandVirtualDiskParameters;
261 | vst: TVirtualStorageType;
262 | begin
263 | vst.DeviceId := VIRTUAL_STORAGE_TYPE_DEVICE_VHD;
264 | vst.VendorId := VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT;
265 |
266 | Ret := OpenVirtualDisk(@vst,
267 | PWideChar(AFilePath),
268 | VIRTUAL_DISK_ACCESS_METAOPS,
269 | OPEN_VIRTUAL_DISK_FLAG_NONE,
270 | nil,
271 | hVhd);
272 |
273 | if Ret = ERROR_SUCCESS then
274 | begin
275 | xparams.Version := EXPAND_VIRTUAL_DISK_VERSION_1;
276 | xparams.Version1.NewSize := ANewSize * 1024 * 1024;
277 |
278 | Ret := ExpandVirtualDisk( hVhd,
279 | EXPAND_VIRTUAL_DISK_FLAG_NONE,
280 | @xparams,
281 | nil );
282 | end;
283 |
284 | Result := Ret = ERROR_SUCCESS;
285 |
286 | if hvhd <> INVALID_HANDLE_VALUE then
287 | CloseHandle( hvhd )
288 | end;
289 |
290 | procedure TFormVirtDiskExampleMain.FormCreate(Sender: TObject);
291 | begin
292 | Caption := Application.Title;
293 | end;
294 |
295 | function TFormVirtDiskExampleMain.GetPhysVHD(const AFilePath: string): Boolean;
296 | var
297 | oparams: TOpenVirtualDiskParameters;
298 | iparams: TAttachVirtualDiskParameters;
299 | vst: TVirtualStorageType;
300 | Ret: DWORD;
301 | hVhd: THandle;
302 | sizePhysicalDisk: ULONG;
303 | pszPhysicalDiskPath: PWideChar;
304 | begin
305 | hVhd := INVALID_HANDLE_VALUE;
306 |
307 | vst.DeviceId := VIRTUAL_STORAGE_TYPE_DEVICE_VHD;
308 | vst.VendorId := VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT;
309 |
310 | oparams.Version := OPEN_VIRTUAL_DISK_VERSION_1;
311 | oparams.Version1.RWDepth := OPEN_VIRTUAL_DISK_RW_DEPTH_DEFAULT;
312 |
313 | iparams.Version := ATTACH_VIRTUAL_DISK_VERSION_1;
314 |
315 | Ret := OpenVirtualDisk(@vst,
316 | PWideChar(AFilePath),
317 | TVIRTUAL_DISK_ACCESS_MASK(DWORD(VIRTUAL_DISK_ACCESS_ATTACH_RW) or DWORD(VIRTUAL_DISK_ACCESS_GET_INFO) or DWORD(VIRTUAL_DISK_ACCESS_DETACH)),
318 | OPEN_VIRTUAL_DISK_FLAG_NONE,
319 | @oparams,
320 | hVhd);
321 |
322 | if Ret = ERROR_SUCCESS then
323 | begin
324 | sizePhysicalDisk := (PHYS_PATH_LEN * sizeof(WideChar)) * 256;
325 | GetMem(pszPhysicalDiskPath, PHYS_PATH_LEN * sizeof(WideChar));
326 | Ret := GetVirtualDiskPhysicalPath( hVhd, @sizePhysicalDisk, pszPhysicalDiskPath );
327 |
328 | if Ret = ERROR_SUCCESS then
329 | begin
330 | ShowMessage( pszPhysicalDiskPath );
331 | end;
332 |
333 | FreeMem( pszPhysicalDiskPath );
334 | end;
335 |
336 | Result := Ret = ERROR_SUCCESS;
337 |
338 | if hvhd <> INVALID_HANDLE_VALUE then
339 | CloseHandle( hvhd )
340 | end;
341 |
342 | function TFormVirtDiskExampleMain.GetVHDInfo(const AFilePath: string): Boolean;
343 | var
344 | Ret: DWORD;
345 | hVhd: THandle;
346 | vst: TVirtualStorageType;
347 | Info: TGetVirtualDiskInfo;
348 | InfoSize, SizeUsed: ULONG;
349 | begin
350 | vst.DeviceId := VIRTUAL_STORAGE_TYPE_DEVICE_VHD;
351 | vst.VendorId := VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT;
352 |
353 | Ret := OpenVirtualDisk(@vst,
354 | PWideChar(AFilePath),
355 | VIRTUAL_DISK_ACCESS_ALL,
356 | OPEN_VIRTUAL_DISK_FLAG_NONE,
357 | nil,
358 | hVhd);
359 |
360 | if Ret = ERROR_SUCCESS then
361 | begin
362 | Info.Version := GET_VIRTUAL_DISK_INFO_SIZE;
363 | InfoSize := sizeof(Info);
364 |
365 | Ret := GetVirtualDiskInformation(hVhd,
366 | InfoSize,
367 | Info,
368 | SizeUsed);
369 | end;
370 |
371 | Result := Ret = ERROR_SUCCESS;
372 |
373 | if hvhd <> INVALID_HANDLE_VALUE then
374 | CloseHandle( hvhd )
375 | end;
376 |
377 | function TFormVirtDiskExampleMain.MergeVHD(const AFilePath: string): Boolean;
378 | var
379 | Ret: DWORD;
380 | hVhd: THandle;
381 | oparams: TOpenVirtualDiskParameters;
382 | mparms: TMergeVirtualDiskParameters;
383 | vst: TVirtualStorageType;
384 | begin
385 | vst.DeviceId := VIRTUAL_STORAGE_TYPE_DEVICE_VHD;
386 | vst.VendorId := VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT;
387 |
388 | oparams.Version := OPEN_VIRTUAL_DISK_VERSION_1;
389 | oparams.Version1.RWDepth := 2;
390 |
391 | Ret := OpenVirtualDisk(@vst,
392 | PWideChar(AFilePath),
393 | TVIRTUAL_DISK_ACCESS_MASK(DWORD(VIRTUAL_DISK_ACCESS_METAOPS) or DWORD(VIRTUAL_DISK_ACCESS_GET_INFO)),
394 | OPEN_VIRTUAL_DISK_FLAG_NONE,
395 | @oparams,
396 | hVhd);
397 |
398 | if Ret = ERROR_SUCCESS then
399 | begin
400 | { TODO : Need Test }
401 | mparms.Version := MERGE_VIRTUAL_DISK_VERSION_1;
402 | mparms.Version1.MergeDepth := oparams.Version1.RWDepth - 1; //MERGE_VIRTUAL_DISK_DEFAULT_MERGE_DEPTH;
403 |
404 | Ret := MergeVirtualDisk( hVhd,
405 | MERGE_VIRTUAL_DISK_FLAG_NONE,
406 | @mparms,
407 | nil );
408 | end;
409 |
410 | Result := Ret = ERROR_SUCCESS;
411 |
412 | if hvhd <> INVALID_HANDLE_VALUE then
413 | CloseHandle( hvhd )
414 | end;
415 |
416 | function TFormVirtDiskExampleMain.SetVHDInfo(const AFilePath: string): Boolean;
417 | var
418 | Ret: DWORD;
419 | hVhd: THandle;
420 | vst: TVirtualStorageType;
421 | SetInfo: TSetVirtualDiskInfo;
422 | begin
423 | vst.DeviceId := VIRTUAL_STORAGE_TYPE_DEVICE_VHD;
424 | vst.VendorId := VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT;
425 |
426 | Ret := OpenVirtualDisk(@vst,
427 | PWideChar(AFilePath),
428 | VIRTUAL_DISK_ACCESS_ALL,
429 | OPEN_VIRTUAL_DISK_FLAG_NONE,
430 | nil,
431 | hVhd);
432 |
433 | if Ret = ERROR_SUCCESS then
434 | begin
435 | SetInfo.Version := SET_VIRTUAL_DISK_INFO_IDENTIFIER;
436 | SetInfo.UniqueIdentifier := TGuid.Empty;
437 |
438 | Ret := SetVirtualDiskInformation(hVhd,
439 | @SetInfo );
440 | end;
441 |
442 | Result := Ret = ERROR_SUCCESS;
443 |
444 | if hvhd <> INVALID_HANDLE_VALUE then
445 | CloseHandle( hvhd )
446 | end;
447 |
448 | end.
449 |
--------------------------------------------------------------------------------
/lib/VirtDisk.pas:
--------------------------------------------------------------------------------
1 | unit VirtDisk;
2 |
3 | interface
4 |
5 | // Microsoft SDKs v7.0 - VirtDisk.h convert to pascal
6 | // http://msdn.microsoft.com/en-us/library/windows/desktop/dd323654(v=vs.85).aspx
7 |
8 | // kyypbd@gmail.com
9 | // http://yypbd.tistory.com
10 |
11 | uses
12 | Windows;
13 |
14 | {$MINENUMSIZE 4}
15 |
16 | // OpenVirtualDisk & CreateVirtualDisk
17 | type
18 | PVirtualStorageType = ^TVirtualStorageType;
19 | _VIRTUAL_STORAGE_TYPE = record
20 | DeviceId: ULONG;
21 | VendorId: TGUID;
22 | end;
23 | TVirtualStorageType = _VIRTUAL_STORAGE_TYPE;
24 | VIRTUAL_STORAGE_TYPE = _VIRTUAL_STORAGE_TYPE;
25 |
26 | const
27 | VIRTUAL_STORAGE_TYPE_VENDOR_UNKNOWN: TGUID =
28 | '{00000000-0000-0000-0000-000000000000}';
29 | VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT: TGUID =
30 | '{EC984AEC-A0F9-47e9-901F-71415A66345B}';
31 |
32 | VIRTUAL_STORAGE_TYPE_DEVICE_UNKNOWN = 0;
33 | VIRTUAL_STORAGE_TYPE_DEVICE_ISO = 1;
34 | VIRTUAL_STORAGE_TYPE_DEVICE_VHD = 2;
35 |
36 | CREATE_VIRTUAL_DISK_PARAMETERS_DEFAULT_BLOCK_SIZE = 0;
37 | CREATE_VIRTUAL_DISK_PARAMETERS_DEFAULT_SECTOR_SIZE = $200;
38 |
39 | type
40 | TCREATE_VIRTUAL_DISK_VERSION = (
41 | CREATE_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0,
42 | CREATE_VIRTUAL_DISK_VERSION_1 = 1
43 | );
44 |
45 | TCreateVirtualDiskParametersVersion1 = record
46 | UniqueId: TGUID;
47 | MaximumSize: ULONGLONG;
48 | BlockSizeInBytes: ULONG;
49 | SectorSizeInBytes: ULONG;
50 | ParentPath: LPCWSTR;
51 | SourcePath: LPCWSTR;
52 | end;
53 |
54 | PCreateVirtualDiskParameters = ^TCreateVirtualDiskParameters;
55 | _CREATE_VIRTUAL_DISK_PARAMETERS = record
56 | Version: TCREATE_VIRTUAL_DISK_VERSION;
57 | case Integer of
58 | 0: ( Version1: TCreateVirtualDiskParametersVersion1; );
59 | end;
60 | TCreateVirtualDiskParameters = _CREATE_VIRTUAL_DISK_PARAMETERS;
61 | CREATE_VIRTUAL_DISK_PARAMETERS = _CREATE_VIRTUAL_DISK_PARAMETERS;
62 |
63 | TCREATE_VIRTUAL_DISK_FLAG = (
64 | CREATE_VIRTUAL_DISK_FLAG_NONE = $00000000,
65 | CREATE_VIRTUAL_DISK_FLAG_FULL_PHYSICAL_ALLOCATION = $00000001
66 | );
67 |
68 | const
69 | OPEN_VIRTUAL_DISK_RW_DEPTH_DEFAULT = 1;
70 |
71 | type
72 | TOPEN_VIRTUAL_DISK_VERSION = (
73 | OPEN_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0,
74 | OPEN_VIRTUAL_DISK_VERSION_1 = 1
75 | );
76 |
77 | TOPEN_VIRTUAL_DISK_PARAMETERS_VERSION1 = record
78 | RWDepth: ULONG;
79 | end;
80 |
81 | POpenVirtualDiskParameters = ^TOpenVirtualDiskParameters;
82 | _OPEN_VIRTUAL_DISK_PARAMETERS = record
83 | Version: TOPEN_VIRTUAL_DISK_VERSION;
84 | case Integer of
85 | 0: ( Version1: TOPEN_VIRTUAL_DISK_PARAMETERS_VERSION1;
86 | );
87 | end;
88 | TOpenVirtualDiskParameters = _OPEN_VIRTUAL_DISK_PARAMETERS;
89 | OPEN_VIRTUAL_DISK_PARAMETERS = _OPEN_VIRTUAL_DISK_PARAMETERS;
90 |
91 | TVIRTUAL_DISK_ACCESS_MASK = (
92 | VIRTUAL_DISK_ACCESS_ATTACH_RO = $00010000,
93 | VIRTUAL_DISK_ACCESS_ATTACH_RW = $00020000,
94 | VIRTUAL_DISK_ACCESS_DETACH = $00040000,
95 | VIRTUAL_DISK_ACCESS_GET_INFO = $00080000,
96 | VIRTUAL_DISK_ACCESS_CREATE = $00100000,
97 | VIRTUAL_DISK_ACCESS_METAOPS = $00200000,
98 | VIRTUAL_DISK_ACCESS_READ = $000d0000,
99 | VIRTUAL_DISK_ACCESS_ALL = $003f0000,
100 | VIRTUAL_DISK_ACCESS_WRITABLE = $00320000
101 | );
102 |
103 | TOPEN_VIRTUAL_DISK_FLAG = (
104 | OPEN_VIRTUAL_DISK_FLAG_NONE = $00000000,
105 | OPEN_VIRTUAL_DISK_FLAG_NO_PARENTS = $00000001,
106 | OPEN_VIRTUAL_DISK_FLAG_BLANK_FILE = $00000002,
107 | OPEN_VIRTUAL_DISK_FLAG_BOOT_DRIVE = $00000004
108 | );
109 |
110 | function OpenVirtualDisk(
111 | VirtualStorageType: PVirtualStorageType;
112 | Path: LPCWSTR;
113 | VirtualDiskAccessMask: TVIRTUAL_DISK_ACCESS_MASK;
114 | Flags: TOPEN_VIRTUAL_DISK_FLAG;
115 | Parameters: POpenVirtualDiskParameters;
116 | var Handle: THandle
117 | ): DWORD; stdcall;
118 |
119 | function CreateVirtualDisk(
120 | VirtualStorageType: PVirtualStorageType;
121 | Path: LPCWSTR;
122 | VirtualDiskAccessMask: TVIRTUAL_DISK_ACCESS_MASK;
123 | SecurityDescriptor: PSECURITY_DESCRIPTOR;
124 | Flags: TCREATE_VIRTUAL_DISK_FLAG;
125 | ProviderSpecificFlags: ULONG;
126 | Parameters: PCreateVirtualDiskParameters;
127 | Overlapped: POverlapped;
128 | var Handle: THandle
129 | ): DWORD; stdcall;
130 |
131 |
132 | // AttachVirtualDisk
133 | type
134 | TATTACH_VIRTUAL_DISK_VERSION = (
135 | ATTACH_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0,
136 | ATTACH_VIRTUAL_DISK_VERSION_1 = 1
137 | );
138 |
139 | TAttachVirtualDiskParametersVersion1 = record
140 | Reserved: ULONG;
141 | end;
142 |
143 | PAttachVirtualDiskParameters = ^TAttachVirtualDiskParameters;
144 | _ATTACH_VIRTUAL_DISK_PARAMETERS = record
145 | Version: TATTACH_VIRTUAL_DISK_VERSION;
146 | case Integer of
147 | 0: ( Version1: TAttachVirtualDiskParametersVersion1; );
148 | end;
149 | TAttachVirtualDiskParameters = _ATTACH_VIRTUAL_DISK_PARAMETERS;
150 | ATTACH_VIRTUAL_DISK_PARAMETERS = _ATTACH_VIRTUAL_DISK_PARAMETERS;
151 |
152 | TATTACH_VIRTUAL_DISK_FLAG = (
153 | ATTACH_VIRTUAL_DISK_FLAG_NONE = $00000000,
154 | ATTACH_VIRTUAL_DISK_FLAG_READ_ONLY = $00000001,
155 | ATTACH_VIRTUAL_DISK_FLAG_NO_DRIVE_LETTER = $00000002,
156 | ATTACH_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME = $00000004,
157 | ATTACH_VIRTUAL_DISK_FLAG_NO_LOCAL_HOST = $00000008
158 | );
159 |
160 | function AttachVirtualDisk(
161 | VirtualDiskHandle: THandle;
162 | SecurityDescriptor: PSECURITY_DESCRIPTOR;
163 | Flags: TATTACH_VIRTUAL_DISK_FLAG;
164 | ProviderSpecificFlags: ULONG;
165 | Parameters: PAttachVirtualDiskParameters;
166 | Overlapped: POverlapped
167 | ): DWORD; stdcall;
168 |
169 |
170 | // DetachVirtualDisk
171 | type
172 | TDETACH_VIRTUAL_DISK_FLAG = (
173 | DETACH_VIRTUAL_DISK_FLAG_NONE = $00000000
174 | );
175 |
176 | function DetachVirtualDisk(
177 | VirtualDiskHandle: THandle;
178 | Flags: TDETACH_VIRTUAL_DISK_FLAG;
179 | ProviderSpecificFlags: ULONG
180 | ): DWORD; stdcall;
181 |
182 |
183 | // GetVirtualDiskPhysicalPath
184 | function GetVirtualDiskPhysicalPath(
185 | VirtualDiskHandle: THandle;
186 | DiskPathSizeInBytes: PULONG;
187 | DiskPath: LPWSTR
188 | ): DWORD; stdcall;
189 |
190 |
191 | // GetStorageDependencyInformation
192 | type
193 | TDEPENDENT_DISK_FLAG = (
194 | DEPENDENT_DISK_FLAG_NONE = $00000000,
195 | DEPENDENT_DISK_FLAG_MULT_BACKING_FILES = $00000001,
196 | DEPENDENT_DISK_FLAG_FULLY_ALLOCATED = $00000002,
197 | DEPENDENT_DISK_FLAG_READ_ONLY = $00000004,
198 | DEPENDENT_DISK_FLAG_REMOTE = $00000008,
199 | DEPENDENT_DISK_FLAG_SYSTEM_VOLUME = $00000010,
200 | DEPENDENT_DISK_FLAG_SYSTEM_VOLUME_PARENT = $00000020,
201 | DEPENDENT_DISK_FLAG_REMOVABLE = $00000040,
202 | DEPENDENT_DISK_FLAG_NO_DRIVE_LETTER = $00000080,
203 | DEPENDENT_DISK_FLAG_PARENT = $00000100,
204 | DEPENDENT_DISK_FLAG_NO_HOST_DISK = $00000200,
205 | DEPENDENT_DISK_FLAG_PERMANENT_LIFETIME = $00000400
206 | );
207 |
208 | TSTORAGE_DEPENDENCY_INFO_VERSION = (
209 | STORAGE_DEPENDENCY_INFO_VERSION_UNSPECIFIED = 0,
210 | STORAGE_DEPENDENCY_INFO_VERSION_1 = 1,
211 | STORAGE_DEPENDENCY_INFO_VERSION_2 = 2
212 | );
213 |
214 | PStorageDependencyInfoType1 = ^TStorageDependencyInfoType1;
215 | _STORAGE_DEPENDENCY_INFO_TYPE_1 = record
216 | DependencyTypeFlags: TDEPENDENT_DISK_FLAG;
217 | ProviderSpecificFlags: ULONG;
218 | VirtualStorageType: TVirtualStorageType;
219 | end;
220 | TStorageDependencyInfoType1 = _STORAGE_DEPENDENCY_INFO_TYPE_1;
221 | STORAGE_DEPENDENCY_INFO_TYPE_1 = _STORAGE_DEPENDENCY_INFO_TYPE_1;
222 |
223 | PStorageDependencyInfoType2 = ^TStorageDependencyInfoType2;
224 | _STORAGE_DEPENDENCY_INFO_TYPE_2 = record
225 | DependencyTypeFlags: TDEPENDENT_DISK_FLAG;
226 | ProviderSpecificFlags: ULONG;
227 | VirtualStorageType: TVirtualStorageType;
228 | AncestorLevel: ULONG;
229 | DependencyDeviceName: LPWSTR;
230 | HostVolumeName: LPWSTR;
231 | DependentVolumeName: LPWSTR;
232 | DependentVolumeRelativePath: LPWSTR;
233 | end;
234 | TStorageDependencyInfoType2 = _STORAGE_DEPENDENCY_INFO_TYPE_2;
235 | STORAGE_DEPENDENCY_INFO_TYPE_2 = _STORAGE_DEPENDENCY_INFO_TYPE_2;
236 |
237 | PStorageDependencyInfo = ^TStorageDependencyInfo;
238 | _STORAGE_DEPENDENCY_INFO = record
239 | Version: TSTORAGE_DEPENDENCY_INFO_VERSION;
240 | NumberEntries: ULONG;
241 | case Integer of
242 | 0: (
243 | Version1Entries: PStorageDependencyInfoType1;
244 | Version2Entries: PStorageDependencyInfoType2;
245 | );
246 | end;
247 | TStorageDependencyInfo = _STORAGE_DEPENDENCY_INFO;
248 | STORAGE_DEPENDENCY_INFO = _STORAGE_DEPENDENCY_INFO;
249 |
250 | TGET_STORAGE_DEPENDENCY_FLAG = (
251 | GET_STORAGE_DEPENDENCY_FLAG_NONE = $00000000,
252 | GET_STORAGE_DEPENDENCY_FLAG_HOST_VOLUMES = $00000001,
253 | GET_STORAGE_DEPENDENCY_FLAG_DISK_HANDLE = $00000002
254 | );
255 | const
256 | GET_STORAGE_DEPENDENCY_FLAG_PARENTS = GET_STORAGE_DEPENDENCY_FLAG_HOST_VOLUMES;
257 |
258 | function GetStorageDependencyInformation(
259 | ObjectHandle: THandle;
260 | Flags: TGET_STORAGE_DEPENDENCY_FLAG;
261 | StorageDependencyInfoSize: ULONG;
262 | var StorageDependencyInfo: TStorageDependencyInfo;
263 | var SizeUsed: ULONG
264 | ): DWORD; stdcall;
265 |
266 |
267 | // GetVirtualDiskInformation
268 | type
269 | TGET_VIRTUAL_DISK_INFO_VERSION = (
270 | GET_VIRTUAL_DISK_INFO_UNSPECIFIED = 0,
271 | GET_VIRTUAL_DISK_INFO_SIZE = 1,
272 | GET_VIRTUAL_DISK_INFO_IDENTIFIER = 2,
273 | GET_VIRTUAL_DISK_INFO_PARENT_LOCATION = 3,
274 | GET_VIRTUAL_DISK_INFO_PARENT_IDENTIFIER = 4,
275 | GET_VIRTUAL_DISK_INFO_PARENT_TIMESTAMP = 5,
276 | GET_VIRTUAL_DISK_INFO_VIRTUAL_STORAGE_TYPE = 6,
277 | GET_VIRTUAL_DISK_INFO_PROVIDER_SUBTYPE = 7
278 | );
279 |
280 | TSize = record
281 | VirtualSize: ULONGLONG;
282 | PhysicalSize: ULONGLONG;
283 | BlockSize: ULONG;
284 | SectorSize: ULONG;
285 | end;
286 |
287 | TParentLocation = record
288 | ParentResolved: BOOL;
289 | ParentLocationBuffer: array[0..0] of WCHAR; // MultiSz string
290 | end;
291 |
292 | PGetVirtualDiskInfo = ^TGetVirtualDiskInfo;
293 | _GET_VIRTUAL_DISK_INFO = record
294 | Version: TGET_VIRTUAL_DISK_INFO_VERSION;
295 | case Integer of
296 | 0: (
297 | Size: TSize;
298 | Identifier: TGUID;
299 | ParentLocation: TParentLocation;
300 | ParentIdentifier: TGUID;
301 | ParentTimestamp: ULONG;
302 | VirtualStorageType: TVirtualStorageType;
303 | ProviderSubtype: ULONG;
304 | );
305 | end;
306 | TGetVirtualDiskInfo = _GET_VIRTUAL_DISK_INFO;
307 | GET_VIRTUAL_DISK_INFO = _GET_VIRTUAL_DISK_INFO;
308 |
309 | function GetVirtualDiskInformation(
310 | VirtualDiskHandle: THandle;
311 | var VirtualDiskInfoSize: ULONG;
312 | var VirtualDiskInfo: TGetVirtualDiskInfo;
313 | var SizeUsed: ULONG
314 | ): DWORD; stdcall;
315 |
316 |
317 | // SetVirtualDiskInformation
318 | type
319 | TSET_VIRTUAL_DISK_INFO_VERSION = (
320 | SET_VIRTUAL_DISK_INFO_UNSPECIFIED = 0,
321 | SET_VIRTUAL_DISK_INFO_PARENT_PATH = 1,
322 | SET_VIRTUAL_DISK_INFO_IDENTIFIER = 2
323 | );
324 |
325 | PSetVirtualDiskInfo = ^TSetVirtualDiskInfo;
326 | _SET_VIRTUAL_DISK_INFO = record
327 | Version: TSET_VIRTUAL_DISK_INFO_VERSION;
328 | case Integer of
329 | 0: (
330 | ParentFilePath: LPWSTR;
331 | UniqueIdentifier: TGUID;
332 | );
333 | end;
334 | TSetVirtualDiskInfo = _SET_VIRTUAL_DISK_INFO;
335 | SET_VIRTUAL_DISK_INFO = _SET_VIRTUAL_DISK_INFO;
336 |
337 | function SetVirtualDiskInformation(
338 | VirtualDiskHandle: THandle;
339 | VirtualDiskInfo: PSetVirtualDiskInfo
340 | ): DWORD; stdcall;
341 |
342 |
343 | // GetVirtualDiskOperationProgress
344 | type
345 | PVirtualDiskProgress = ^TVirtualDiskProgress;
346 | _VIRTUAL_DISK_PROGRESS = record
347 | OperationStatus: DWORD;
348 | CurrentValue: ULONGLONG;
349 | CompletionValue: ULONGLONG;
350 | end;
351 | TVirtualDiskProgress = _VIRTUAL_DISK_PROGRESS;
352 | VIRTUAL_DISK_PROGRESS = _VIRTUAL_DISK_PROGRESS;
353 |
354 | function GetVirtualDiskOperationProgress(
355 | VirtualDiskHandle: THandle;
356 | Overlapped: POverlapped;
357 | var Progress: TVirtualDiskProgress
358 | ): DWORD; stdcall;
359 |
360 |
361 | // CompactVirtualDisk
362 | type
363 | TCOMPACT_VIRTUAL_DISK_VERSION = (
364 | COMPACT_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0,
365 | COMPACT_VIRTUAL_DISK_VERSION_1 = 1
366 | );
367 |
368 | TCOMPACT_VIRTUAL_DISK_PARAMETERS_VERSION1 = record
369 | Reserved: ULONG;
370 | end;
371 |
372 | PCompactVirtualDiskParameters = ^TCompactVirtualDiskParameters;
373 | _COMPACT_VIRTUAL_DISK_PARAMETERS = record
374 | Version: TCOMPACT_VIRTUAL_DISK_VERSION;
375 | case Integer of
376 | 0: ( Version1: TCOMPACT_VIRTUAL_DISK_PARAMETERS_VERSION1; );
377 | end;
378 | TCompactVirtualDiskParameters = _COMPACT_VIRTUAL_DISK_PARAMETERS;
379 | COMPACT_VIRTUAL_DISK_PARAMETERS = _COMPACT_VIRTUAL_DISK_PARAMETERS;
380 |
381 | TCOMPACT_VIRTUAL_DISK_FLAG = (
382 | COMPACT_VIRTUAL_DISK_FLAG_NONE = $00000000
383 | );
384 |
385 | function CompactVirtualDisk(
386 | VirtualDiskHandle: THandle;
387 | Flags: TCOMPACT_VIRTUAL_DISK_FLAG;
388 | Parameters: PCompactVirtualDiskParameters;
389 | Overlapped: POverlapped
390 | ): DWORD; stdcall;
391 |
392 |
393 | // MergeVirtualDisk
394 | type
395 | TMERGE_VIRTUAL_DISK_VERSION = (
396 | MERGE_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0,
397 | MERGE_VIRTUAL_DISK_VERSION_1 = 1
398 | );
399 |
400 | const
401 | MERGE_VIRTUAL_DISK_DEFAULT_MERGE_DEPTH = 1;
402 |
403 | type
404 | TMergeVirtualDiskParametersVersion1 = record
405 | MergeDepth: ULONG;
406 | end;
407 |
408 | PMergeVirtualDiskParameters = ^TMergeVirtualDiskParameters;
409 | _MERGE_VIRTUAL_DISK_PARAMETERS = record
410 | Version: TMERGE_VIRTUAL_DISK_VERSION;
411 | case Integer of
412 | 0: ( Version1: TMergeVirtualDiskParametersVersion1; );
413 | end;
414 | TMergeVirtualDiskParameters = _MERGE_VIRTUAL_DISK_PARAMETERS;
415 | MERGE_VIRTUAL_DISK_PARAMETERS = _MERGE_VIRTUAL_DISK_PARAMETERS;
416 |
417 | TMERGE_VIRTUAL_DISK_FLAG = (
418 | MERGE_VIRTUAL_DISK_FLAG_NONE = $00000000
419 | );
420 |
421 | function MergeVirtualDisk(
422 | VirtualDiskHandle: THandle;
423 | Flags: TMERGE_VIRTUAL_DISK_FLAG;
424 | Parameters: PMergeVirtualDiskParameters;
425 | Overlapped: POverlapped
426 | ): DWORD; stdcall;
427 |
428 |
429 | // ExpandVirtualDisk
430 | type
431 | TEXPAND_VIRTUAL_DISK_VERSION = (
432 | EXPAND_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0,
433 | EXPAND_VIRTUAL_DISK_VERSION_1 = 1
434 | );
435 |
436 | TExpandVirtualDiskParametersVersion1 = record
437 | NewSize: ULONGLONG;
438 | end;
439 |
440 | PExpandVirtualDiskParameters = ^TExpandVirtualDiskParameters;
441 | _EXPAND_VIRTUAL_DISK_PARAMETERS = record
442 | Version: TEXPAND_VIRTUAL_DISK_VERSION;
443 | case Integer of
444 | 0: ( Version1: TExpandVirtualDiskParametersVersion1; );
445 | end;
446 | TExpandVirtualDiskParameters = _EXPAND_VIRTUAL_DISK_PARAMETERS;
447 | EXPAND_VIRTUAL_DISK_PARAMETERS = _EXPAND_VIRTUAL_DISK_PARAMETERS;
448 |
449 | TEXPAND_VIRTUAL_DISK_FLAG = (
450 | EXPAND_VIRTUAL_DISK_FLAG_NONE = $00000000
451 | );
452 |
453 | function ExpandVirtualDisk(
454 | VirtualDiskHandle: THANDLE;
455 | Flags: TEXPAND_VIRTUAL_DISK_FLAG;
456 | Parameters: PExpandVirtualDiskParameters;
457 | Overlapped: POverlapped
458 | ): DWORD; stdcall;
459 |
460 |
461 | implementation
462 |
463 | const
464 | VirtDiskDLLName = 'VirtDisk.dll';
465 |
466 | function OpenVirtualDisk; external VirtDiskDLLName name 'OpenVirtualDisk';
467 | function CreateVirtualDisk; external VirtDiskDLLName name 'CreateVirtualDisk';
468 | function AttachVirtualDisk; external VirtDiskDLLName name 'AttachVirtualDisk';
469 | function DetachVirtualDisk; external VirtDiskDLLName name 'DetachVirtualDisk';
470 | function GetVirtualDiskPhysicalPath; external VirtDiskDLLName name 'GetVirtualDiskPhysicalPath';
471 | function GetStorageDependencyInformation; external VirtDiskDLLName name 'GetStorageDependencyInformation';
472 | function GetVirtualDiskInformation; external VirtDiskDLLName name 'GetVirtualDiskInformation';
473 | function SetVirtualDiskInformation; external VirtDiskDLLName name 'SetVirtualDiskInformation';
474 | function GetVirtualDiskOperationProgress; external VirtDiskDLLName name 'GetVirtualDiskOperationProgress';
475 | function CompactVirtualDisk; external VirtDiskDLLName name 'CompactVirtualDisk';
476 | function MergeVirtualDisk; external VirtDiskDLLName name 'MergeVirtualDisk';
477 | function ExpandVirtualDisk; external VirtDiskDLLName name 'ExpandVirtualDisk';
478 |
479 | end.
480 |
--------------------------------------------------------------------------------
/example/FirewallExample/FirewallExampleMainForm.pas:
--------------------------------------------------------------------------------
1 | unit FirewallExampleMainForm;
2 |
3 | interface
4 |
5 | uses
6 | Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
7 | Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, NetFwTypeLib_TLB;
8 |
9 | // reference
10 | // http://msdn.microsoft.com/en-us/library/windows/desktop/aa366459(v=vs.85).aspx
11 |
12 | // c++
13 | // http://msdn.microsoft.com/en-us/library/windows/desktop/ff956128(v=vs.85).aspx
14 |
15 | // vbs
16 | // http://msdn.microsoft.com/en-us/library/windows/desktop/ff956129(v=vs.85).aspx
17 |
18 | const
19 | NET_FW_IP_PROTOCOL_ICMPv4 = 1;
20 | NET_FW_IP_PROTOCOL_ICMPv6 = 58;
21 |
22 | type
23 | TFormFirewallExampleMain = class(TForm)
24 | Button1: TButton;
25 | MemoLog: TMemo;
26 | Button2: TButton;
27 | Button3: TButton;
28 | Button4: TButton;
29 | Button5: TButton;
30 | Button6: TButton;
31 | Button7: TButton;
32 | Button8: TButton;
33 | Button9: TButton;
34 | Button10: TButton;
35 | Button11: TButton;
36 | Button12: TButton;
37 | Button13: TButton;
38 | Button14: TButton;
39 | Button15: TButton;
40 | procedure Button1Click(Sender: TObject);
41 | procedure Button2Click(Sender: TObject);
42 | procedure Button3Click(Sender: TObject);
43 | procedure Button4Click(Sender: TObject);
44 | procedure Button5Click(Sender: TObject);
45 | procedure Button6Click(Sender: TObject);
46 | procedure Button7Click(Sender: TObject);
47 | procedure Button8Click(Sender: TObject);
48 | procedure Button9Click(Sender: TObject);
49 | procedure Button10Click(Sender: TObject);
50 | procedure Button11Click(Sender: TObject);
51 | procedure Button12Click(Sender: TObject);
52 | procedure Button13Click(Sender: TObject);
53 | procedure Button14Click(Sender: TObject);
54 | procedure Button15Click(Sender: TObject);
55 | private
56 | { Private declarations }
57 | procedure PrintRuleToMemo( const ARule: INetFwRule );
58 | public
59 | { Public declarations }
60 | end;
61 |
62 | var
63 | FormFirewallExampleMain: TFormFirewallExampleMain;
64 |
65 | implementation
66 |
67 | uses
68 | ComObj, ActiveX;
69 |
70 | {$R *.dfm}
71 |
72 | procedure TFormFirewallExampleMain.Button10Click(Sender: TObject);
73 | var
74 | FwPolicy2: INetFwPolicy2;
75 | // CurrentProfiles: Integer;
76 | // InterfaceArray: Variant;
77 | begin
78 | MemoLog.Clear;
79 |
80 | CoInitialize( nil );
81 | try
82 | FwPolicy2 := INetFwPolicy2(CreateOleObject( 'HNetCfg.FwPolicy2' ));
83 | {
84 | CurrentProfiles := FwPolicy2.CurrentProfileTypes;
85 |
86 | InterfaceArray := VarArrayCreate( [0, 0], varVariant );
87 | InterfaceArray[0] := 'Local Area Connection';
88 | // InterfaceArray[0] := '로컬 영역 연결';
89 |
90 | if (CurrentProfiles and NET_FW_PROFILE2_DOMAIN) <> 0 then
91 | FwPolicy2.ExcludedInterfaces[NET_FW_PROFILE2_DOMAIN] := InterfaceArray;
92 |
93 | if (CurrentProfiles and NET_FW_PROFILE2_PRIVATE) <> 0 then
94 | FwPolicy2.ExcludedInterfaces[NET_FW_PROFILE2_PRIVATE] := InterfaceArray;
95 |
96 | if (CurrentProfiles and NET_FW_PROFILE2_PUBLIC) <> 0 then
97 | FwPolicy2.ExcludedInterfaces[NET_FW_PROFILE2_PUBLIC] := InterfaceArray;
98 | }
99 | finally
100 | CoUninitialize;
101 | end;
102 | end;
103 |
104 | procedure TFormFirewallExampleMain.Button11Click(Sender: TObject);
105 | var
106 | FwPolicy2: INetFwPolicy2;
107 | begin
108 | MemoLog.Clear;
109 |
110 | CoInitialize( nil );
111 | try
112 | FwPolicy2 := INetFwPolicy2(CreateOleObject( 'HNetCfg.FwPolicy2' ));
113 | fwPolicy2.EnableRuleGroup( fwPolicy2.CurrentProfileTypes, 'File and Printer Sharing', True );
114 | finally
115 | CoUninitialize;
116 | end;
117 | end;
118 |
119 | procedure TFormFirewallExampleMain.Button12Click(Sender: TObject);
120 | var
121 | FwPolicy2: INetFwPolicy2;
122 | CurrentProfiles: Integer;
123 | Rule: INetFwRule;
124 | Enumerator: IInterface;
125 | hr: HRESULT;
126 | pVariant: IEnumVARIANT;
127 | pVar: OleVariant;
128 | cFetched: DWORD;
129 | begin
130 | MemoLog.Clear;
131 |
132 | MemoLog.Lines.BeginUpdate;
133 | CoInitialize( nil );
134 | try
135 | FwPolicy2 := INetFwPolicy2(CreateOleObject( 'HNetCfg.FwPolicy2' ));
136 |
137 | CurrentProfiles := fwPolicy2.CurrentProfileTypes;
138 |
139 | if CurrentProfiles and NET_FW_PROFILE2_DOMAIN <> 0 then
140 | MemoLog.Lines.Add( 'Domain Firewall Profile is active' );
141 | if CurrentProfiles and NET_FW_PROFILE2_PRIVATE <> 0 then
142 | MemoLog.Lines.Add( 'Private Firewall Profile is active' );
143 | if CurrentProfiles and NET_FW_PROFILE2_PUBLIC <> 0 then
144 | MemoLog.Lines.Add( 'Public Firewall Profile is active' );
145 |
146 | MemoLog.Lines.Add( '' );
147 | MemoLog.Lines.Add( '' );
148 |
149 | MemoLog.Lines.Add( 'Rules Count = ' + IntToStr(FwPolicy2.Rules.Count) );
150 | MemoLog.Lines.Add( '' );
151 |
152 | Enumerator := fwPolicy2.Rules._NewEnum;
153 | // Enumerator.QueryInterface( __uuidof(IEnumVARIANT), Variant );
154 | hr := Enumerator.QueryInterface( StringToGUID('{00020404-0000-0000-C000-000000000046}'), pVariant );
155 |
156 | while Succeeded(hr) and (hr <> S_FALSE) do
157 | begin
158 | hr := pVariant.Next( 1, pVar, cFetched );
159 |
160 | if hr = S_OK then
161 | begin
162 | hr := IInterface(pVar).QueryInterface( StringToGUID('{AF230D27-BABA-4E42-ACED-F524F22CFCE2}'), Rule );
163 |
164 | if SUCCEEDED( hr ) then
165 | begin
166 | // 전체를 출력할 것인지... 부분만 출력할것인지
167 | if Rule.Profiles and FwPolicy2.CurrentProfileTypes <> 0 then
168 | // 그룹 맞는것 출력
169 | // if ARule.Grouping = '@firewallapi.dll,-23255' then
170 | PrintRuleToMemo( Rule );
171 | end;
172 | end;
173 | end;
174 | finally
175 | CoUninitialize;
176 | MemoLog.Lines.EndUpdate;
177 | end;
178 | end;
179 |
180 | procedure TFormFirewallExampleMain.Button13Click(Sender: TObject);
181 | var
182 | FwPolicy2: INetFwPolicy2;
183 | NewInboundRule, NewOutboundRule: INetFwRule;
184 | begin
185 | CoInitialize( nil );
186 | try
187 | FwPolicy2 := INetFwPolicy2(CreateOleObject( 'HNetCfg.FwPolicy2' ));
188 |
189 | // Very Very Very Danger~~!!!!
190 | // fwPolicy2.ServiceRestriction.RestrictService( 'TermService', '%systemDrive%\WINDOWS\system32\svchost.exe', TRUE, FALSE );
191 | // fwPolicy2.ServiceRestriction.RestrictService( 'TermService', '%systemDrive%\WINDOWS\system32\svchost.exe', FALSE, FALSE );
192 |
193 | NewInboundRule := INetFwRule(CreateOleObject( 'HNetCfg.FWRule' ));
194 | NewInboundRule.Name := 'Allow only TCP 3389 inbound to service';
195 | NewInboundRule.ApplicationName := '%systemDrive%\WINDOWS\system32\svchost.exe';
196 | NewInboundRule.ServiceName := 'TermService';
197 | NewInboundRule.Protocol := NET_FW_IP_PROTOCOL_TCP;
198 | NewInboundRule.LocalPorts := '3389';
199 | NewInboundRule.Action := NET_FW_ACTION_ALLOW;
200 | NewInboundRule.Direction := NET_FW_RULE_DIR_IN;
201 | NewInboundRule.Enabled := True;
202 | fwPolicy2.Rules.Add( NewInboundRule );
203 |
204 | NewOutboundRule := INetFwRule(CreateOleObject( 'HNetCfg.FWRule' ));
205 | NewOutboundRule.Name := 'Allow outbound traffic from service only from TCP 3389';
206 | NewOutboundRule.ApplicationName := '%systemDrive%\WINDOWS\system32\svchost.exe';
207 | NewOutboundRule.ServiceName := 'TermService';
208 | NewOutboundRule.Protocol := NET_FW_IP_PROTOCOL_TCP;
209 | NewOutboundRule.LocalPorts := '3389';
210 | NewOutboundRule.Action := NET_FW_ACTION_ALLOW;
211 | NewOutboundRule.Direction := NET_FW_RULE_DIR_OUT;
212 | NewOutboundRule.Enabled := True;
213 | FwPolicy2.Rules.Add( NewOutboundRule );
214 | finally
215 | CoUninitialize;
216 | end;
217 | end;
218 |
219 | procedure TFormFirewallExampleMain.Button14Click(Sender: TObject);
220 | var
221 | FwPolicy2: INetFwPolicy2;
222 | CurrentProfiles: Integer;
223 | begin
224 | MemoLog.Clear;
225 |
226 | MemoLog.Lines.BeginUpdate;
227 | CoInitialize( nil );
228 | try
229 | FwPolicy2 := INetFwPolicy2(CreateOleObject( 'HNetCfg.FwPolicy2' ));
230 |
231 | CurrentProfiles := fwPolicy2.CurrentProfileTypes;
232 |
233 | if CurrentProfiles and NET_FW_PROFILE2_DOMAIN <> 0 then
234 | if FwPolicy2.FirewallEnabled[NET_FW_PROFILE2_DOMAIN] then
235 | MemoLog.Lines.Add( 'Firewall is ON on domain profile.' )
236 | else
237 | MemoLog.Lines.Add( 'Firewall is OFF on domain profile.' );
238 |
239 | if CurrentProfiles and NET_FW_PROFILE2_PRIVATE <> 0 then
240 | if FwPolicy2.FirewallEnabled[NET_FW_PROFILE2_PRIVATE] then
241 | MemoLog.Lines.Add( 'Firewall is ON on private profile.' )
242 | else
243 | MemoLog.Lines.Add( 'Firewall is OFF on private profile.' );
244 |
245 | if CurrentProfiles and NET_FW_PROFILE2_PUBLIC <> 0 then
246 | if FwPolicy2.FirewallEnabled[NET_FW_PROFILE2_PUBLIC] then
247 | MemoLog.Lines.Add( 'Firewall is ON on public profile.' )
248 | else
249 | MemoLog.Lines.Add( 'Firewall is OFF on public profile.' );
250 | finally
251 | CoUninitialize;
252 | MemoLog.Lines.EndUpdate;
253 | end;
254 | end;
255 |
256 | procedure TFormFirewallExampleMain.Button15Click(Sender: TObject);
257 | var
258 | FwPolicy2: INetFwPolicy2;
259 | CurrentProfiles: Integer;
260 | begin
261 | CoInitialize( nil );
262 | try
263 | FwPolicy2 := INetFwPolicy2(CreateOleObject( 'HNetCfg.FwPolicy2' ));
264 |
265 | CurrentProfiles := fwPolicy2.CurrentProfileTypes;
266 |
267 | if CurrentProfiles and NET_FW_PROFILE2_DOMAIN <> 0 then
268 | fwPolicy2.FirewallEnabled[NET_FW_PROFILE2_DOMAIN] := False;
269 | if CurrentProfiles and NET_FW_PROFILE2_PRIVATE <> 0 then
270 | fwPolicy2.FirewallEnabled[NET_FW_PROFILE2_PRIVATE] := False;
271 | if CurrentProfiles and NET_FW_PROFILE2_PUBLIC <> 0 then
272 | fwPolicy2.FirewallEnabled[NET_FW_PROFILE2_PUBLIC] := False;
273 | finally
274 | CoUninitialize;
275 | end;
276 | end;
277 |
278 | procedure TFormFirewallExampleMain.Button1Click(Sender: TObject);
279 | var
280 | FwPolicy2: INetFwPolicy2;
281 | NewRule: INetFwRule;
282 | begin
283 | CoInitialize( nil );
284 | try
285 | FwPolicy2 := INetFwPolicy2(CreateOleObject( 'HNetCfg.FwPolicy2' ));
286 | NewRule := INetFwRule(CreateOleObject( 'HNetCfg.FWRule' ));
287 |
288 | NewRule.Name := 'Per_InterfaceType_Rule';
289 | NewRule.Description := 'Allow incoming network traffic over port 2400 coming from LAN interfcace type';
290 | NewRule.Protocol := NET_FW_IP_PROTOCOL_TCP;
291 | NewRule.LocalPorts := '2300';
292 | NewRule.Interfacetypes := 'LAN';
293 | NewRule.Enabled := TRUE;
294 | NewRule.Grouping := '@firewallapi.dll,-23255';
295 | NewRule.Profiles := FwPolicy2.CurrentProfileTypes;
296 | NewRule.Action := NET_FW_ACTION_ALLOW;
297 |
298 | FwPolicy2.Rules.Add( NewRule );
299 | finally
300 | CoUninitialize;
301 | end;
302 | end;
303 |
304 | procedure TFormFirewallExampleMain.Button2Click(Sender: TObject);
305 | var
306 | FwPolicy2: INetFwPolicy2;
307 | NewRule: INetFwRule;
308 | InterfaceArray: Variant;
309 | begin
310 | CoInitialize( nil );
311 | try
312 | FwPolicy2 := INetFwPolicy2(CreateOleObject( 'HNetCfg.FwPolicy2' ));
313 | NewRule := INetFwRule(CreateOleObject( 'HNetCfg.FWRule' ));
314 |
315 | InterfaceArray := VarArrayCreate( [0, 0], varVariant );
316 | InterfaceArray[0] := 'Local Area Connection';
317 | // InterfaceArray[0] := '로컬 영역 연결';
318 |
319 | NewRule.Name := 'Per_Interface_Rule';
320 | NewRule.Description := 'Add a Per Interface Rule';
321 | NewRule.Protocol := NET_FW_IP_PROTOCOL_TCP;
322 | NewRule.LocalPorts := '2300';
323 | NewRule.Enabled := TRUE;
324 | NewRule.Grouping := '@firewallapi.dll,-23255';
325 | NewRule.Profiles := FwPolicy2.CurrentProfileTypes;
326 | NewRule.Interfaces := InterfaceArray;
327 | NewRule.Action := NET_FW_ACTION_ALLOW;
328 |
329 | FwPolicy2.Rules.Add( NewRule );
330 | finally
331 | CoUninitialize;
332 | end;
333 | end;
334 |
335 | procedure TFormFirewallExampleMain.Button3Click(Sender: TObject);
336 | var
337 | FwPolicy2: INetFwPolicy2;
338 | NewRule: INetFwRule;
339 | begin
340 | CoInitialize( nil );
341 | try
342 | FwPolicy2 := INetFwPolicy2(CreateOleObject( 'HNetCfg.FwPolicy2' ));
343 | NewRule := INetFwRule(CreateOleObject( 'HNetCfg.FWRule' ));
344 |
345 | NewRule.Name := 'GRE_RULE';
346 | NewRule.Description := 'Allow GRE Traffic';
347 | NewRule.Protocol := 47;
348 | NewRule.Enabled := TRUE;
349 | NewRule.Grouping := '@firewallapi.dll,-23255';
350 | NewRule.Profiles := FwPolicy2.CurrentProfileTypes;
351 | NewRule.Action := NET_FW_ACTION_ALLOW;
352 |
353 | FwPolicy2.Rules.Add( NewRule );
354 | finally
355 | CoUninitialize;
356 | end;
357 | end;
358 |
359 | procedure TFormFirewallExampleMain.Button4Click(Sender: TObject);
360 | var
361 | FwPolicy2: INetFwPolicy2;
362 | NewRule: INetFwRule;
363 | begin
364 | CoInitialize( nil );
365 | try
366 | FwPolicy2 := INetFwPolicy2(CreateOleObject( 'HNetCfg.FwPolicy2' ));
367 | NewRule := INetFwRule(CreateOleObject( 'HNetCfg.FWRule' ));
368 |
369 | NewRule.Name := 'My Application Name with Edge Traversal';
370 | NewRule.Description := 'Allow my application network traffic with Edge Traversal';
371 | NewRule.Applicationname := '%systemDrive%\Program Files\MyApplication.exe';
372 | NewRule.Protocol := NET_FW_IP_PROTOCOL_TCP;
373 | NewRule.LocalPorts := '5000';
374 | NewRule.Enabled := TRUE;
375 | NewRule.Grouping := '@firewallapi.dll,-23255';
376 | NewRule.Profiles := FwPolicy2.CurrentProfileTypes;
377 | NewRule.Action := NET_FW_ACTION_ALLOW;
378 | NewRule.EdgeTraversal := TRUE;
379 |
380 | FwPolicy2.Rules.Add( NewRule );
381 | finally
382 | CoUninitialize;
383 | end;
384 | end;
385 |
386 | procedure TFormFirewallExampleMain.Button5Click(Sender: TObject);
387 | var
388 | FwPolicy2: INetFwPolicy2;
389 | NewRule: INetFwRule;
390 | begin
391 | CoInitialize( nil );
392 | try
393 | FwPolicy2 := INetFwPolicy2(CreateOleObject( 'HNetCfg.FwPolicy2' ));
394 | NewRule := INetFwRule(CreateOleObject( 'HNetCfg.FWRule' ));
395 |
396 | NewRule.Name := 'Service_Rule';
397 | NewRule.Description := 'Allow incoming network traffic to myservice';
398 | NewRule.Applicationname := '%SystemDrive%\Windows\system32\myservice.exe';
399 | NewRule.Servicename := 'myservicename';
400 | NewRule.Protocol := NET_FW_IP_PROTOCOL_TCP;
401 | NewRule.LocalPorts := '135';
402 | NewRule.Grouping := '@firewallapi.dll,-23255';
403 | NewRule.Profiles := FwPolicy2.CurrentProfileTypes;
404 | NewRule.Enabled := TRUE;
405 | NewRule.Action := NET_FW_ACTION_ALLOW;
406 |
407 | FwPolicy2.Rules.Add( NewRule );
408 | finally
409 | CoUninitialize;
410 | end;
411 | end;
412 |
413 | procedure TFormFirewallExampleMain.Button6Click(Sender: TObject);
414 | var
415 | FwPolicy2: INetFwPolicy2;
416 | NewRule: INetFwRule;
417 | begin
418 | CoInitialize( nil );
419 | try
420 | FwPolicy2 := INetFwPolicy2(CreateOleObject( 'HNetCfg.FwPolicy2' ));
421 | NewRule := INetFwRule(CreateOleObject( 'HNetCfg.FWRule' ));
422 |
423 | NewRule.Name := 'ICMP_Rule';
424 | NewRule.Description := 'Allow ICMP network traffic';
425 | NewRule.Protocol := NET_FW_IP_PROTOCOL_ICMPv4;
426 | NewRule.IcmpTypesAndCodes := '1:1';
427 | NewRule.Enabled := TRUE;
428 | NewRule.Grouping := '@firewallapi.dll,-23255';
429 | NewRule.Profiles := FwPolicy2.CurrentProfileTypes;
430 | NewRule.Action := NET_FW_ACTION_ALLOW;
431 |
432 | FwPolicy2.Rules.Add( NewRule );
433 | finally
434 | CoUninitialize;
435 | end;
436 | end;
437 |
438 | procedure TFormFirewallExampleMain.Button7Click(Sender: TObject);
439 | var
440 | FwPolicy2: INetFwPolicy2;
441 | NewRule: INetFwRule;
442 | begin
443 | CoInitialize( nil );
444 | try
445 | FwPolicy2 := INetFwPolicy2(CreateOleObject( 'HNetCfg.FwPolicy2' ));
446 | NewRule := INetFwRule(CreateOleObject( 'HNetCfg.FWRule' ));
447 |
448 | NewRule.Name := 'My Application Name';
449 | NewRule.Description := 'Allow my application network traffic';
450 | NewRule.Applicationname := '%systemDrive%\Program Files\MyApplication.exe';
451 | NewRule.Protocol := NET_FW_IP_PROTOCOL_TCP;
452 | NewRule.LocalPorts := '4000';
453 | NewRule.Enabled := TRUE;
454 | NewRule.Grouping := '@firewallapi.dll,-23255';
455 | NewRule.Profiles := FwPolicy2.CurrentProfileTypes;
456 | NewRule.Action := NET_FW_ACTION_ALLOW;
457 |
458 | FwPolicy2.Rules.Add( NewRule );
459 | finally
460 | CoUninitialize;
461 | end;
462 | end;
463 |
464 | procedure TFormFirewallExampleMain.Button8Click(Sender: TObject);
465 | var
466 | FwPolicy2: INetFwPolicy2;
467 | NewRule: INetFwRule;
468 | begin
469 | CoInitialize( nil );
470 | try
471 | FwPolicy2 := INetFwPolicy2(CreateOleObject( 'HNetCfg.FwPolicy2' ));
472 | NewRule := INetFwRule(CreateOleObject( 'HNetCfg.FWRule' ));
473 |
474 | NewRule.Name := 'Outbound_Rule';
475 | NewRule.Description := 'Allow outbound network traffic from my Application over TCP port 4000';
476 | NewRule.Applicationname := '%systemDrive%\Program Files\MyApplication.exe';
477 | NewRule.Protocol := NET_FW_IP_PROTOCOL_TCP;
478 | NewRule.LocalPorts := '4000';
479 | NewRule.Direction := NET_FW_RULE_DIR_OUT;
480 | NewRule.Enabled := TRUE;
481 | NewRule.Grouping := '@firewallapi.dll,-23255';
482 | NewRule.Profiles := FwPolicy2.CurrentProfileTypes;
483 | NewRule.Action := NET_FW_ACTION_ALLOW;
484 |
485 | FwPolicy2.Rules.Add( NewRule );
486 | finally
487 | CoUninitialize;
488 | end;
489 | end;
490 |
491 | procedure TFormFirewallExampleMain.Button9Click(Sender: TObject);
492 | var
493 | FwPolicy2: INetFwPolicy2;
494 | begin
495 | MemoLog.Clear;
496 |
497 | CoInitialize( nil );
498 | try
499 | FwPolicy2 := INetFwPolicy2(CreateOleObject( 'HNetCfg.FwPolicy2' ));
500 |
501 | if FwPolicy2.IsRuleGroupCurrentlyEnabled[ 'File and Printer Sharing' ] then
502 | MemoLog.Lines.Add( 'File and Printer Sharing is currently enabled on at least one of the current profiles' )
503 | else
504 | MemoLog.Lines.Add( 'File and Printer Sharing is currently not enabled on any of the current profiles' );
505 |
506 | MemoLog.Lines.Add( '' );
507 | MemoLog.Lines.Add( '' );
508 |
509 | case fwPolicy2.LocalPolicyModifyState of
510 | NET_FW_MODIFY_STATE_OK: MemoLog.Lines.Add( 'Changing or adding a firewall rule (or group) will take effect on at least one of the current profiles.' );
511 | NET_FW_MODIFY_STATE_GP_OVERRIDE: MemoLog.Lines.Add( 'Changing or adding a firewall rule (or group) to the current profiles will not take effect because group policy overrides it on at least one of the current profiles.' );
512 | NET_FW_MODIFY_STATE_INBOUND_BLOCKED: MemoLog.Lines.Add( 'Changing or adding an inbound firewall rule (or group) to the current profiles will not take effect because inbound rules are not allowed on at least one of the current profiles.' );
513 | else
514 | MemoLog.Lines.Add( 'Invalid Modify State returned by LocalPolicyModifyState.' );
515 | end;
516 | finally
517 | CoUninitialize;
518 | end;
519 | end;
520 |
521 | procedure TFormFirewallExampleMain.PrintRuleToMemo(const ARule: INetFwRule);
522 | var
523 | InterfaceArray: Variant;
524 | I: Integer;
525 | begin
526 | MemoLog.Lines.Add(' Rule Name: ' + ARule.Name);
527 | MemoLog.Lines.Add(' ----------------------------------------------');
528 | MemoLog.Lines.Add(' Description: ' + ARule.Description);
529 | MemoLog.Lines.Add(' Application Name: ' + ARule.ApplicationName);
530 | MemoLog.Lines.Add(' Service Name: ' + ARule.ServiceName);
531 | case ARule.Protocol of
532 | NET_FW_IP_PROTOCOL_TCP: MemoLog.Lines.Add(' IP Protocol: TCP.');
533 | NET_FW_IP_PROTOCOL_UDP: MemoLog.Lines.Add(' IP Protocol: UDP.');
534 | NET_FW_IP_PROTOCOL_ICMPv4: MemoLog.Lines.Add(' IP Protocol: UDP.');
535 | NET_FW_IP_PROTOCOL_ICMPv6: MemoLog.Lines.Add(' IP Protocol: UDP.');
536 | else MemoLog.Lines.Add(' IP Protocol: ' + IntToStr(ARule.Protocol));
537 | end;
538 |
539 | if (ARule.Protocol = NET_FW_IP_PROTOCOL_TCP) or (ARule.Protocol = NET_FW_IP_PROTOCOL_UDP) then
540 | begin
541 | MemoLog.Lines.Add(' Local Ports: ' + ARule.LocalPorts);
542 | MemoLog.Lines.Add(' Remote Ports: ' + ARule.RemotePorts);
543 | MemoLog.Lines.Add(' LocalAddresses: ' + ARule.LocalAddresses);
544 | MemoLog.Lines.Add(' RemoteAddresses: ' + ARule.RemoteAddresses);
545 | end;
546 |
547 | if (ARule.Protocol = NET_FW_IP_PROTOCOL_ICMPv4) or (ARule.Protocol = NET_FW_IP_PROTOCOL_ICMPv6) then
548 | MemoLog.Lines.Add(' ICMP Type and Code: ' + ARule.IcmpTypesAndCodes);
549 |
550 | case ARule.Direction of
551 | NET_FW_RULE_DIR_IN: MemoLog.Lines.Add(' Direction: In');
552 | NET_FW_RULE_DIR_OUT: MemoLog.Lines.Add(' Direction: Out');
553 | end;
554 |
555 | MemoLog.Lines.Add(' Enabled: ' + BoolToStr(ARule.Enabled, True));
556 | MemoLog.Lines.Add(' Edge: ' + BoolToStr(ARule.EdgeTraversal, True));
557 | case ARule.Action of
558 | NET_FW_ACTION_ALLOW: MemoLog.Lines.Add(' Action: Allow');
559 | NET_FW_ACTION_BLOCk: MemoLog.Lines.Add(' Action: Block');
560 | end;
561 | MemoLog.Lines.Add(' Grouping: ' + ARule.Grouping);
562 | MemoLog.Lines.Add(' Interface Types: ' + ARule.InterfaceTypes);
563 |
564 | InterfaceArray := ARule.Interfaces;
565 | if VarIsEmpty(InterfaceArray) then
566 | MemoLog.Lines.Add(' Interfaces: All')
567 | else
568 | begin
569 | { TODO : Interfaces 출력 }
570 | for I := VarArrayLowBound(InterfaceArray, 0) to VarArrayHighBound(InterfaceArray, 0) do
571 | begin
572 | MemoLog.Lines.Add(' ' + InterfaceArray[i]);
573 | end;
574 |
575 | {
576 | LowerBound = LBound(InterfaceArray);
577 | UpperBound = UBound(InterfaceArray);
578 | MemoLog.Lines.Add(' Interfaces: ');
579 | for iterate = LowerBound To UpperBound
580 | MemoLog.Lines.Add(' ' + InterfaceArray(iterate););
581 | Next
582 | }
583 | end;
584 |
585 | MemoLog.Lines.Add('');
586 | end;
587 |
588 | end.
589 |
--------------------------------------------------------------------------------
/lib/NetFwTypeLib_TLB.pas:
--------------------------------------------------------------------------------
1 | unit NetFwTypeLib_TLB;
2 |
3 | // ************************************************************************ //
4 | // WARNING
5 | // -------
6 | // The types declared in this file were generated from data read from a
7 | // Type Library. If this type library is explicitly or indirectly (via
8 | // another type library referring to this type library) re-imported, or the
9 | // 'Refresh' command of the Type Library Editor activated while editing the
10 | // Type Library, the contents of this file will be regenerated and all
11 | // manual modifications will be lost.
12 | // ************************************************************************ //
13 |
14 | // $Rev: 45604 $
15 | // File generated on 2012-10-09 오후 4:14:43 from Type Library described below.
16 |
17 | // ************************************************************************ //
18 | // Type Lib: C:\Windows\SysWOW64\FirewallAPI.dll (1)
19 | // LIBID: {58FBCF7C-E7A9-467C-80B3-FC65E8FCCA08}
20 | // LCID: 0
21 | // Helpfile:
22 | // HelpString:
23 | // DepndLst:
24 | // (1) v2.0 stdole, (C:\Windows\SysWOW64\stdole2.tlb)
25 | // SYS_KIND: SYS_WIN32
26 | // Errors:
27 | // Hint: Symbol 'Type' renamed to 'type_'
28 | // Hint: Parameter 'Type' of INetFwService.Type changed to 'Type_'
29 | // Hint: Parameter 'Type' of INetFwProfile.Type changed to 'Type_'
30 | // Hint: Parameter 'Type' of INetFwMgr.IsIcmpTypeAllowed changed to 'Type_'
31 | // ************************************************************************ //
32 | {$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers.
33 | {$WARN SYMBOL_PLATFORM OFF}
34 | {$WRITEABLECONST ON}
35 | {$VARPROPSETTER ON}
36 | {$ALIGN 4}
37 |
38 | interface
39 |
40 | uses Winapi.Windows, System.Classes, System.Variants, System.Win.StdVCL, Vcl.Graphics, Winapi.ActiveX;
41 |
42 |
43 | // *********************************************************************//
44 | // GUIDS declared in the TypeLibrary. Following prefixes are used:
45 | // Type Libraries : LIBID_xxxx
46 | // CoClasses : CLASS_xxxx
47 | // DISPInterfaces : DIID_xxxx
48 | // Non-DISP interfaces: IID_xxxx
49 | // *********************************************************************//
50 | const
51 | // TypeLibrary Major and minor versions
52 | NetFwTypeLibMajorVersion = 1;
53 | NetFwTypeLibMinorVersion = 0;
54 |
55 | LIBID_NetFwTypeLib: TGUID = '{58FBCF7C-E7A9-467C-80B3-FC65E8FCCA08}';
56 |
57 | IID_INetFwRemoteAdminSettings: TGUID = '{D4BECDDF-6F73-4A83-B832-9C66874CD20E}';
58 | IID_INetFwIcmpSettings: TGUID = '{A6207B2E-7CDD-426A-951E-5E1CBC5AFEAD}';
59 | IID_INetFwOpenPort: TGUID = '{E0483BA0-47FF-4D9C-A6D6-7741D0B195F7}';
60 | IID_INetFwOpenPorts: TGUID = '{C0E9D7FA-E07E-430A-B19A-090CE82D92E2}';
61 | IID_INetFwService: TGUID = '{79FD57C8-908E-4A36-9888-D5B3F0A444CF}';
62 | IID_INetFwServices: TGUID = '{79649BB4-903E-421B-94C9-79848E79F6EE}';
63 | IID_INetFwAuthorizedApplication: TGUID = '{B5E64FFA-C2C5-444E-A301-FB5E00018050}';
64 | IID_INetFwAuthorizedApplications: TGUID = '{644EFD52-CCF9-486C-97A2-39F352570B30}';
65 | IID_INetFwServiceRestriction: TGUID = '{8267BBE3-F890-491C-B7B6-2DB1EF0E5D2B}';
66 | IID_INetFwRules: TGUID = '{9C4C6277-5027-441E-AFAE-CA1F542DA009}';
67 | IID_INetFwRule: TGUID = '{AF230D27-BABA-4E42-ACED-F524F22CFCE2}';
68 | IID_INetFwRule2: TGUID = '{9C27C8DA-189B-4DDE-89F7-8B39A316782C}';
69 | IID_INetFwProfile: TGUID = '{174A0DDA-E9F9-449D-993B-21AB667CA456}';
70 | IID_INetFwPolicy: TGUID = '{D46D2478-9AC9-4008-9DC7-5563CE5536CC}';
71 | IID_INetFwPolicy2: TGUID = '{98325047-C671-4174-8D81-DEFCD3F03186}';
72 | IID_INetFwMgr: TGUID = '{F7898AF5-CAC4-4632-A2EC-DA06E5111AF2}';
73 | IID_INetFwProduct: TGUID = '{71881699-18F4-458B-B892-3FFCE5E07F75}';
74 | IID_INetFwProducts: TGUID = '{39EB36E0-2097-40BD-8AF2-63A13B525362}';
75 |
76 | // *********************************************************************//
77 | // Declaration of Enumerations defined in Type Library
78 | // *********************************************************************//
79 | // Constants for enum NET_FW_IP_VERSION_
80 | type
81 | NET_FW_IP_VERSION_ = TOleEnum;
82 | const
83 | NET_FW_IP_VERSION_V4 = $00000000;
84 | NET_FW_IP_VERSION_V6 = $00000001;
85 | NET_FW_IP_VERSION_ANY = $00000002;
86 | NET_FW_IP_VERSION_MAX = $00000003;
87 |
88 | // Constants for enum NET_FW_SCOPE_
89 | type
90 | NET_FW_SCOPE_ = TOleEnum;
91 | const
92 | NET_FW_SCOPE_ALL = $00000000;
93 | NET_FW_SCOPE_LOCAL_SUBNET = $00000001;
94 | NET_FW_SCOPE_CUSTOM = $00000002;
95 | NET_FW_SCOPE_MAX = $00000003;
96 |
97 | // Constants for enum NET_FW_IP_PROTOCOL_
98 | type
99 | NET_FW_IP_PROTOCOL_ = TOleEnum;
100 | const
101 | NET_FW_IP_PROTOCOL_TCP = $00000006;
102 | NET_FW_IP_PROTOCOL_UDP = $00000011;
103 | NET_FW_IP_PROTOCOL_ANY = $00000100;
104 |
105 | // Constants for enum NET_FW_SERVICE_TYPE_
106 | type
107 | NET_FW_SERVICE_TYPE_ = TOleEnum;
108 | const
109 | NET_FW_SERVICE_FILE_AND_PRINT = $00000000;
110 | NET_FW_SERVICE_UPNP = $00000001;
111 | NET_FW_SERVICE_REMOTE_DESKTOP = $00000002;
112 | NET_FW_SERVICE_NONE = $00000003;
113 | NET_FW_SERVICE_TYPE_MAX = $00000004;
114 |
115 | // Constants for enum NET_FW_RULE_DIRECTION_
116 | type
117 | NET_FW_RULE_DIRECTION_ = TOleEnum;
118 | const
119 | NET_FW_RULE_DIR_IN = $00000001;
120 | NET_FW_RULE_DIR_OUT = $00000002;
121 | NET_FW_RULE_DIR_MAX = $00000003;
122 |
123 | // Constants for enum NET_FW_ACTION_
124 | type
125 | NET_FW_ACTION_ = TOleEnum;
126 | const
127 | NET_FW_ACTION_BLOCK = $00000000;
128 | NET_FW_ACTION_ALLOW = $00000001;
129 | NET_FW_ACTION_MAX = $00000002;
130 |
131 | // Constants for enum NET_FW_PROFILE_TYPE_
132 | type
133 | NET_FW_PROFILE_TYPE_ = TOleEnum;
134 | const
135 | NET_FW_PROFILE_DOMAIN = $00000000;
136 | NET_FW_PROFILE_STANDARD = $00000001;
137 | NET_FW_PROFILE_CURRENT = $00000002;
138 | NET_FW_PROFILE_TYPE_MAX = $00000003;
139 |
140 | // Constants for enum NET_FW_PROFILE_TYPE2_
141 | type
142 | NET_FW_PROFILE_TYPE2_ = TOleEnum;
143 | const
144 | NET_FW_PROFILE2_DOMAIN = $00000001;
145 | NET_FW_PROFILE2_PRIVATE = $00000002;
146 | NET_FW_PROFILE2_PUBLIC = $00000004;
147 | NET_FW_PROFILE2_ALL = $7FFFFFFF;
148 |
149 | // Constants for enum NET_FW_MODIFY_STATE_
150 | type
151 | NET_FW_MODIFY_STATE_ = TOleEnum;
152 | const
153 | NET_FW_MODIFY_STATE_OK = $00000000;
154 | NET_FW_MODIFY_STATE_GP_OVERRIDE = $00000001;
155 | NET_FW_MODIFY_STATE_INBOUND_BLOCKED = $00000002;
156 |
157 | type
158 |
159 | // *********************************************************************//
160 | // Forward declaration of types defined in TypeLibrary
161 | // *********************************************************************//
162 | INetFwRemoteAdminSettings = interface;
163 | INetFwRemoteAdminSettingsDisp = dispinterface;
164 | INetFwIcmpSettings = interface;
165 | INetFwIcmpSettingsDisp = dispinterface;
166 | INetFwOpenPort = interface;
167 | INetFwOpenPortDisp = dispinterface;
168 | INetFwOpenPorts = interface;
169 | INetFwOpenPortsDisp = dispinterface;
170 | INetFwService = interface;
171 | INetFwServiceDisp = dispinterface;
172 | INetFwServices = interface;
173 | INetFwServicesDisp = dispinterface;
174 | INetFwAuthorizedApplication = interface;
175 | INetFwAuthorizedApplicationDisp = dispinterface;
176 | INetFwAuthorizedApplications = interface;
177 | INetFwAuthorizedApplicationsDisp = dispinterface;
178 | INetFwServiceRestriction = interface;
179 | INetFwServiceRestrictionDisp = dispinterface;
180 | INetFwRules = interface;
181 | INetFwRulesDisp = dispinterface;
182 | INetFwRule = interface;
183 | INetFwRuleDisp = dispinterface;
184 | INetFwRule2 = interface;
185 | INetFwRule2Disp = dispinterface;
186 | INetFwProfile = interface;
187 | INetFwProfileDisp = dispinterface;
188 | INetFwPolicy = interface;
189 | INetFwPolicyDisp = dispinterface;
190 | INetFwPolicy2 = interface;
191 | INetFwPolicy2Disp = dispinterface;
192 | INetFwMgr = interface;
193 | INetFwMgrDisp = dispinterface;
194 | INetFwProduct = interface;
195 | INetFwProductDisp = dispinterface;
196 | INetFwProducts = interface;
197 | INetFwProductsDisp = dispinterface;
198 |
199 | // *********************************************************************//
200 | // Interface: INetFwRemoteAdminSettings
201 | // Flags: (4416) Dual OleAutomation Dispatchable
202 | // GUID: {D4BECDDF-6F73-4A83-B832-9C66874CD20E}
203 | // *********************************************************************//
204 | INetFwRemoteAdminSettings = interface(IDispatch)
205 | ['{D4BECDDF-6F73-4A83-B832-9C66874CD20E}']
206 | function Get_IpVersion: NET_FW_IP_VERSION_; safecall;
207 | procedure Set_IpVersion(IpVersion: NET_FW_IP_VERSION_); safecall;
208 | function Get_Scope: NET_FW_SCOPE_; safecall;
209 | procedure Set_Scope(Scope: NET_FW_SCOPE_); safecall;
210 | function Get_RemoteAddresses: WideString; safecall;
211 | procedure Set_RemoteAddresses(const remoteAddrs: WideString); safecall;
212 | function Get_Enabled: WordBool; safecall;
213 | procedure Set_Enabled(Enabled: WordBool); safecall;
214 | property IpVersion: NET_FW_IP_VERSION_ read Get_IpVersion write Set_IpVersion;
215 | property Scope: NET_FW_SCOPE_ read Get_Scope write Set_Scope;
216 | property RemoteAddresses: WideString read Get_RemoteAddresses write Set_RemoteAddresses;
217 | property Enabled: WordBool read Get_Enabled write Set_Enabled;
218 | end;
219 |
220 | // *********************************************************************//
221 | // DispIntf: INetFwRemoteAdminSettingsDisp
222 | // Flags: (4416) Dual OleAutomation Dispatchable
223 | // GUID: {D4BECDDF-6F73-4A83-B832-9C66874CD20E}
224 | // *********************************************************************//
225 | INetFwRemoteAdminSettingsDisp = dispinterface
226 | ['{D4BECDDF-6F73-4A83-B832-9C66874CD20E}']
227 | property IpVersion: NET_FW_IP_VERSION_ dispid 1;
228 | property Scope: NET_FW_SCOPE_ dispid 2;
229 | property RemoteAddresses: WideString dispid 3;
230 | property Enabled: WordBool dispid 4;
231 | end;
232 |
233 | // *********************************************************************//
234 | // Interface: INetFwIcmpSettings
235 | // Flags: (4416) Dual OleAutomation Dispatchable
236 | // GUID: {A6207B2E-7CDD-426A-951E-5E1CBC5AFEAD}
237 | // *********************************************************************//
238 | INetFwIcmpSettings = interface(IDispatch)
239 | ['{A6207B2E-7CDD-426A-951E-5E1CBC5AFEAD}']
240 | function Get_AllowOutboundDestinationUnreachable: WordBool; safecall;
241 | procedure Set_AllowOutboundDestinationUnreachable(allow: WordBool); safecall;
242 | function Get_AllowRedirect: WordBool; safecall;
243 | procedure Set_AllowRedirect(allow: WordBool); safecall;
244 | function Get_AllowInboundEchoRequest: WordBool; safecall;
245 | procedure Set_AllowInboundEchoRequest(allow: WordBool); safecall;
246 | function Get_AllowOutboundTimeExceeded: WordBool; safecall;
247 | procedure Set_AllowOutboundTimeExceeded(allow: WordBool); safecall;
248 | function Get_AllowOutboundParameterProblem: WordBool; safecall;
249 | procedure Set_AllowOutboundParameterProblem(allow: WordBool); safecall;
250 | function Get_AllowOutboundSourceQuench: WordBool; safecall;
251 | procedure Set_AllowOutboundSourceQuench(allow: WordBool); safecall;
252 | function Get_AllowInboundRouterRequest: WordBool; safecall;
253 | procedure Set_AllowInboundRouterRequest(allow: WordBool); safecall;
254 | function Get_AllowInboundTimestampRequest: WordBool; safecall;
255 | procedure Set_AllowInboundTimestampRequest(allow: WordBool); safecall;
256 | function Get_AllowInboundMaskRequest: WordBool; safecall;
257 | procedure Set_AllowInboundMaskRequest(allow: WordBool); safecall;
258 | function Get_AllowOutboundPacketTooBig: WordBool; safecall;
259 | procedure Set_AllowOutboundPacketTooBig(allow: WordBool); safecall;
260 | property AllowOutboundDestinationUnreachable: WordBool read Get_AllowOutboundDestinationUnreachable write Set_AllowOutboundDestinationUnreachable;
261 | property AllowRedirect: WordBool read Get_AllowRedirect write Set_AllowRedirect;
262 | property AllowInboundEchoRequest: WordBool read Get_AllowInboundEchoRequest write Set_AllowInboundEchoRequest;
263 | property AllowOutboundTimeExceeded: WordBool read Get_AllowOutboundTimeExceeded write Set_AllowOutboundTimeExceeded;
264 | property AllowOutboundParameterProblem: WordBool read Get_AllowOutboundParameterProblem write Set_AllowOutboundParameterProblem;
265 | property AllowOutboundSourceQuench: WordBool read Get_AllowOutboundSourceQuench write Set_AllowOutboundSourceQuench;
266 | property AllowInboundRouterRequest: WordBool read Get_AllowInboundRouterRequest write Set_AllowInboundRouterRequest;
267 | property AllowInboundTimestampRequest: WordBool read Get_AllowInboundTimestampRequest write Set_AllowInboundTimestampRequest;
268 | property AllowInboundMaskRequest: WordBool read Get_AllowInboundMaskRequest write Set_AllowInboundMaskRequest;
269 | property AllowOutboundPacketTooBig: WordBool read Get_AllowOutboundPacketTooBig write Set_AllowOutboundPacketTooBig;
270 | end;
271 |
272 | // *********************************************************************//
273 | // DispIntf: INetFwIcmpSettingsDisp
274 | // Flags: (4416) Dual OleAutomation Dispatchable
275 | // GUID: {A6207B2E-7CDD-426A-951E-5E1CBC5AFEAD}
276 | // *********************************************************************//
277 | INetFwIcmpSettingsDisp = dispinterface
278 | ['{A6207B2E-7CDD-426A-951E-5E1CBC5AFEAD}']
279 | property AllowOutboundDestinationUnreachable: WordBool dispid 1;
280 | property AllowRedirect: WordBool dispid 2;
281 | property AllowInboundEchoRequest: WordBool dispid 3;
282 | property AllowOutboundTimeExceeded: WordBool dispid 4;
283 | property AllowOutboundParameterProblem: WordBool dispid 5;
284 | property AllowOutboundSourceQuench: WordBool dispid 6;
285 | property AllowInboundRouterRequest: WordBool dispid 7;
286 | property AllowInboundTimestampRequest: WordBool dispid 8;
287 | property AllowInboundMaskRequest: WordBool dispid 9;
288 | property AllowOutboundPacketTooBig: WordBool dispid 10;
289 | end;
290 |
291 | // *********************************************************************//
292 | // Interface: INetFwOpenPort
293 | // Flags: (4416) Dual OleAutomation Dispatchable
294 | // GUID: {E0483BA0-47FF-4D9C-A6D6-7741D0B195F7}
295 | // *********************************************************************//
296 | INetFwOpenPort = interface(IDispatch)
297 | ['{E0483BA0-47FF-4D9C-A6D6-7741D0B195F7}']
298 | function Get_Name: WideString; safecall;
299 | procedure Set_Name(const Name: WideString); safecall;
300 | function Get_IpVersion: NET_FW_IP_VERSION_; safecall;
301 | procedure Set_IpVersion(IpVersion: NET_FW_IP_VERSION_); safecall;
302 | function Get_Protocol: NET_FW_IP_PROTOCOL_; safecall;
303 | procedure Set_Protocol(ipProtocol: NET_FW_IP_PROTOCOL_); safecall;
304 | function Get_Port: Integer; safecall;
305 | procedure Set_Port(portNumber: Integer); safecall;
306 | function Get_Scope: NET_FW_SCOPE_; safecall;
307 | procedure Set_Scope(Scope: NET_FW_SCOPE_); safecall;
308 | function Get_RemoteAddresses: WideString; safecall;
309 | procedure Set_RemoteAddresses(const remoteAddrs: WideString); safecall;
310 | function Get_Enabled: WordBool; safecall;
311 | procedure Set_Enabled(Enabled: WordBool); safecall;
312 | function Get_BuiltIn: WordBool; safecall;
313 | property Name: WideString read Get_Name write Set_Name;
314 | property IpVersion: NET_FW_IP_VERSION_ read Get_IpVersion write Set_IpVersion;
315 | property Protocol: NET_FW_IP_PROTOCOL_ read Get_Protocol write Set_Protocol;
316 | property Port: Integer read Get_Port write Set_Port;
317 | property Scope: NET_FW_SCOPE_ read Get_Scope write Set_Scope;
318 | property RemoteAddresses: WideString read Get_RemoteAddresses write Set_RemoteAddresses;
319 | property Enabled: WordBool read Get_Enabled write Set_Enabled;
320 | property BuiltIn: WordBool read Get_BuiltIn;
321 | end;
322 |
323 | // *********************************************************************//
324 | // DispIntf: INetFwOpenPortDisp
325 | // Flags: (4416) Dual OleAutomation Dispatchable
326 | // GUID: {E0483BA0-47FF-4D9C-A6D6-7741D0B195F7}
327 | // *********************************************************************//
328 | INetFwOpenPortDisp = dispinterface
329 | ['{E0483BA0-47FF-4D9C-A6D6-7741D0B195F7}']
330 | property Name: WideString dispid 1;
331 | property IpVersion: NET_FW_IP_VERSION_ dispid 2;
332 | property Protocol: NET_FW_IP_PROTOCOL_ dispid 3;
333 | property Port: Integer dispid 4;
334 | property Scope: NET_FW_SCOPE_ dispid 5;
335 | property RemoteAddresses: WideString dispid 6;
336 | property Enabled: WordBool dispid 7;
337 | property BuiltIn: WordBool readonly dispid 8;
338 | end;
339 |
340 | // *********************************************************************//
341 | // Interface: INetFwOpenPorts
342 | // Flags: (4416) Dual OleAutomation Dispatchable
343 | // GUID: {C0E9D7FA-E07E-430A-B19A-090CE82D92E2}
344 | // *********************************************************************//
345 | INetFwOpenPorts = interface(IDispatch)
346 | ['{C0E9D7FA-E07E-430A-B19A-090CE82D92E2}']
347 | function Get_Count: Integer; safecall;
348 | procedure Add(const Port: INetFwOpenPort); safecall;
349 | procedure Remove(portNumber: Integer; ipProtocol: NET_FW_IP_PROTOCOL_); safecall;
350 | function Item(portNumber: Integer; ipProtocol: NET_FW_IP_PROTOCOL_): INetFwOpenPort; safecall;
351 | function Get__NewEnum: IUnknown; safecall;
352 | property Count: Integer read Get_Count;
353 | property _NewEnum: IUnknown read Get__NewEnum;
354 | end;
355 |
356 | // *********************************************************************//
357 | // DispIntf: INetFwOpenPortsDisp
358 | // Flags: (4416) Dual OleAutomation Dispatchable
359 | // GUID: {C0E9D7FA-E07E-430A-B19A-090CE82D92E2}
360 | // *********************************************************************//
361 | INetFwOpenPortsDisp = dispinterface
362 | ['{C0E9D7FA-E07E-430A-B19A-090CE82D92E2}']
363 | property Count: Integer readonly dispid 1;
364 | procedure Add(const Port: INetFwOpenPort); dispid 2;
365 | procedure Remove(portNumber: Integer; ipProtocol: NET_FW_IP_PROTOCOL_); dispid 3;
366 | function Item(portNumber: Integer; ipProtocol: NET_FW_IP_PROTOCOL_): INetFwOpenPort; dispid 4;
367 | property _NewEnum: IUnknown readonly dispid -4;
368 | end;
369 |
370 | // *********************************************************************//
371 | // Interface: INetFwService
372 | // Flags: (4416) Dual OleAutomation Dispatchable
373 | // GUID: {79FD57C8-908E-4A36-9888-D5B3F0A444CF}
374 | // *********************************************************************//
375 | INetFwService = interface(IDispatch)
376 | ['{79FD57C8-908E-4A36-9888-D5B3F0A444CF}']
377 | function Get_Name: WideString; safecall;
378 | function Get_type_: NET_FW_SERVICE_TYPE_; safecall;
379 | function Get_Customized: WordBool; safecall;
380 | function Get_IpVersion: NET_FW_IP_VERSION_; safecall;
381 | procedure Set_IpVersion(IpVersion: NET_FW_IP_VERSION_); safecall;
382 | function Get_Scope: NET_FW_SCOPE_; safecall;
383 | procedure Set_Scope(Scope: NET_FW_SCOPE_); safecall;
384 | function Get_RemoteAddresses: WideString; safecall;
385 | procedure Set_RemoteAddresses(const remoteAddrs: WideString); safecall;
386 | function Get_Enabled: WordBool; safecall;
387 | procedure Set_Enabled(Enabled: WordBool); safecall;
388 | function Get_GloballyOpenPorts: INetFwOpenPorts; safecall;
389 | property Name: WideString read Get_Name;
390 | property type_: NET_FW_SERVICE_TYPE_ read Get_type_;
391 | property Customized: WordBool read Get_Customized;
392 | property IpVersion: NET_FW_IP_VERSION_ read Get_IpVersion write Set_IpVersion;
393 | property Scope: NET_FW_SCOPE_ read Get_Scope write Set_Scope;
394 | property RemoteAddresses: WideString read Get_RemoteAddresses write Set_RemoteAddresses;
395 | property Enabled: WordBool read Get_Enabled write Set_Enabled;
396 | property GloballyOpenPorts: INetFwOpenPorts read Get_GloballyOpenPorts;
397 | end;
398 |
399 | // *********************************************************************//
400 | // DispIntf: INetFwServiceDisp
401 | // Flags: (4416) Dual OleAutomation Dispatchable
402 | // GUID: {79FD57C8-908E-4A36-9888-D5B3F0A444CF}
403 | // *********************************************************************//
404 | INetFwServiceDisp = dispinterface
405 | ['{79FD57C8-908E-4A36-9888-D5B3F0A444CF}']
406 | property Name: WideString readonly dispid 1;
407 | property type_: NET_FW_SERVICE_TYPE_ readonly dispid 2;
408 | property Customized: WordBool readonly dispid 3;
409 | property IpVersion: NET_FW_IP_VERSION_ dispid 4;
410 | property Scope: NET_FW_SCOPE_ dispid 5;
411 | property RemoteAddresses: WideString dispid 6;
412 | property Enabled: WordBool dispid 7;
413 | property GloballyOpenPorts: INetFwOpenPorts readonly dispid 8;
414 | end;
415 |
416 | // *********************************************************************//
417 | // Interface: INetFwServices
418 | // Flags: (4416) Dual OleAutomation Dispatchable
419 | // GUID: {79649BB4-903E-421B-94C9-79848E79F6EE}
420 | // *********************************************************************//
421 | INetFwServices = interface(IDispatch)
422 | ['{79649BB4-903E-421B-94C9-79848E79F6EE}']
423 | function Get_Count: Integer; safecall;
424 | function Item(svcType: NET_FW_SERVICE_TYPE_): INetFwService; safecall;
425 | function Get__NewEnum: IUnknown; safecall;
426 | property Count: Integer read Get_Count;
427 | property _NewEnum: IUnknown read Get__NewEnum;
428 | end;
429 |
430 | // *********************************************************************//
431 | // DispIntf: INetFwServicesDisp
432 | // Flags: (4416) Dual OleAutomation Dispatchable
433 | // GUID: {79649BB4-903E-421B-94C9-79848E79F6EE}
434 | // *********************************************************************//
435 | INetFwServicesDisp = dispinterface
436 | ['{79649BB4-903E-421B-94C9-79848E79F6EE}']
437 | property Count: Integer readonly dispid 1;
438 | function Item(svcType: NET_FW_SERVICE_TYPE_): INetFwService; dispid 2;
439 | property _NewEnum: IUnknown readonly dispid -4;
440 | end;
441 |
442 | // *********************************************************************//
443 | // Interface: INetFwAuthorizedApplication
444 | // Flags: (4416) Dual OleAutomation Dispatchable
445 | // GUID: {B5E64FFA-C2C5-444E-A301-FB5E00018050}
446 | // *********************************************************************//
447 | INetFwAuthorizedApplication = interface(IDispatch)
448 | ['{B5E64FFA-C2C5-444E-A301-FB5E00018050}']
449 | function Get_Name: WideString; safecall;
450 | procedure Set_Name(const Name: WideString); safecall;
451 | function Get_ProcessImageFileName: WideString; safecall;
452 | procedure Set_ProcessImageFileName(const imageFileName: WideString); safecall;
453 | function Get_IpVersion: NET_FW_IP_VERSION_; safecall;
454 | procedure Set_IpVersion(IpVersion: NET_FW_IP_VERSION_); safecall;
455 | function Get_Scope: NET_FW_SCOPE_; safecall;
456 | procedure Set_Scope(Scope: NET_FW_SCOPE_); safecall;
457 | function Get_RemoteAddresses: WideString; safecall;
458 | procedure Set_RemoteAddresses(const remoteAddrs: WideString); safecall;
459 | function Get_Enabled: WordBool; safecall;
460 | procedure Set_Enabled(Enabled: WordBool); safecall;
461 | property Name: WideString read Get_Name write Set_Name;
462 | property ProcessImageFileName: WideString read Get_ProcessImageFileName write Set_ProcessImageFileName;
463 | property IpVersion: NET_FW_IP_VERSION_ read Get_IpVersion write Set_IpVersion;
464 | property Scope: NET_FW_SCOPE_ read Get_Scope write Set_Scope;
465 | property RemoteAddresses: WideString read Get_RemoteAddresses write Set_RemoteAddresses;
466 | property Enabled: WordBool read Get_Enabled write Set_Enabled;
467 | end;
468 |
469 | // *********************************************************************//
470 | // DispIntf: INetFwAuthorizedApplicationDisp
471 | // Flags: (4416) Dual OleAutomation Dispatchable
472 | // GUID: {B5E64FFA-C2C5-444E-A301-FB5E00018050}
473 | // *********************************************************************//
474 | INetFwAuthorizedApplicationDisp = dispinterface
475 | ['{B5E64FFA-C2C5-444E-A301-FB5E00018050}']
476 | property Name: WideString dispid 1;
477 | property ProcessImageFileName: WideString dispid 2;
478 | property IpVersion: NET_FW_IP_VERSION_ dispid 3;
479 | property Scope: NET_FW_SCOPE_ dispid 4;
480 | property RemoteAddresses: WideString dispid 5;
481 | property Enabled: WordBool dispid 6;
482 | end;
483 |
484 | // *********************************************************************//
485 | // Interface: INetFwAuthorizedApplications
486 | // Flags: (4416) Dual OleAutomation Dispatchable
487 | // GUID: {644EFD52-CCF9-486C-97A2-39F352570B30}
488 | // *********************************************************************//
489 | INetFwAuthorizedApplications = interface(IDispatch)
490 | ['{644EFD52-CCF9-486C-97A2-39F352570B30}']
491 | function Get_Count: Integer; safecall;
492 | procedure Add(const app: INetFwAuthorizedApplication); safecall;
493 | procedure Remove(const imageFileName: WideString); safecall;
494 | function Item(const imageFileName: WideString): INetFwAuthorizedApplication; safecall;
495 | function Get__NewEnum: IUnknown; safecall;
496 | property Count: Integer read Get_Count;
497 | property _NewEnum: IUnknown read Get__NewEnum;
498 | end;
499 |
500 | // *********************************************************************//
501 | // DispIntf: INetFwAuthorizedApplicationsDisp
502 | // Flags: (4416) Dual OleAutomation Dispatchable
503 | // GUID: {644EFD52-CCF9-486C-97A2-39F352570B30}
504 | // *********************************************************************//
505 | INetFwAuthorizedApplicationsDisp = dispinterface
506 | ['{644EFD52-CCF9-486C-97A2-39F352570B30}']
507 | property Count: Integer readonly dispid 1;
508 | procedure Add(const app: INetFwAuthorizedApplication); dispid 2;
509 | procedure Remove(const imageFileName: WideString); dispid 3;
510 | function Item(const imageFileName: WideString): INetFwAuthorizedApplication; dispid 4;
511 | property _NewEnum: IUnknown readonly dispid -4;
512 | end;
513 |
514 | // *********************************************************************//
515 | // Interface: INetFwServiceRestriction
516 | // Flags: (4416) Dual OleAutomation Dispatchable
517 | // GUID: {8267BBE3-F890-491C-B7B6-2DB1EF0E5D2B}
518 | // *********************************************************************//
519 | INetFwServiceRestriction = interface(IDispatch)
520 | ['{8267BBE3-F890-491C-B7B6-2DB1EF0E5D2B}']
521 | procedure RestrictService(const serviceName: WideString; const appName: WideString;
522 | RestrictService: WordBool; serviceSidRestricted: WordBool); safecall;
523 | function ServiceRestricted(const serviceName: WideString; const appName: WideString): WordBool; safecall;
524 | function Get_Rules: INetFwRules; safecall;
525 | property Rules: INetFwRules read Get_Rules;
526 | end;
527 |
528 | // *********************************************************************//
529 | // DispIntf: INetFwServiceRestrictionDisp
530 | // Flags: (4416) Dual OleAutomation Dispatchable
531 | // GUID: {8267BBE3-F890-491C-B7B6-2DB1EF0E5D2B}
532 | // *********************************************************************//
533 | INetFwServiceRestrictionDisp = dispinterface
534 | ['{8267BBE3-F890-491C-B7B6-2DB1EF0E5D2B}']
535 | procedure RestrictService(const serviceName: WideString; const appName: WideString;
536 | RestrictService: WordBool; serviceSidRestricted: WordBool); dispid 1;
537 | function ServiceRestricted(const serviceName: WideString; const appName: WideString): WordBool; dispid 2;
538 | property Rules: INetFwRules readonly dispid 3;
539 | end;
540 |
541 | // *********************************************************************//
542 | // Interface: INetFwRules
543 | // Flags: (4416) Dual OleAutomation Dispatchable
544 | // GUID: {9C4C6277-5027-441E-AFAE-CA1F542DA009}
545 | // *********************************************************************//
546 | INetFwRules = interface(IDispatch)
547 | ['{9C4C6277-5027-441E-AFAE-CA1F542DA009}']
548 | function Get_Count: Integer; safecall;
549 | procedure Add(const rule: INetFwRule); safecall;
550 | procedure Remove(const Name: WideString); safecall;
551 | function Item(const Name: WideString): INetFwRule; safecall;
552 | function Get__NewEnum: IUnknown; safecall;
553 | property Count: Integer read Get_Count;
554 | property _NewEnum: IUnknown read Get__NewEnum;
555 | end;
556 |
557 | // *********************************************************************//
558 | // DispIntf: INetFwRulesDisp
559 | // Flags: (4416) Dual OleAutomation Dispatchable
560 | // GUID: {9C4C6277-5027-441E-AFAE-CA1F542DA009}
561 | // *********************************************************************//
562 | INetFwRulesDisp = dispinterface
563 | ['{9C4C6277-5027-441E-AFAE-CA1F542DA009}']
564 | property Count: Integer readonly dispid 1;
565 | procedure Add(const rule: INetFwRule); dispid 2;
566 | procedure Remove(const Name: WideString); dispid 3;
567 | function Item(const Name: WideString): INetFwRule; dispid 4;
568 | property _NewEnum: IUnknown readonly dispid -4;
569 | end;
570 |
571 | // *********************************************************************//
572 | // Interface: INetFwRule
573 | // Flags: (4416) Dual OleAutomation Dispatchable
574 | // GUID: {AF230D27-BABA-4E42-ACED-F524F22CFCE2}
575 | // *********************************************************************//
576 | INetFwRule = interface(IDispatch)
577 | ['{AF230D27-BABA-4E42-ACED-F524F22CFCE2}']
578 | function Get_Name: WideString; safecall;
579 | procedure Set_Name(const Name: WideString); safecall;
580 | function Get_Description: WideString; safecall;
581 | procedure Set_Description(const desc: WideString); safecall;
582 | function Get_ApplicationName: WideString; safecall;
583 | procedure Set_ApplicationName(const imageFileName: WideString); safecall;
584 | function Get_serviceName: WideString; safecall;
585 | procedure Set_serviceName(const serviceName: WideString); safecall;
586 | function Get_Protocol: Integer; safecall;
587 | procedure Set_Protocol(Protocol: Integer); safecall;
588 | function Get_LocalPorts: WideString; safecall;
589 | procedure Set_LocalPorts(const portNumbers: WideString); safecall;
590 | function Get_RemotePorts: WideString; safecall;
591 | procedure Set_RemotePorts(const portNumbers: WideString); safecall;
592 | function Get_LocalAddresses: WideString; safecall;
593 | procedure Set_LocalAddresses(const localAddrs: WideString); safecall;
594 | function Get_RemoteAddresses: WideString; safecall;
595 | procedure Set_RemoteAddresses(const remoteAddrs: WideString); safecall;
596 | function Get_IcmpTypesAndCodes: WideString; safecall;
597 | procedure Set_IcmpTypesAndCodes(const IcmpTypesAndCodes: WideString); safecall;
598 | function Get_Direction: NET_FW_RULE_DIRECTION_; safecall;
599 | procedure Set_Direction(dir: NET_FW_RULE_DIRECTION_); safecall;
600 | function Get_Interfaces: OleVariant; safecall;
601 | procedure Set_Interfaces(Interfaces: OleVariant); safecall;
602 | function Get_InterfaceTypes: WideString; safecall;
603 | procedure Set_InterfaceTypes(const InterfaceTypes: WideString); safecall;
604 | function Get_Enabled: WordBool; safecall;
605 | procedure Set_Enabled(Enabled: WordBool); safecall;
606 | function Get_Grouping: WideString; safecall;
607 | procedure Set_Grouping(const context: WideString); safecall;
608 | function Get_Profiles: Integer; safecall;
609 | procedure Set_Profiles(profileTypesBitmask: Integer); safecall;
610 | function Get_EdgeTraversal: WordBool; safecall;
611 | procedure Set_EdgeTraversal(Enabled: WordBool); safecall;
612 | function Get_Action: NET_FW_ACTION_; safecall;
613 | procedure Set_Action(Action: NET_FW_ACTION_); safecall;
614 | property Name: WideString read Get_Name write Set_Name;
615 | property Description: WideString read Get_Description write Set_Description;
616 | property ApplicationName: WideString read Get_ApplicationName write Set_ApplicationName;
617 | property serviceName: WideString read Get_serviceName write Set_serviceName;
618 | property Protocol: Integer read Get_Protocol write Set_Protocol;
619 | property LocalPorts: WideString read Get_LocalPorts write Set_LocalPorts;
620 | property RemotePorts: WideString read Get_RemotePorts write Set_RemotePorts;
621 | property LocalAddresses: WideString read Get_LocalAddresses write Set_LocalAddresses;
622 | property RemoteAddresses: WideString read Get_RemoteAddresses write Set_RemoteAddresses;
623 | property IcmpTypesAndCodes: WideString read Get_IcmpTypesAndCodes write Set_IcmpTypesAndCodes;
624 | property Direction: NET_FW_RULE_DIRECTION_ read Get_Direction write Set_Direction;
625 | property Interfaces: OleVariant read Get_Interfaces write Set_Interfaces;
626 | property InterfaceTypes: WideString read Get_InterfaceTypes write Set_InterfaceTypes;
627 | property Enabled: WordBool read Get_Enabled write Set_Enabled;
628 | property Grouping: WideString read Get_Grouping write Set_Grouping;
629 | property Profiles: Integer read Get_Profiles write Set_Profiles;
630 | property EdgeTraversal: WordBool read Get_EdgeTraversal write Set_EdgeTraversal;
631 | property Action: NET_FW_ACTION_ read Get_Action write Set_Action;
632 | end;
633 |
634 | // *********************************************************************//
635 | // DispIntf: INetFwRuleDisp
636 | // Flags: (4416) Dual OleAutomation Dispatchable
637 | // GUID: {AF230D27-BABA-4E42-ACED-F524F22CFCE2}
638 | // *********************************************************************//
639 | INetFwRuleDisp = dispinterface
640 | ['{AF230D27-BABA-4E42-ACED-F524F22CFCE2}']
641 | property Name: WideString dispid 1;
642 | property Description: WideString dispid 2;
643 | property ApplicationName: WideString dispid 3;
644 | property serviceName: WideString dispid 4;
645 | property Protocol: Integer dispid 5;
646 | property LocalPorts: WideString dispid 6;
647 | property RemotePorts: WideString dispid 7;
648 | property LocalAddresses: WideString dispid 8;
649 | property RemoteAddresses: WideString dispid 9;
650 | property IcmpTypesAndCodes: WideString dispid 10;
651 | property Direction: NET_FW_RULE_DIRECTION_ dispid 11;
652 | property Interfaces: OleVariant dispid 12;
653 | property InterfaceTypes: WideString dispid 13;
654 | property Enabled: WordBool dispid 14;
655 | property Grouping: WideString dispid 15;
656 | property Profiles: Integer dispid 16;
657 | property EdgeTraversal: WordBool dispid 17;
658 | property Action: NET_FW_ACTION_ dispid 18;
659 | end;
660 |
661 | // *********************************************************************//
662 | // Interface: INetFwRule2
663 | // Flags: (4416) Dual OleAutomation Dispatchable
664 | // GUID: {9C27C8DA-189B-4DDE-89F7-8B39A316782C}
665 | // *********************************************************************//
666 | INetFwRule2 = interface(INetFwRule)
667 | ['{9C27C8DA-189B-4DDE-89F7-8B39A316782C}']
668 | function Get_EdgeTraversalOptions: Integer; safecall;
669 | procedure Set_EdgeTraversalOptions(lOptions: Integer); safecall;
670 | property EdgeTraversalOptions: Integer read Get_EdgeTraversalOptions write Set_EdgeTraversalOptions;
671 | end;
672 |
673 | // *********************************************************************//
674 | // DispIntf: INetFwRule2Disp
675 | // Flags: (4416) Dual OleAutomation Dispatchable
676 | // GUID: {9C27C8DA-189B-4DDE-89F7-8B39A316782C}
677 | // *********************************************************************//
678 | INetFwRule2Disp = dispinterface
679 | ['{9C27C8DA-189B-4DDE-89F7-8B39A316782C}']
680 | property EdgeTraversalOptions: Integer dispid 19;
681 | property Name: WideString dispid 1;
682 | property Description: WideString dispid 2;
683 | property ApplicationName: WideString dispid 3;
684 | property serviceName: WideString dispid 4;
685 | property Protocol: Integer dispid 5;
686 | property LocalPorts: WideString dispid 6;
687 | property RemotePorts: WideString dispid 7;
688 | property LocalAddresses: WideString dispid 8;
689 | property RemoteAddresses: WideString dispid 9;
690 | property IcmpTypesAndCodes: WideString dispid 10;
691 | property Direction: NET_FW_RULE_DIRECTION_ dispid 11;
692 | property Interfaces: OleVariant dispid 12;
693 | property InterfaceTypes: WideString dispid 13;
694 | property Enabled: WordBool dispid 14;
695 | property Grouping: WideString dispid 15;
696 | property Profiles: Integer dispid 16;
697 | property EdgeTraversal: WordBool dispid 17;
698 | property Action: NET_FW_ACTION_ dispid 18;
699 | end;
700 |
701 | // *********************************************************************//
702 | // Interface: INetFwProfile
703 | // Flags: (4416) Dual OleAutomation Dispatchable
704 | // GUID: {174A0DDA-E9F9-449D-993B-21AB667CA456}
705 | // *********************************************************************//
706 | INetFwProfile = interface(IDispatch)
707 | ['{174A0DDA-E9F9-449D-993B-21AB667CA456}']
708 | function Get_type_: NET_FW_PROFILE_TYPE_; safecall;
709 | function Get_FirewallEnabled: WordBool; safecall;
710 | procedure Set_FirewallEnabled(Enabled: WordBool); safecall;
711 | function Get_ExceptionsNotAllowed: WordBool; safecall;
712 | procedure Set_ExceptionsNotAllowed(notAllowed: WordBool); safecall;
713 | function Get_NotificationsDisabled: WordBool; safecall;
714 | procedure Set_NotificationsDisabled(disabled: WordBool); safecall;
715 | function Get_UnicastResponsesToMulticastBroadcastDisabled: WordBool; safecall;
716 | procedure Set_UnicastResponsesToMulticastBroadcastDisabled(disabled: WordBool); safecall;
717 | function Get_RemoteAdminSettings: INetFwRemoteAdminSettings; safecall;
718 | function Get_IcmpSettings: INetFwIcmpSettings; safecall;
719 | function Get_GloballyOpenPorts: INetFwOpenPorts; safecall;
720 | function Get_Services: INetFwServices; safecall;
721 | function Get_AuthorizedApplications: INetFwAuthorizedApplications; safecall;
722 | property type_: NET_FW_PROFILE_TYPE_ read Get_type_;
723 | property FirewallEnabled: WordBool read Get_FirewallEnabled write Set_FirewallEnabled;
724 | property ExceptionsNotAllowed: WordBool read Get_ExceptionsNotAllowed write Set_ExceptionsNotAllowed;
725 | property NotificationsDisabled: WordBool read Get_NotificationsDisabled write Set_NotificationsDisabled;
726 | property UnicastResponsesToMulticastBroadcastDisabled: WordBool read Get_UnicastResponsesToMulticastBroadcastDisabled write Set_UnicastResponsesToMulticastBroadcastDisabled;
727 | property RemoteAdminSettings: INetFwRemoteAdminSettings read Get_RemoteAdminSettings;
728 | property IcmpSettings: INetFwIcmpSettings read Get_IcmpSettings;
729 | property GloballyOpenPorts: INetFwOpenPorts read Get_GloballyOpenPorts;
730 | property Services: INetFwServices read Get_Services;
731 | property AuthorizedApplications: INetFwAuthorizedApplications read Get_AuthorizedApplications;
732 | end;
733 |
734 | // *********************************************************************//
735 | // DispIntf: INetFwProfileDisp
736 | // Flags: (4416) Dual OleAutomation Dispatchable
737 | // GUID: {174A0DDA-E9F9-449D-993B-21AB667CA456}
738 | // *********************************************************************//
739 | INetFwProfileDisp = dispinterface
740 | ['{174A0DDA-E9F9-449D-993B-21AB667CA456}']
741 | property type_: NET_FW_PROFILE_TYPE_ readonly dispid 1;
742 | property FirewallEnabled: WordBool dispid 2;
743 | property ExceptionsNotAllowed: WordBool dispid 3;
744 | property NotificationsDisabled: WordBool dispid 4;
745 | property UnicastResponsesToMulticastBroadcastDisabled: WordBool dispid 5;
746 | property RemoteAdminSettings: INetFwRemoteAdminSettings readonly dispid 6;
747 | property IcmpSettings: INetFwIcmpSettings readonly dispid 7;
748 | property GloballyOpenPorts: INetFwOpenPorts readonly dispid 8;
749 | property Services: INetFwServices readonly dispid 9;
750 | property AuthorizedApplications: INetFwAuthorizedApplications readonly dispid 10;
751 | end;
752 |
753 | // *********************************************************************//
754 | // Interface: INetFwPolicy
755 | // Flags: (4416) Dual OleAutomation Dispatchable
756 | // GUID: {D46D2478-9AC9-4008-9DC7-5563CE5536CC}
757 | // *********************************************************************//
758 | INetFwPolicy = interface(IDispatch)
759 | ['{D46D2478-9AC9-4008-9DC7-5563CE5536CC}']
760 | function Get_CurrentProfile: INetFwProfile; safecall;
761 | function GetProfileByType(profileType: NET_FW_PROFILE_TYPE_): INetFwProfile; safecall;
762 | property CurrentProfile: INetFwProfile read Get_CurrentProfile;
763 | end;
764 |
765 | // *********************************************************************//
766 | // DispIntf: INetFwPolicyDisp
767 | // Flags: (4416) Dual OleAutomation Dispatchable
768 | // GUID: {D46D2478-9AC9-4008-9DC7-5563CE5536CC}
769 | // *********************************************************************//
770 | INetFwPolicyDisp = dispinterface
771 | ['{D46D2478-9AC9-4008-9DC7-5563CE5536CC}']
772 | property CurrentProfile: INetFwProfile readonly dispid 1;
773 | function GetProfileByType(profileType: NET_FW_PROFILE_TYPE_): INetFwProfile; dispid 2;
774 | end;
775 |
776 | // *********************************************************************//
777 | // Interface: INetFwPolicy2
778 | // Flags: (4416) Dual OleAutomation Dispatchable
779 | // GUID: {98325047-C671-4174-8D81-DEFCD3F03186}
780 | // *********************************************************************//
781 | INetFwPolicy2 = interface(IDispatch)
782 | ['{98325047-C671-4174-8D81-DEFCD3F03186}']
783 | function Get_CurrentProfileTypes: Integer; safecall;
784 | function Get_FirewallEnabled(profileType: NET_FW_PROFILE_TYPE2_): WordBool; safecall;
785 | procedure Set_FirewallEnabled(profileType: NET_FW_PROFILE_TYPE2_; Enabled: WordBool); safecall;
786 | function Get_ExcludedInterfaces(profileType: NET_FW_PROFILE_TYPE2_): OleVariant; safecall;
787 | procedure Set_ExcludedInterfaces(profileType: NET_FW_PROFILE_TYPE2_; Interfaces: OleVariant); safecall;
788 | function Get_BlockAllInboundTraffic(profileType: NET_FW_PROFILE_TYPE2_): WordBool; safecall;
789 | procedure Set_BlockAllInboundTraffic(profileType: NET_FW_PROFILE_TYPE2_; Block: WordBool); safecall;
790 | function Get_NotificationsDisabled(profileType: NET_FW_PROFILE_TYPE2_): WordBool; safecall;
791 | procedure Set_NotificationsDisabled(profileType: NET_FW_PROFILE_TYPE2_; disabled: WordBool); safecall;
792 | function Get_UnicastResponsesToMulticastBroadcastDisabled(profileType: NET_FW_PROFILE_TYPE2_): WordBool; safecall;
793 | procedure Set_UnicastResponsesToMulticastBroadcastDisabled(profileType: NET_FW_PROFILE_TYPE2_;
794 | disabled: WordBool); safecall;
795 | function Get_Rules: INetFwRules; safecall;
796 | function Get_ServiceRestriction: INetFwServiceRestriction; safecall;
797 | procedure EnableRuleGroup(profileTypesBitmask: Integer; const group: WideString;
798 | enable: WordBool); safecall;
799 | function IsRuleGroupEnabled(profileTypesBitmask: Integer; const group: WideString): WordBool; safecall;
800 | procedure RestoreLocalFirewallDefaults; safecall;
801 | function Get_DefaultInboundAction(profileType: NET_FW_PROFILE_TYPE2_): NET_FW_ACTION_; safecall;
802 | procedure Set_DefaultInboundAction(profileType: NET_FW_PROFILE_TYPE2_; Action: NET_FW_ACTION_); safecall;
803 | function Get_DefaultOutboundAction(profileType: NET_FW_PROFILE_TYPE2_): NET_FW_ACTION_; safecall;
804 | procedure Set_DefaultOutboundAction(profileType: NET_FW_PROFILE_TYPE2_; Action: NET_FW_ACTION_); safecall;
805 | function Get_IsRuleGroupCurrentlyEnabled(const group: WideString): WordBool; safecall;
806 | function Get_LocalPolicyModifyState: NET_FW_MODIFY_STATE_; safecall;
807 | property CurrentProfileTypes: Integer read Get_CurrentProfileTypes;
808 | property FirewallEnabled[profileType: NET_FW_PROFILE_TYPE2_]: WordBool read Get_FirewallEnabled write Set_FirewallEnabled;
809 | property ExcludedInterfaces[profileType: NET_FW_PROFILE_TYPE2_]: OleVariant read Get_ExcludedInterfaces write Set_ExcludedInterfaces;
810 | property BlockAllInboundTraffic[profileType: NET_FW_PROFILE_TYPE2_]: WordBool read Get_BlockAllInboundTraffic write Set_BlockAllInboundTraffic;
811 | property NotificationsDisabled[profileType: NET_FW_PROFILE_TYPE2_]: WordBool read Get_NotificationsDisabled write Set_NotificationsDisabled;
812 | property UnicastResponsesToMulticastBroadcastDisabled[profileType: NET_FW_PROFILE_TYPE2_]: WordBool read Get_UnicastResponsesToMulticastBroadcastDisabled write Set_UnicastResponsesToMulticastBroadcastDisabled;
813 | property Rules: INetFwRules read Get_Rules;
814 | property ServiceRestriction: INetFwServiceRestriction read Get_ServiceRestriction;
815 | property DefaultInboundAction[profileType: NET_FW_PROFILE_TYPE2_]: NET_FW_ACTION_ read Get_DefaultInboundAction write Set_DefaultInboundAction;
816 | property DefaultOutboundAction[profileType: NET_FW_PROFILE_TYPE2_]: NET_FW_ACTION_ read Get_DefaultOutboundAction write Set_DefaultOutboundAction;
817 | property IsRuleGroupCurrentlyEnabled[const group: WideString]: WordBool read Get_IsRuleGroupCurrentlyEnabled;
818 | property LocalPolicyModifyState: NET_FW_MODIFY_STATE_ read Get_LocalPolicyModifyState;
819 | end;
820 |
821 | // *********************************************************************//
822 | // DispIntf: INetFwPolicy2Disp
823 | // Flags: (4416) Dual OleAutomation Dispatchable
824 | // GUID: {98325047-C671-4174-8D81-DEFCD3F03186}
825 | // *********************************************************************//
826 | INetFwPolicy2Disp = dispinterface
827 | ['{98325047-C671-4174-8D81-DEFCD3F03186}']
828 | property CurrentProfileTypes: Integer readonly dispid 1;
829 | property FirewallEnabled[profileType: NET_FW_PROFILE_TYPE2_]: WordBool dispid 2;
830 | property ExcludedInterfaces[profileType: NET_FW_PROFILE_TYPE2_]: OleVariant dispid 3;
831 | property BlockAllInboundTraffic[profileType: NET_FW_PROFILE_TYPE2_]: WordBool dispid 4;
832 | property NotificationsDisabled[profileType: NET_FW_PROFILE_TYPE2_]: WordBool dispid 5;
833 | property UnicastResponsesToMulticastBroadcastDisabled[profileType: NET_FW_PROFILE_TYPE2_]: WordBool dispid 6;
834 | property Rules: INetFwRules readonly dispid 7;
835 | property ServiceRestriction: INetFwServiceRestriction readonly dispid 8;
836 | procedure EnableRuleGroup(profileTypesBitmask: Integer; const group: WideString;
837 | enable: WordBool); dispid 9;
838 | function IsRuleGroupEnabled(profileTypesBitmask: Integer; const group: WideString): WordBool; dispid 10;
839 | procedure RestoreLocalFirewallDefaults; dispid 11;
840 | property DefaultInboundAction[profileType: NET_FW_PROFILE_TYPE2_]: NET_FW_ACTION_ dispid 12;
841 | property DefaultOutboundAction[profileType: NET_FW_PROFILE_TYPE2_]: NET_FW_ACTION_ dispid 13;
842 | property IsRuleGroupCurrentlyEnabled[const group: WideString]: WordBool readonly dispid 14;
843 | property LocalPolicyModifyState: NET_FW_MODIFY_STATE_ readonly dispid 15;
844 | end;
845 |
846 | // *********************************************************************//
847 | // Interface: INetFwMgr
848 | // Flags: (4416) Dual OleAutomation Dispatchable
849 | // GUID: {F7898AF5-CAC4-4632-A2EC-DA06E5111AF2}
850 | // *********************************************************************//
851 | INetFwMgr = interface(IDispatch)
852 | ['{F7898AF5-CAC4-4632-A2EC-DA06E5111AF2}']
853 | function Get_LocalPolicy: INetFwPolicy; safecall;
854 | function Get_CurrentProfileType: NET_FW_PROFILE_TYPE_; safecall;
855 | procedure RestoreDefaults; safecall;
856 | procedure IsPortAllowed(const imageFileName: WideString; IpVersion: NET_FW_IP_VERSION_;
857 | portNumber: Integer; const localAddress: WideString;
858 | ipProtocol: NET_FW_IP_PROTOCOL_; out allowed: OleVariant;
859 | out restricted: OleVariant); safecall;
860 | procedure IsIcmpTypeAllowed(IpVersion: NET_FW_IP_VERSION_; const localAddress: WideString;
861 | Type_: Byte; out allowed: OleVariant; out restricted: OleVariant); safecall;
862 | property LocalPolicy: INetFwPolicy read Get_LocalPolicy;
863 | property CurrentProfileType: NET_FW_PROFILE_TYPE_ read Get_CurrentProfileType;
864 | end;
865 |
866 | // *********************************************************************//
867 | // DispIntf: INetFwMgrDisp
868 | // Flags: (4416) Dual OleAutomation Dispatchable
869 | // GUID: {F7898AF5-CAC4-4632-A2EC-DA06E5111AF2}
870 | // *********************************************************************//
871 | INetFwMgrDisp = dispinterface
872 | ['{F7898AF5-CAC4-4632-A2EC-DA06E5111AF2}']
873 | property LocalPolicy: INetFwPolicy readonly dispid 1;
874 | property CurrentProfileType: NET_FW_PROFILE_TYPE_ readonly dispid 2;
875 | procedure RestoreDefaults; dispid 3;
876 | procedure IsPortAllowed(const imageFileName: WideString; IpVersion: NET_FW_IP_VERSION_;
877 | portNumber: Integer; const localAddress: WideString;
878 | ipProtocol: NET_FW_IP_PROTOCOL_; out allowed: OleVariant;
879 | out restricted: OleVariant); dispid 4;
880 | procedure IsIcmpTypeAllowed(IpVersion: NET_FW_IP_VERSION_; const localAddress: WideString;
881 | Type_: Byte; out allowed: OleVariant; out restricted: OleVariant); dispid 5;
882 | end;
883 |
884 | // *********************************************************************//
885 | // Interface: INetFwProduct
886 | // Flags: (4416) Dual OleAutomation Dispatchable
887 | // GUID: {71881699-18F4-458B-B892-3FFCE5E07F75}
888 | // *********************************************************************//
889 | INetFwProduct = interface(IDispatch)
890 | ['{71881699-18F4-458B-B892-3FFCE5E07F75}']
891 | function Get_RuleCategories: OleVariant; safecall;
892 | procedure Set_RuleCategories(RuleCategories: OleVariant); safecall;
893 | function Get_DisplayName: WideString; safecall;
894 | procedure Set_DisplayName(const DisplayName: WideString); safecall;
895 | function Get_PathToSignedProductExe: WideString; safecall;
896 | property RuleCategories: OleVariant read Get_RuleCategories write Set_RuleCategories;
897 | property DisplayName: WideString read Get_DisplayName write Set_DisplayName;
898 | property PathToSignedProductExe: WideString read Get_PathToSignedProductExe;
899 | end;
900 |
901 | // *********************************************************************//
902 | // DispIntf: INetFwProductDisp
903 | // Flags: (4416) Dual OleAutomation Dispatchable
904 | // GUID: {71881699-18F4-458B-B892-3FFCE5E07F75}
905 | // *********************************************************************//
906 | INetFwProductDisp = dispinterface
907 | ['{71881699-18F4-458B-B892-3FFCE5E07F75}']
908 | property RuleCategories: OleVariant dispid 1;
909 | property DisplayName: WideString dispid 2;
910 | property PathToSignedProductExe: WideString readonly dispid 3;
911 | end;
912 |
913 | // *********************************************************************//
914 | // Interface: INetFwProducts
915 | // Flags: (4416) Dual OleAutomation Dispatchable
916 | // GUID: {39EB36E0-2097-40BD-8AF2-63A13B525362}
917 | // *********************************************************************//
918 | INetFwProducts = interface(IDispatch)
919 | ['{39EB36E0-2097-40BD-8AF2-63A13B525362}']
920 | function Get_Count: Integer; safecall;
921 | function Register(const product: INetFwProduct): IUnknown; safecall;
922 | function Item(index: Integer): INetFwProduct; safecall;
923 | function Get__NewEnum: IUnknown; safecall;
924 | property Count: Integer read Get_Count;
925 | property _NewEnum: IUnknown read Get__NewEnum;
926 | end;
927 |
928 | // *********************************************************************//
929 | // DispIntf: INetFwProductsDisp
930 | // Flags: (4416) Dual OleAutomation Dispatchable
931 | // GUID: {39EB36E0-2097-40BD-8AF2-63A13B525362}
932 | // *********************************************************************//
933 | INetFwProductsDisp = dispinterface
934 | ['{39EB36E0-2097-40BD-8AF2-63A13B525362}']
935 | property Count: Integer readonly dispid 1;
936 | function Register(const product: INetFwProduct): IUnknown; dispid 2;
937 | function Item(index: Integer): INetFwProduct; dispid 3;
938 | property _NewEnum: IUnknown readonly dispid -4;
939 | end;
940 |
941 | implementation
942 |
943 | uses System.Win.ComObj;
944 |
945 | end.
946 |
--------------------------------------------------------------------------------