Selaa lähdekoodia

日志配置和C++环境监测

tags/对接微服务前
张剑 3 vuotta sitten
vanhempi
commit
0dc0bfa8fa

+ 4
- 4
XHWK.WKTool/App.config Näytä tiedosto

@@ -5,18 +5,18 @@
5 5
   </startup>
6 6
   <appSettings>
7 7
     <!--0正式 1测试-->
8
-    <add key="IsDebug" value="1" />
8
+    <add key="IsDebug" value="0" />
9 9
     <!--参数是否加密 0不加密 1加密-->
10 10
     <add key="IsParameterEncryption" value="0" />
11 11
     <!--版本号-->
12
-    <add key="VersionCode" value="92" />
13
-    <add key="VersionName" value="3.0.0" />
12
+    <add key="VersionCode" value="97" />
13
+    <add key="VersionName" value="3.1.3" />
14 14
     <!--皮肤样式 0白 1蓝 2黑色 -->
15 15
     <add key="SkinStyle" value="0" />
16 16
     <!--是否输出视频记录日志:0否-->
17 17
     <add key="OutputVideoLog" value="0" />
18 18
     <!--是否输出其他测试日志-->
19
-    <add key="IsOutputInfoLog" value="0" />
19
+    <add key="IsOutputInfoLog" value="1" />
20 20
     <!--文件存放路径  路径\账户名\讲解名称_x.MP4-->
21 21
     <add key="VideoSavePath" value="D:\星火微课" />
22 22
     <!--视频格式 1、MP4 2、FlV 3、AVI-->

+ 11
- 6
XHWK.WKTool/App.xaml.cs Näytä tiedosto

@@ -328,6 +328,7 @@ namespace XHWK.WKTool
328 328
         public APP()
329 329
         {
330 330
             Console.WriteLine("初始化APP");
331
+            LogHelper.InitLog4Net();
331 332
             myloading = new LoadDialog();
332 333
             StopSameProcess();
333 334
             Killffmpeg();
@@ -435,8 +436,10 @@ namespace XHWK.WKTool
435 436
         /// <summary>
436 437
         /// 错误处理
437 438
         /// </summary>
438
-        /// <param name="sender"></param>
439
-        /// <param name="e"></param>
439
+        /// <param name="sender">
440
+        /// </param>
441
+        /// <param name="e">
442
+        /// </param>
440 443
         private void MyApp_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
441 444
         {
442 445
             LogHelper.WriteErrLog("未标示错误:" + e.Exception.Message, e.Exception);
@@ -504,9 +507,6 @@ namespace XHWK.WKTool
504 507
                         VideoList = new List<Model_Video>();
505 508
                         WKData.VideoList = WKData.VideoList.Where((x, i) => WKData.VideoList.FindIndex(z => z.FileGuid == x.FileGuid) == i).ToList();
506 509
                         VideoList = WKData.VideoList;
507
-                        //List<Model_Video> companyList = WKData.VideoList;
508
-                        //VideoList = companyList.Where((x, i) => companyList.FindIndex(z => z.FileGuid == x.FileGuid) == i).ToList();
509
-                        //VideoList = companyList.Distinct().ToList();
510 510
                     }
511 511
                 }
512 512
             }
@@ -557,6 +557,10 @@ namespace XHWK.WKTool
557 557
                     string PageDataXmlStr = FileToolsCommon.FileToString(SavePath);
558 558
                     PageDrawList = XmlUtilHelper.DESerializer<List<Model_DrawData>>(PageDataXmlStr);
559 559
                 }
560
+                else
561
+                {
562
+                    PageDrawList = new List<Model_DrawData>();
563
+                }
560 564
             }
561 565
             catch (Exception ex)
