7
7
using SharpPcap . Npcap ;
8
8
using System ;
9
9
using System . Collections . Generic ;
10
+ using System . Diagnostics ;
10
11
using System . Drawing ;
11
12
using System . Drawing . Drawing2D ;
13
+ using System . IO ;
12
14
using System . Linq ;
13
15
using System . Net ;
14
16
using System . Net . NetworkInformation ;
@@ -140,7 +142,7 @@ private void NicSelection_Load(object sender, EventArgs e)
140
142
#endregion
141
143
142
144
//Open the registry, show the License Agreement dialog if it's not accepted,
143
- //then check for the WinPcap driver and display an error dialog if it's not installed,
145
+ //then check for the Npcap driver and display an error dialog if it's not installed,
144
146
//otherwise grab the driver version and show it.
145
147
var root = Registry . CurrentUser ;
146
148
RegistryKey reg1 = root . OpenSubKey ( "Software" , true ) . CreateSubKey ( "hSmNz" ) ;
@@ -166,37 +168,45 @@ private void NicSelection_Load(object sender, EventArgs e)
166
168
167
169
#endregion
168
170
169
- #region WinPcap driver check
171
+ #region Npcap driver check
170
172
171
- RegistryKey winpcapkey = null ;
172
- if ( Environment . Is64BitOperatingSystem )
173
- {
174
- winpcapkey =
175
- Registry . LocalMachine . OpenSubKey (
176
- @"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\WinPcapInst" ) ;
177
- }
178
- else
179
- {
180
- winpcapkey =
181
- Registry . LocalMachine . OpenSubKey (
182
- @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinPcapInst" ) ;
183
- }
173
+ string ver = null ;
184
174
185
- if ( winpcapkey != null )
175
+ if ( ! Environment . Is64BitOperatingSystem )
186
176
{
187
- string ver = ( string ) winpcapkey . GetValue ( "DisplayName" ) ;
188
- if ( ! string . IsNullOrEmpty ( ver ) )
177
+ using ( RegistryKey np = Registry . LocalMachine . OpenSubKey ( @"SOFTWARE\Npcap" , false ) )
189
178
{
190
- materialLabel3 . Text = ver ;
191
- winpcapkey . Close ( ) ;
179
+ //Get Npcap installation path
180
+ var InstallationPath = np . GetValue ( string . Empty ) as string ;
181
+
182
+ if ( ! string . IsNullOrEmpty ( InstallationPath ) )
183
+ {
184
+ ver = FileVersionInfo . GetVersionInfo ( Path . Combine ( InstallationPath , "NPFInstall.exe" ) ) . FileVersion ;
185
+
186
+ materialLabel3 . Text = ver ;
187
+ }
192
188
}
193
189
}
194
190
else
195
191
{
196
- winpcapkey . Close ( ) ;
192
+ using ( RegistryKey np = Registry . LocalMachine . OpenSubKey ( @"SOFTWARE\WOW6432Node\Npcap" , false ) )
193
+ {
194
+ //Get Npcap installation path
195
+ var InstallationPath = np . GetValue ( string . Empty ) as string ;
196
+
197
+ if ( ! string . IsNullOrEmpty ( InstallationPath ) )
198
+ {
199
+ ver = FileVersionInfo . GetVersionInfo ( Path . Combine ( InstallationPath , "NPFInstall.exe" ) ) . FileVersion ;
200
+
201
+ materialLabel3 . Text = ver ;
202
+ }
203
+ }
204
+ }
197
205
198
- ErrorForm EF = new ErrorForm ( ) ;
199
- EF . ShowDialog ( ) ;
206
+ if ( string . IsNullOrEmpty ( ver ) )
207
+ {
208
+ var verError = new ErrorForm ( ) ;
209
+ verError . ShowDialog ( ) ;
200
210
}
201
211
202
212
#endregion
0 commit comments