为什么调用Shell_NotifyIcon函数失败

守破之间 2001-12-04 06:30:15
加精
调用
Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias " Shell_NotifyIconA" ( _
ByVal dwMessage As Long, _
lpData As NOTIFYICONDATA _
) As Long
函数时,系统提示Can't find DLLentry point Shell_NotifyIconA in shell32.dll这样的错误。我该怎样调用它才能避免发生上面的错误了?
...全文
251 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
DeityFox 2001-12-05
  • 打赏
  • 举报
回复
TO:zhang1976

哈哈哈,你是用vb的api浏览器粘铁的吧,那是在
" Shell_NotifyIconA" 的“shell前”即引号后面多了个空格,把这个空格去掉就ok了

试试?这是不是也算一个bug?
enmity 2001-12-05
  • 打赏
  • 举报
回复
to:zhang1976(惆怅死了)
已发送,请查收。
Amoon 2001-12-04
  • 打赏
  • 举报
回复
to sonicdater(发呆呆):呵呵,是啊。现在只有晚上能来啦。公司的ADSL还没弄好。
哎,我说,你怎么也学老吴他们大段大段的代码往上放啊,呵呵 :)!
sonicdater 2001-12-04
  • 打赏
  • 举报
回复
哦,对。 上次见 陈锐 在 帖上说过的。

Amoon 好久不见啦!
Amoon 2001-12-04
  • 打赏
  • 举报
回复
其实事情是这样的,Alias " Shell_NotifyIconA"
~~~这个地方多了个空格。是微软的失误啦。
hy8278 2001-12-04
  • 打赏
  • 举报
回复
我也遇到了这种情况,发现去掉前面的PUBLIC能够解决
守破之间 2001-12-04
  • 打赏
  • 举报
回复
我也是同样的代码!但是MSDN上显示错误的解释是:此DLL中包含的函数版本过时。我用的是2000
守破之间 2001-12-04
  • 打赏
  • 举报
回复
choucsl@163.com请多多关照
enmity 2001-12-04
  • 打赏
  • 举报
回复
如果有兴趣,请留下email,给你一个完整的例子,支持win2k、winxp最新特性。
sonicdater 2001-12-04
  • 打赏
  • 举报
回复
Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean

Public Const WM_LBUTTONDBLCLK = &H203
Public Const WM_RBUTTONUP = &H205
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202

Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIF_MESSAGE = &H1
Public Const NIM_DELETE = &H2
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4

Public Const WM_MOUSEMOVE = &H200

Public Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uId As Long
uFlags As Long
ucallbackMessage As Long
hIcon As Long
szTip As String * 64
End Type

Public TrayIcon As NOTIFYICONDATA

========================================================
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long

Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Const SW_RESTORE = 9

Const SW_SHOWNORMAL = 1

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_SYSCOMMAND = &H112
Private Const SC_MOVE = &HF010&
Private Const SC_RESTORE = &HF120&
Private Const SC_SIZE = &HF000&


Private Sub cmdExit_Click()

Unload Me

End Sub


Private Sub Form_Load()


'centers form
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2

'sets cbSize to the Length of TrayIcon
TrayIcon.cbSize = Len(TrayIcon)
' Handle of the window used to handle messages - which is the this form
TrayIcon.hwnd = Me.hwnd
' ID code of the icon
TrayIcon.uId = vbNull
' Flags
TrayIcon.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
' ID of the call back message
TrayIcon.ucallbackMessage = WM_MOUSEMOVE
' The icon - sets the icon that should be used
TrayIcon.hIcon = imgIcon1.Picture
' The Tooltip for the icon - sets the Tooltip that will be displayed
TrayIcon.szTip = "Mind's Tray Icon Example" & Chr$(0)

' Add icon to the tray by calling the Shell_NotifyIcon API
'NIM_ADD is a Constant - add icon to tray
Call Shell_NotifyIcon(NIM_ADD, TrayIcon)

' Don't let application appear in the Windows task list
App.TaskVisible = False
Me.Hide
End Sub


Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Static Message As Long
Static RR As Boolean

'x is the current mouse location along the x-axis
Message = X / Screen.TwipsPerPixelX

If RR = False Then
RR = True
Select Case Message
Case WM_LBUTTONUP
'Me.Visible = True

SendMessage Me.hwnd, WM_SYSCOMMAND, SC_RESTORE, 0&
ShowWindow Me.hwnd, SW_SHOWNORMAL
SetForegroundWindow Me.hwnd

' ' Left double click (This should bring up a dialog box)
' Case WM_LBUTTONDBLCLK
' 'Me.Visible = True
'
' Me.Show
'
' SetForegroundWindow Me.hwnd
' Me.SetFocus
' ' Right button up (This should bring up a menu)
Case WM_RBUTTONUP
Me.PopupMenu mnuPopUp
End Select
RR = False
End If

End Sub


Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

TrayIcon.cbSize = Len(TrayIcon)
TrayIcon.hwnd = Me.hwnd
TrayIcon.uId = vbNull
'Remove icon for Tray
Call Shell_NotifyIcon(NIM_DELETE, TrayIcon)

End Sub


Private Sub Form_Resize()

If Me.WindowState = vbMinimized Then
Me.Hide
End If

End Sub

Private Sub mnuAbout_Click()

frmAbout.Show

End Sub

Private Sub mnuChange_Click()

'checks to find what icon is currently displayed
If TrayIcon.hIcon = imgIcon1.Picture Then
'changes the icon to display
TrayIcon.hIcon = imgIcon2.Picture
'removes current icon from tray
Call Shell_NotifyIcon(NIM_DELETE, TrayIcon)
'calls the API to add in new icon
Call Shell_NotifyIcon(NIM_ADD, TrayIcon)
Else
'changes the icon to display
TrayIcon.hIcon = imgIcon1.Picture
'removes current icon from tray
Call Shell_NotifyIcon(NIM_DELETE, TrayIcon)
'calls the API to add in new icon
Call Shell_NotifyIcon(NIM_ADD, TrayIcon)
End If

End Sub


7,765

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