562 566
             {
@@ -643,7 +647,8 @@ namespace XHWK.WKTool
643 647
         /// <summary>
644 648
         /// 内存释放压缩
645 649
         /// </summary>
646
-        /// <param name="e"></param>
650
+        /// <param name="e">
651
+        /// </param>
647 652
         protected override void OnStartup(StartupEventArgs e)
648 653
         {
649 654
             new Thread(o =>

+ 101
- 78
XHWK.WKTool/CreateAMicroLessonWindow.xaml.cs Näytä tiedosto

@@ -2,6 +2,7 @@
2 2
 
3 3
 using System;
4 4
 using System.Threading;
5
+using System.Threading.Tasks;
5 6
 using System.Windows;
6 7
 using System.Windows.Forms;
7 8
 using System.Windows.Input;
@@ -17,9 +18,12 @@ namespace XHWK.WKTool
17 18
     public partial class CreateAMicroLessonWindow : Window
18 19
     {
19 20
         #region 字段
21
+
20 22
         private FolderBrowserDialog ofd;
21 23
         private DialogResult result;
22
-        #endregion
24
+
25
+        #endregion 字段
26
+
23 27
         /// <summary>
24 28
         /// 创建微课
25 29
         /// </summary>
@@ -27,7 +31,7 @@ namespace XHWK.WKTool
27 31
         {
28 32
             InitializeComponent();
29 33
             ResizeMode = ResizeMode.NoResize;
30
-       
34
+
31 35
             //if (!APP.CheckScreenCapturerRecorder())
32 36
             //{
33 37
             //    MessageWindow.Show("首次运行需安装环境,请在确定后依次点击“English-OK-Next>-Next>Install”完成安装!");
@@ -40,22 +44,26 @@ namespace XHWK.WKTool
40 44
         }
41 45
 
42 46
         #region 轮播图
47
+
43 48
         /// <summary>
44 49
         /// 图片宽度,每次切换的宽度
45 50
         /// </summary>
46
-        double ImgWidth = 502.00;
51
+        private double ImgWidth = 502.00;
52
+
47 53
         /// <summary>
48 54
         /// 轮播时移动增加的宽度
49 55
         /// </summary>
50
-        double ImgMove = 1;
56
+        private double ImgMove = 1;
57
+
51 58
         /// <summary>
52 59
         /// 当前展示的图片序号Index从0开始
53 60
         /// </summary>
54
-        int ImgNumIndex = 0;
61
+        private int ImgNumIndex = 0;
62
+
55 63
         /// <summary>
56 64
         /// 加载录播图
57 65
         /// </summary>
58
-        void LoadingCarouseImg()
66
+        private void LoadingCarouseImg()
59 67
         {
60 68
             new Thread(new ThreadStart(new Action(() =>
61 69
             {
@@ -71,14 +79,15 @@ namespace XHWK.WKTool
71 79
                 });
72 80
             }))).Start();
73 81
         }
82
+
74 83
         /// <summary>
75 84
         /// 轮播图
76 85
         /// </summary>
77
-        void CarouseImg()
86
+        private void CarouseImg()
78 87
         {
79 88
             new Thread(new ThreadStart(new Action(() =>
80 89
             {
81
-                while(true)
90
+                while (true)
82 91
                 {
83 92
                     for (double i = ImgMove; i < ImgWidth; i += ImgMove)
84 93
                     {
@@ -86,8 +95,8 @@ namespace XHWK.WKTool
86 95
                         {
87 96
                             if (Math.Abs(i + ImgMove) < ImgWidth)
88 97
                             {
89
-                            //图片移动轮播
90
-                            SplCarouse.Margin = new Thickness(SplCarouse.Margin.Left - ImgMove, 0, 0, 0);
98
+                                //图片移动轮播
99
+                                SplCarouse.Margin = new Thickness(SplCarouse.Margin.Left - ImgMove, 0, 0, 0);
91 100
                             }
92 101
                             else
93 102
                             {
@@ -120,27 +129,33 @@ namespace XHWK.WKTool
120 129
                         break;
121 130
                     }
122 131
                 }
123
-
124 132
             }))).Start();
125 133
         }
134
+
126 135
         /// <summary>
127 136
         /// 轮播图切换
128 137
         /// </summary>
129
-        /// <param name="sender"></param>
130
-        /// <param name="e"></param>
138
+        /// <param name="sender">
139
+        /// </param>
140
+        /// <param name="e">
141
+        /// </param>
131 142
         private void TimesCarouse_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
132 143
         {
133 144
             //SplCarouse
134 145
             //ImgCarouse1
135 146
         }
136
-        #endregion
147
+
148
+        #endregion 轮播图
137 149
 
138 150
         #region 事件
151
+
139 152
         /// <summary>
140 153
         /// 关闭
141 154
         /// </summary>
142
-        /// <param name="sender"></param>
143
-        /// <param name="e"></param>
155
+        /// <param name="sender">
156
+        /// </param>
157
+        /// <param name="e">
158
+        /// </param>
144 159
         private void BtnDown_Click(object sender, RoutedEventArgs e)
145 160
         {
146 161
             MessageBoxResult dr = MessageWindow.Show("确定退出系统?", "提示", MessageBoxButton.OKCancel);
@@ -153,11 +168,14 @@ namespace XHWK.WKTool
153 168
                 return;
154 169
             }
155 170
         }
171
+
156 172
         /// <summary>
157 173
         /// 浏览
158 174
         /// </summary>
159
-        /// <param name="sender"></param>
160
-        /// <param name="e"></param>
175
+        /// <param name="sender">
176
+        /// </param>
177
+        /// <param name="e">
178
+        /// </param>
161 179
         private void BtnBrowse_Click(object sender, RoutedEventArgs e)
162 180
         {
163 181
             //string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
@@ -175,15 +193,20 @@ namespace XHWK.WKTool
175 193
                 }
176 194
             }
177 195
         }
178
-        bool IsPressButton = false;
196
+
197
+        private bool IsPressButton = false;
198
+
179 199
         /// <summary>
180 200
         /// 开始
181 201
         /// </summary>
182
-        /// <param name="sender"></param>
183
-        /// <param name="e"></param>
184
-        private void BtnStart_Click(object sender, RoutedEventArgs e)
202
+        /// <param name="sender">
203
+        /// </param>
204
+        /// <param name="e">
205
+        /// </param>
206
+        private async void BtnStart_Click(object sender, RoutedEventArgs e)
185 207
         {
186 208
             #region 防止连击
209
+
187 210
             if (IsPressButton)
188 211
             {
189 212
                 return;
@@ -197,8 +220,11 @@ namespace XHWK.WKTool
197 220
                     IsPressButton = false;
198 221
                 }))).Start();
