Skip to content

Commit ed2d231

Browse files
committed
增加强制顶置,安装程序添加自动启动管理 - 20250227
1 parent 40fd099 commit ed2d231

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

Src/CountDownControl.suo

512 Bytes
Binary file not shown.

Src/CountDownControl/Form1.vb

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Public Class Form1
107107
Public UnSaveData As Integer '不保存设置
108108
Public UnReadData As Integer '不读取设置
109109
Public ShowModeTips As Integer '不显示横幅
110+
Public NeedStillTopMost As Integer '是否强制顶置
110111

111112
'倒计时目标时间
112113
Public SetDate As Date
@@ -368,15 +369,23 @@ Public Class Form1
368369
c = 0
369370
Me.SetTimeFormSize(aa.Height, aa.Width)
370371
End If
372+
373+
If Me.TopMost = True Then
374+
If Me.Visible = True Then
375+
If NeedStillTopMost = 1 Then
376+
SetWindowPos(Me.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS)
377+
End If
378+
End If
379+
End If
371380
End Sub
372-
'<DllImport("user32.dll")>
373-
'Private Shared Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As UInteger) As Boolean
374-
'End Function
381+
<DllImport("user32.dll")>
382+
Private Shared Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As UInteger) As Boolean
383+
End Function
375384

376-
'Const HWND_TOPMOST = -1
377-
'Const SWP_NOSIZE As UInteger = &H1
378-
'Const SWP_NOMOVE As UInteger = &H2
379-
'Const TOPMOST_FLAGS As UInteger = SWP_NOMOVE Or SWP_NOSIZE
385+
Const HWND_TOPMOST = -1
386+
Const SWP_NOSIZE As UInteger = &H1
387+
Const SWP_NOMOVE As UInteger = &H2
388+
Const TOPMOST_FLAGS As UInteger = SWP_NOMOVE Or SWP_NOSIZE
380389

381390
Public Sub SetTimeFormSize(ByVal MeH As Integer, ByVal MeW As Integer)
382391
Dim disi As Graphics = Me.CreateGraphics()
@@ -455,6 +464,7 @@ Public Class Form1
455464
Form2.Label20.Text = "部分功能由于被管理员禁用而无法使用。"
456465
End Sub
457466
Public Sub loaddef(ByVal sender As System.Object, ByVal e As System.EventArgs)
467+
NeedStillTopMost = 1
458468
'////////////////////////////////////////////////////////////////////////////////////
459469
'//
460470
'// 系统颜色读取注册表读取(UnReadData=1)
@@ -1822,10 +1832,12 @@ Public Class Form1
18221832
End Sub
18231833

18241834
Private Sub ext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ext.Click
1835+
NeedStillTopMost = 0
18251836
'If MessageBox.Show("确定要关闭时钟吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = MsgBoxResult.Yes Then
18261837
'End
18271838
'End If
18281839
Form2.ShowDialog()
1840+
NeedStillTopMost = 1
18291841
End Sub
18301842

18311843
Private Sub Me_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs) Handles Me.FormClosing

Src/CountDownControl/My Project/AssemblyInfo.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
3131
' 方法是按如下所示使用“*”:
3232
' <Assembly: AssemblyVersion("1.0.*")>
3333

34-
<Assembly: AssemblyVersion("1.0.2.25021")>
35-
<Assembly: AssemblyFileVersion("1.0.2.25021")>
34+
<Assembly: AssemblyVersion("1.0.3.25022")>
35+
<Assembly: AssemblyFileVersion("1.0.3.25022")>

Src/CountDownControl/files/1-安装.bat

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ if "%ad%" == "1" if not exist "%systemdrive%\ProgramData\Microsoft\Windows\Start
145145
if "%ad%" == "1" if exist "%systemdrive%\ProgramData\Microsoft\Windows\Start Menu\Programs\倒计时小工具\倒计时小工具.lnk" del /q "%systemdrive%\ProgramData\Microsoft\Windows\Start Menu\Programs\倒计时小工具\倒计时小工具.lnk"
146146
if "%ad%" == "1" call mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(""%systemdrive%\ProgramData\Microsoft\Windows\Start Menu\Programs\倒计时小工具\倒计时小工具.lnk""):b.TargetPath=""%programfiles%\CJH\CountDownControl\CountDownControl.exe"":b.WorkingDirectory=""%programfiles%\CJH\CountDownControl"":b.Save:close")
147147

148+
copy /y "%~dp03-自动启动管理.bat" "%programfiles%\CJH\CountDownControl\AutoBootMgr.bat"
149+
if "%ad%" == "1" if exist "%systemdrive%\ProgramData\Microsoft\Windows\Start Menu\Programs\倒计时小工具\管理自动启动.lnk" del /q "%systemdrive%\ProgramData\Microsoft\Windows\Start Menu\Programs\倒计时小工具\管理自动启动.lnk"
150+
if "%ad%" == "1" call mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(""%systemdrive%\ProgramData\Microsoft\Windows\Start Menu\Programs\倒计时小工具\管理自动启动.lnk""):b.TargetPath=""%programfiles%\CJH\CountDownControl\AutoBootMgr.bat"":b.IconLocation=""%programfiles%\CJH\CountDownControl\CountDownControl.exe"":b.WorkingDirectory=""%programfiles%\CJH\CountDownControl"":b.Save:close")
151+
148152
echo 正在安装软件根证书
149153
echo.
150154
echo 如果长时间停留在此操作,请检测是否被杀毒软件拦截。
@@ -224,6 +228,10 @@ if "%ad%" == "1" if exist "%systemdrive%\ProgramData\Microsoft\Windows\Start Men
224228
if "%ad%" == "1" call mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(""%systemdrive%\ProgramData\Microsoft\Windows\Start Menu\Programs\倒计时小工具\倒计时小工具.lnk""):b.TargetPath=""%programfiles%\CJH\CountDownControl\CountDownControl.exe"":b.WorkingDirectory=""%programfiles%\CJH\CountDownControl"":b.Save:close")
225229
if "%ad%" == "1" call mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(""%systemdrive%\ProgramData\Microsoft\Windows\Start Menu\Programs\倒计时小工具\倒计时小工具(32位).lnk""):b.TargetPath=""%programfiles%\CJH\CountDownControl\x86\CountDownControl.exe"":b.WorkingDirectory=""%programfiles%\CJH\CountDownControl\x86"":b.Save:close")
226230

231+
copy /y "%~dp03-自动启动管理.bat" "%programfiles%\CJH\CountDownControl\AutoBootMgr.bat"
232+
if "%ad%" == "1" if exist "%systemdrive%\ProgramData\Microsoft\Windows\Start Menu\Programs\倒计时小工具\管理自动启动.lnk" del /q "%systemdrive%\ProgramData\Microsoft\Windows\Start Menu\Programs\倒计时小工具\管理自动启动.lnk"
233+
if "%ad%" == "1" call mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(""%systemdrive%\ProgramData\Microsoft\Windows\Start Menu\Programs\倒计时小工具\管理自动启动.lnk""):b.TargetPath=""%programfiles%\CJH\CountDownControl\AutoBootMgr.bat"":b.IconLocation=""%programfiles%\CJH\CountDownControl\CountDownControl.exe"":b.WorkingDirectory=""%programfiles%\CJH\CountDownControl"":b.Save:close")
234+
227235
echo 正在安装软件根证书
228236
echo.
229237
echo 如果长时间停留在此操作,请检测是否被杀毒软件拦截。

0 commit comments

Comments
 (0)