VB.net“尝试读取或写入受保护的内存。这通常指示其他内存已损坏。” 10
小白求教、本是VB的代码、改用VS2017、总是出错、不知道出里错了OptionExplicitOnModuleModule1PublicDeclareFunctionS...
小白求教、本是VB的代码、改用VS2017、总是出错、不知道出里错了
Option Explicit On
Module Module1
Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwmainssage As Int32, lpData As NOTIFYICONDATA) As Long
Public Const MAX_TOOLTIP As Integer = 64
Public Const NIF_ICON As Integer = &H2
Public Const NIF_mainSSAGE As Integer = &H1
Public Const NIF_TIP As Integer = &H4
Public Const NIM_ADD As Integer = &H0
Public Const NIM_DELETE As Integer = &H2
Public Const WM_MOUSEMOVE As Integer = &H200
Public Const WM_LBUTTONUP As Integer = &H202
Public Const WM_RBUTTONUP As Integer = &H205
Public Const MF_bitmap As Integer = &H4&
Public Const WM_LBUTTONDBLCLK As Long = &H203
Public Const MF_bitmap As Integer = &H4&
Public Structure NOTIFYICONDATA
Dim cbSize As Long
Dim hwnd As Long
Dim uID As Icon
Dim uFlags As Long
Dim uCallbackmainssage As Long
Dim hIcon As Long
Dim szTip As String '* MAX_TOOLTIP
End Structure
Public nfIconData As NOTIFYICONDATA
Public Sub Sys_Tray()
nfIconData.hwnd = Form1.Handle
nfIconData.uID = Form1.Icon
nfIconData.uFlags = NIF_ICON Or NIF_mainSSAGE Or NIF_TIP
nfIconData.uCallbackmainssage = WM_MOUSEMOVE
nfIconData.hIcon = Form1.Icon.Handle
nfIconData.szTip = "托盘提示" & vbNullChar
nfIconData.cbSize = Len(nfIconData)
Shell_NotifyIcon(NIM_ADD, nfIconData)
End Sub
End Module 展开
Option Explicit On
Module Module1
Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwmainssage As Int32, lpData As NOTIFYICONDATA) As Long
Public Const MAX_TOOLTIP As Integer = 64
Public Const NIF_ICON As Integer = &H2
Public Const NIF_mainSSAGE As Integer = &H1
Public Const NIF_TIP As Integer = &H4
Public Const NIM_ADD As Integer = &H0
Public Const NIM_DELETE As Integer = &H2
Public Const WM_MOUSEMOVE As Integer = &H200
Public Const WM_LBUTTONUP As Integer = &H202
Public Const WM_RBUTTONUP As Integer = &H205
Public Const MF_bitmap As Integer = &H4&
Public Const WM_LBUTTONDBLCLK As Long = &H203
Public Const MF_bitmap As Integer = &H4&
Public Structure NOTIFYICONDATA
Dim cbSize As Long
Dim hwnd As Long
Dim uID As Icon
Dim uFlags As Long
Dim uCallbackmainssage As Long
Dim hIcon As Long
Dim szTip As String '* MAX_TOOLTIP
End Structure
Public nfIconData As NOTIFYICONDATA
Public Sub Sys_Tray()
nfIconData.hwnd = Form1.Handle
nfIconData.uID = Form1.Icon
nfIconData.uFlags = NIF_ICON Or NIF_mainSSAGE Or NIF_TIP
nfIconData.uCallbackmainssage = WM_MOUSEMOVE
nfIconData.hIcon = Form1.Icon.Handle
nfIconData.szTip = "托盘提示" & vbNullChar
nfIconData.cbSize = Len(nfIconData)
Shell_NotifyIcon(NIM_ADD, nfIconData)
End Sub
End Module 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询