199 222
             }
200
-            #endregion
223
+
224
+            #endregion 防止连击
225
+
201 226
             #region 合法性判断
227
+
202 228
             if (string.IsNullOrWhiteSpace(txbExplainName.Text.Trim()))
203 229
             {
204 230
                 MessageWindow.Show("讲解名称不可为空!");
@@ -218,83 +244,77 @@ namespace XHWK.WKTool
218 244
                 MessageWindow.Show("路径无法访问,解决方案:\r\n1,检查路径是否可访问。\r\n2,关闭杀毒软件或信任软件。");
219 245
                 return;
220 246
             }
221
-            #endregion
247
+
248
+            #endregion 合法性判断
249
+
222 250
             LblCreate.Visibility = Visibility.Visible;
223 251
             string wkpath = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + txbExplainName.Text.Trim() + "/";
224 252
             string StoragePath = txbStoragePath.Text;
225
-            new Thread(new ThreadStart(new Action(() =>
253
+            string WkName = txbExplainName.Text;
254
+            await Task.Run(() =>
226 255
             {
227
-                //读取微课数据
228
-                APP.ReadWkData(wkpath);
229
-                if (APP.WKData == null)
256
+                try
230 257
                 {
231
-                    Dispatcher.Invoke(() =>
258
+                    //读取微课数据
259
+                    APP.ReadWkData(wkpath);
260
+                    if (APP.WKData == null)
232 261
                     {
233
-                        APP.WKData = new Model.Model_WKData
262
+                        APP.WKData = new Model_WKData
234 263
                         {
235 264
                             WkPath = wkpath,
236
-                            WkName = txbExplainName.Text,
265
+                            WkName = WkName,
237 266
                             WkCreateDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
238 267
                         };
239
-                    });
240
-                }
241
-                //创建文件夹
242
-                FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
243
-                FileToolsCommon.DeleteDirectory(wkpath + "temp");
244
-                FileToolsCommon.DeleteDirectory(wkpath + "temprs");
245
-                //存储文件
246
-                FileToolsCommon.SetConfigValue("VideoSavePath", StoragePath);
247
-                APP.ReadDrawData();
248
-                #region 微课不允许有多个视频 废弃
249
-                ////判断微课是否存在,存在则询问
250
-                //if (APP.WKDataList != null&& APP.WKDataList.Count>0)
251
-                //{
252
-                //    if (APP.WKDataList.Exists(x => x.WkName == APP.WKData.WkName))
253
-                //    {
254
-                //        MessageBoxResult dr = MessageWindow.Show("此微课已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
255
-                //        if (dr == MessageBoxResult.OK)
256
-                //        {
257
-                //            FileToolsCommon.DeleteDirectory(APP.WKData.WkPath);
258
-                //            FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
259
-                //            APP.WKDataList.RemoveAll(x => x.WkName == APP.WKData.WkName);
260
-                //        }
261
-                //        else
262
-                //        {
263
-                //            return;
264
-                //        }
265
-                //    }
266
-                //}
267
-                #endregion
268
+                    }
268 269
 
269
-                Dispatcher.Invoke(() =>
270
-                {
271
-                    if (APP.W_XHMicroLessonSystemWindow == null)
270
+                    try
272 271
                     {
273
-                        //double proportion = 1036.0 / 1276.0;
274
-                        APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
275
-                        //APP.W_XHMicroLessonSystemWindow.Width = proportion * (PrimaryScreen.ScaleScreenSize().Height-40);
276
-                        //APP.W_XHMicroLessonSystemWindow.Height =/*1276-*/ PrimaryScreen.ScaleScreenSize().Height-40;
277
-                        //APP.W_XHMicroLessonSystemWindow .Topmost = true;
272
+                        //创建文件夹
273
+                        FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
274
+                        FileToolsCommon.DeleteDirectory(wkpath + "temp");
275
+                        FileToolsCommon.DeleteDirectory(wkpath + "temprs");
278 276
                     }
279
-                    APP.W_XHMicroLessonSystemWindow.Show();
280
-                    LblCreate.Visibility = Visibility.Hidden;
281
-                    Hide();
282
-                });
283
-            }))).Start();
277
+                    catch (Exception ex)
278
+                    {
279
+                        LogHelper.WriteErrLog("【微课创建课程】文件夹创建删除失败:" + ex.Message, ex);
280
+                    }
281
+
282
+                    //存储文件
283
+                    FileToolsCommon.SetConfigValue("VideoSavePath", StoragePath);
284
+
285
+                    APP.ReadDrawData();
286
+                }
287
+                catch (Exception ex)
288
+                {
289
+                    LogHelper.WriteErrLog("【微课创建课程】读取课堂数据失败:" + ex.Message, ex);
290
+                }
291
+            });
292
+
293
+            if (APP.W_XHMicroLessonSystemWindow == null)
294
+            {
295
+                APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
296
+            }
297
+            APP.W_XHMicroLessonSystemWindow.Show();
298
+            LblCreate.Visibility = Visibility.Hidden;
299
+            Hide();
284 300
         }
