如果用vb.net程序打開可以用如下代碼:
創(chuàng)新互聯(lián)專注于納雍網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供納雍營(yíng)銷型網(wǎng)站建設(shè),納雍網(wǎng)站制作、納雍網(wǎng)頁設(shè)計(jì)、納雍網(wǎng)站官網(wǎng)定制、重慶小程序開發(fā)服務(wù),打造納雍網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供納雍網(wǎng)站排名全網(wǎng)營(yíng)銷落地服務(wù)。
Shell("C:\文件",?AppWinStyle.Hide)'打開C:\文件,并在其打開時(shí)將其隱藏
如不懂可以追問
望采納
添加托盤圖標(biāo)控件,并設(shè)置好其Icon屬性,然后添加如下代碼:
Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
e.Cancel = True
Me.Hide()
End Sub
這樣實(shí)現(xiàn)了點(diǎn)關(guān)閉,進(jìn)入托盤,如果點(diǎn)最小化進(jìn)入托盤:
'窗體最小化時(shí)候隱藏窗體,
Private Sub MainForm_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
If Me.WindowState = FormWindowState.Minimized Then
Me.Hide()
Me.ShowInTaskbar = False
End If
End Sub
首先添加一個(gè)模塊,寫入代碼,代碼我已經(jīng)準(zhǔn)備好了
然再給Form窗體添加代碼
模塊
Option Explicit
Public Const MAX_TOOLTIP As Integer = 64
Public Const NIF_ICON = H2
Public Const NIF_MESSAGE = H1
Public Const NIF_TIP = H4
Public Const NIM_ADD = H0
Public Const NIM_DELETE = H2
Public Const WM_MOUSEMOVE = H200
Public Const WM_LBUTTONDOWN = H201
Public Const WM_LBUTTONUP = H202
Public Const WM_LBUTTONDBLCLK = H203
Public Const WM_RBUTTONDOWN = H204
Public Const WM_RBUTTONUP = H205
Public Const WM_RBUTTONDBLCLK = H206
Public Const SW_RESTORE = 9
Public Const SW_HIDE = 0
Public nfIconData As NOTIFYICONDATA
Public Type NOTIFYICONDATA
cbSize As Long
hWnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip As String * MAX_TOOLTIP
End Type
Public Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
From窗體Private Sub Command1_Click()
With nfIconData
.hWnd = Me.hWnd
.uID = Me.Icon
.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
.uCallbackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon.Handle
.szTip = App.Title + "(版本 " App.Major "." App.Minor "." App.Revision ")" vbNullChar
.cbSize = Len(nfIconData)
End With
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
Me.Hide
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lMsg As Single
lMsg = X / Screen.TwipsPerPixelX
Select Case lMsg
Case WM_LBUTTONUP
ShowWindow Me.hWnd, SW_RESTORE
End Select
End Sub
添加托盤圖標(biāo)控件,并設(shè)置好其Icon屬性,然后添加如下代碼:
Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
e.Cancel = True
Me.Hide()
End Sub