285 301
 
286 302
         private double screeHeight = SystemParameters.FullPrimaryScreenHeight;
287 303
         private double screeWidth = SystemParameters.FullPrimaryScreenWidth;
304
+
288 305
         /// <summary>
289 306
         /// 窗体移动
290 307
         /// </summary>
291
-        /// <param name="sender"></param>
292
-        /// <param name="e"></param>
308
+        /// <param name="sender">
309
+        /// </param>
310
+        /// <param name="e">
311
+        /// </param>
293 312
         private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
294 313
         {
295 314
             DragMove();
296 315
         }
297
-        #endregion
316
+
317
+        #endregion 事件
298 318
 
299 319
         /// <summary>
300 320
         /// 检测APP更新
@@ -340,10 +360,12 @@ namespace XHWK.WKTool
340 360
                 }
341 361
             }).Start();
342 362
         }
363
+
343 364
         /// <summary>
344 365
         /// 应用更新
345 366
         /// </summary>
346
-        /// <param name="app"></param>
367
+        /// <param name="app">
368
+        /// </param>
347 369
         private void appUpdateShow(Model_App app)
348 370
         {
349 371
             AppUpdateWin win = new AppUpdateWin(app)
@@ -353,9 +375,10 @@ namespace XHWK.WKTool
353 375
             };
354 376
             win.Show();
355 377
         }
378
+
356 379
         private void Window_Loaded(object sender, RoutedEventArgs e)
357 380
         {
358 381
             getNewApp();
359 382
         }
360 383
     }
361
-}
384
+}

+ 2
- 5
XHWK.WKTool/LoginWindow.xaml.cs Näytä tiedosto

@@ -105,11 +105,8 @@ namespace XHWK.WKTool
105 105
         {
106 106
             string accountNumber = string.Empty;
107 107
             string password = string.Empty;
108
-            Dispatcher.Invoke(new Action(() =>
109
-            {
110
-                accountNumber = txbAccountNumber.Text.Replace(" ", "").Trim();
111
-                password = pobPassword.Password.Replace(" ", "").Trim();
112
-            }));
108
+            accountNumber = txbAccountNumber.Text.Replace(" ", "").Trim();
109
+            password = pobPassword.Password.Replace(" ", "").Trim();
113 110
 
114 111
             int code = @interface.Login(accountNumber, password);
115 112
             if (code == 0)

+ 1
- 1
XHWK.WKTool/MessageWindow.xaml Näytä tiedosto

@@ -19,7 +19,7 @@
19 19
     WindowStyle="None"
20 20
     mc:Ignorable="d">
21 21
 
22
-    <Border BorderBrush="#eeeeee" BorderThickness="1">
22
+    <Border BorderBrush="#3f6fff" BorderThickness="1">
23 23
         <Grid>
24 24
             <Grid.RowDefinitions>
25 25
                 <RowDefinition Height="42" />

+ 3
- 0
XHWK.WKTool/XHWK.WKTool.csproj Näytä tiedosto

@@ -479,6 +479,9 @@
479 479
     <EmbeddedResource Include="LatticeXML\S0_O000_B0000_P000-255.tmx">
480 480
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
481 481
     </EmbeddedResource>
482
+    <None Include="log4net.config">
483
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
484
+    </None>
482 485
     <None Include="packages.config" />
483 486
     <None Include="Properties\app.manifest" />
484 487
     <None Include="Properties\Settings.settings">

+ 52
- 0
XHWK.WKTool/log4net.config Näytä tiedosto

@@ -0,0 +1,52 @@
1
+<?xml version="1.0" encoding="utf-8" ?>
2
+<log4net>
3
+  <!--错误日志类-->
4
+  <logger name="logerror">
5
+    <!--日志类的名字-->
6
+    <level value="ALL" />
7
+    <!--定义记录的日志级别-->
8
+    <appender-ref ref="ErrorAppender" />
9
+    <!--记录到哪个介质中去-->
10
+  </logger>
11
+  <!--信息日志类-->
12
+  <logger name="loginfo">
13
+    <level value="ALL" />
14
+    <appender-ref ref="InfoAppender" />
15
+  </logger>
16
+  <!--错误日志附加介质-->
17
+  <appender name="ErrorAppender" type="log4net.Appender.RollingFileAppender">
18
+    <!-- name属性指定其名称,type则是log4net.Appender命名空间的一个类的名称,意思是,指定使用哪种介质-->
19
+    <param name="File" value="Log\\LogError\\" />
20
+    <!--日志输出到exe程序这个相对目录下-->
21
+    <param name="AppendToFile" value="true" />
22
+    <!--输出的日志不会覆盖以前的信息-->
23
+    <param name="MaxSizeRollBackups" value="100" />
24
+    <!--备份文件的个数-->
25
+    <param name="MaxFileSize" value="10240" />
26
+    <!--当个日志文件的最大大小-->
27
+    <param name="StaticLogFileName" value="false" />
28
+    <!--是否使用静态文件名-->
29
+    <param name="DatePattern" value="yyyyMMdd&quot;.htm&quot;" />
30
+    <!--日志文件名-->
31
+    <param name="RollingStyle" value="Date" />
32
+    <!--文件创建的方式,这里是以Date方式创建-->
33
+    <!--错误日志布局-->
34
+    <layout type="log4net.Layout.PatternLayout">
35
+      <param name="ConversionPattern" value="&lt;HR COLOR=red&gt;%n异常时间:%d [%t] &lt;BR&gt;%n异常级别:%-5p &lt;BR&gt;%n异 常 类:%c [%x] &lt;BR&gt;%n%m &lt;BR&gt;%n" />
36
+    </layout>
37
+  </appender>
38
+  <!--信息日志附加介质-->
39
+  <appender name="InfoAppender" type="log4net.Appender.RollingFileAppender">
40
+    <param name="File" value="Log\\LogInfo\\" />
41
+    <param name="AppendToFile" value="true" />
42
+    <param name="MaxFileSize" value="10240" />
43
+    <param name="MaxSizeRollBackups" value="100" />
44
+    <param name="StaticLogFileName" value="false" />
45
+    <param name="DatePattern" value="yyyyMMdd&quot;.htm&quot;" />
46
+    <param name="RollingStyle" value="Date" />
47
+    <!--信息日志布局-->
48
+    <layout type="log4net.Layout.PatternLayout">
49
+      <param name="ConversionPattern" value="&lt;HR COLOR=blue&gt;%n日志时间:%d [%t] &lt;BR&gt;%n日志级别:%-5p &lt;BR&gt;%n日 志 类:%c [%x] &lt;BR&gt;%n%m &lt;BR&gt;%n" />
50
+    </layout>
51
+  </appender>
52
+</log4net>

+ 13
- 2
XHWK.WKTool/system/LogHelper.cs Näytä tiedosto

@@ -1,4 +1,7 @@
1
-using System;
1
+using log4net.Config;
2
+
3
+using System;
4
+using System.IO;
2 5
 
3 6
 namespace Common.system
4 7
 {
@@ -6,6 +9,14 @@ namespace Common.system
6 9
     {
7 10
         public static readonly log4net.ILog loginfo = log4net.LogManager.GetLogger("loginfo");
8 11
         public static readonly log4net.ILog logerror = log4net.LogManager.GetLogger("logerror");
12
+
13
+        public static void InitLog4Net()
14
+        {
15
+            var logCfg = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config");
16
+            XmlConfigurator.ConfigureAndWatch(logCfg);
17
+            loginfo.Info("日志初始化");
18
+        }
19
+
9 20
         public static void WriteInfoLog(string info)
10 21
         {
11 22
             if (loginfo.IsInfoEnabled)
@@ -22,4 +33,4 @@ namespace Common.system
22 33
             }
23 34
         }
24 35
     }
25
-}
36
+}

+ 36
- 18
星火微课/星火微课-正式.iss Näytä tiedosto

@@ -3,10 +3,10 @@
3 3
 
4 4
 #define MyAppName "星火微课"  
5 5
 #define MyAppDir "xhwk"
6
-#define MyAppVersion "3.0.0"
6
+#define MyAppVersion "3.1.3"
7 7
 #define MyAppPublisher "河南星火燎原软件科技有限公司"
8 8
 #define MyAppURL "http://www.xhkjedu.com/"
9
-#define MySourcePath "D:\Project\C#\xhwkclient\XHWK.WKTool\bin\x86\Debug\"
9
+#define MySourcePath "D:\Project\CSharp\xhwkclient\XHWK.WKTool\bin\x86\Debug\"
10 10
 #define MyAppExeName "星火微课.exe"
11 11
 #define MyIcoName "256.ico"
12 12
 #define MyTargetPath "D:\程序打包\星火微课-正式\"
@@ -143,23 +143,41 @@ function InitializeSetup: Boolean;
143 143
 var Path:string;   
144 144
     ResultCode: Integer;   
145 145
 begin  
146
-  if  IsDotNetDetected('v4.5.2', 0) then  
147
-  begin  
148
-    Result := true;   
149
-  end  
150
-  else  
151
-  begin  
152
-    if MsgBox('系统检测到您没有安装.Net Framework4.5.2,是否立刻下载并安装?', mbConfirmation, MB_YESNO) = idYes then  
146
+  if IsDotNetDetected('v4.5.2', 0) then  
153 147
     begin  
154
-      Path := ExpandConstant('{pf}/Internet Explorer/iexplore.exe');   
155
-      Exec(Path, 'https://xhkjedu.oss-cn-huhehaote.aliyuncs.com/runtime/NDP452-KB2901907-x86-x64-AllOS-ENU.exe', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);   
156
-      MsgBox('请安装好.Net Framework环境后,再运行本安装包程序!',mbInformation,MB_OK);   
157
-      Result := false;   
148
+      if RegValueExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{01FAEC41-B3BC-44F4-B185-5E8475AEB855}', 'Version') then  
149
+        begin  
150
+          Result := true;   
151
+        end  
152
+      else  
153
+      begin  
154
+        if MsgBox('系统检测到您没有安装VC++环境,是否立刻下载并安装?', mbConfirmation, MB_YESNO) = idYes then  
155
+          begin  
156
+            Path := ExpandConstant('{pf}/Internet Explorer/iexplore.exe');   
157
+            Exec(Path, 'https://xhkjedu.oss-cn-huhehaote.aliyuncs.com/runtime/VC_redist.x86.exe', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);   
158
+            MsgBox('请安装好VC++环境后,再运行本安装包程序!',mbInformation,MB_OK);   
159
+            Result := false;   
160
+          end  
161
+        else  
162
+          begin  
163
+            MsgBox('取消后请手动安装VC2015-2019环境!',mbInformation,MB_OK);   
164
+            Result := true;   
165
+          end;   
166
+      end;
158 167
     end  
159
-    else  
168
+  else  
160 169
     begin  
161
-      MsgBox('没有安装.Net Framework环境,无法运行程序,本安装程序即将退出!',mbInformation,MB_OK);   
162
-      Result := false;   
163
-    end;   
164
-  end;
170
+      if MsgBox('系统检测到您没有安装.Net Framework4.5.2,是否立刻下载并安装?', mbConfirmation, MB_YESNO) = idYes then  
171
+        begin  
172
+          Path := ExpandConstant('{pf}/Internet Explorer/iexplore.exe');   
173
+          Exec(Path, 'https://xhkjedu.oss-cn-huhehaote.aliyuncs.com/runtime/NDP452-KB2901907-x86-x64-AllOS-ENU.exe', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);   
174
+          MsgBox('请安装好.Net Framework环境后,再运行本安装包程序!',mbInformation,MB_OK);   
175
+          Result := false;   
176
+        end  
177
+      else  
178
+        begin  
179
+          MsgBox('没有安装.Net Framework环境,无法运行程序,本安装程序即将退出!',mbInformation,MB_OK);   
180
+          Result := false;   
181
+        end;   
182
+    end;
165 183
 end;

+ 34
- 16
星火微课/星火微课-测试.iss Näytä tiedosto

@@ -143,23 +143,41 @@ function InitializeSetup: Boolean;
143 143
 var Path:string;   
144 144
     ResultCode: Integer;   
145 145
 begin  
146
-  if  IsDotNetDetected('v4.5.2', 0) then  
147
-  begin  
148
-    Result := true;   
149
-  end  
150
-  else  
151
-  begin  
152
-    if MsgBox('系统检测到您没有安装.Net Framework4.5.2,是否立刻下载并安装?', mbConfirmation, MB_YESNO) = idYes then  
146
+  if IsDotNetDetected('v4.5.2', 0) then  
153 147
     begin  
154
-      Path := ExpandConstant('{pf}/Internet Explorer/iexplore.exe');   
155
-      Exec(Path, 'https://xhkjedu.oss-cn-huhehaote.aliyuncs.com/runtime/NDP452-KB2901907-x86-x64-AllOS-ENU.exe', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);   
156
-      MsgBox('请安装好.Net Framework环境后,再运行本安装包程序!',mbInformation,MB_OK);   
157
-      Result := false;   
148
+      if RegValueExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{01FAEC41-B3BC-44F4-B185-5E8475AEB855}', 'Version') then  
149
+        begin  
150
+          Result := true;   
151
+        end  
152
+      else  
153
+      begin  
154
+        if MsgBox('系统检测到您没有安装VC++环境,是否立刻下载并安装?', mbConfirmation, MB_YESNO) = idYes then  
155
+          begin  
156
+            Path := ExpandConstant('{pf}/Internet Explorer/iexplore.exe');   
157
+            Exec(Path, 'https://xhkjedu.oss-cn-huhehaote.aliyuncs.com/runtime/VC_redist.x86.exe', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);   
158
+            MsgBox('请安装好VC++环境后,再运行本安装包程序!',mbInformation,MB_OK);   
159
+            Result := false;   
160
+          end  
161
+        else  
162
+          begin  
163
+            MsgBox('取消后请手动安装VC2015-2019环境!',mbInformation,MB_OK);   
164
+            Result := true;   
165
+          end;   
166
+      end;
158 167
     end  
159
-    else  
168
+  else  
160 169
     begin  
161
-      MsgBox('没有安装.Net Framework环境,无法运行程序,本安装程序即将退出!',mbInformation,MB_OK);   
162
-      Result := false;   
163
-    end;   
164
-  end;
170
+      if MsgBox('系统检测到您没有安装.Net Framework4.5.2,是否立刻下载并安装?', mbConfirmation, MB_YESNO) = idYes then  
171
+        begin  
172
+          Path := ExpandConstant('{pf}/Internet Explorer/iexplore.exe');   
173
+          Exec(Path, 'https://xhkjedu.oss-cn-huhehaote.aliyuncs.com/runtime/NDP452-KB2901907-x86-x64-AllOS-ENU.exe', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);   
174
+          MsgBox('请安装好.Net Framework环境后,再运行本安装包程序!',mbInformation,MB_OK);   
175
+          Result := false;   
176
+        end  
177
+      else  
178
+        begin  
179
+          MsgBox('没有安装.Net Framework环境,无法运行程序,本安装程序即将退出!',mbInformation,MB_OK);   
180
+          Result := false;   
181
+        end;   
182
+    end;
165 183
 end;

Loading…
Peruuta
Tallenna