Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

My old VB6 code for changing icons does not seem to work with out modifications. Now I'm stuck with the SHChangeNotify. Does any one know how to get this API work in VB 2005 Express?

 

 

'Declarations
Private Declare Function SHChangeNotify Lib "Shell32.dll" (ByVal wEventID As Long, ByVal uFlags As Long, ByVal dwItem1 As Long, ByVal dwItem2 As Long) As Long
'Private Declare Sub SHChangeNotify Lib "shell32.dll" (ByVal wEventId As Long, ByVal uFlags As Long, ByVal dwItem1 As Object, ByVal dwItem2 As Object)
Const SHCNE_ASSOCCHANGED = &H8000000
Const SHCNF_IDLIST = &H0


'In a sub
'Notify shell icon has changed
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, vbNullString, vbNullString)

 

Oh and here's the error I'm getting:

A call to PInvoke function 'JaMP!JaMP.FormAssociations::SHChangeNotify' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

Edited by JumpyNET
Posted

Longs, Integers, and IntPtrs

 

You should be using the Sub version rather than the Function version of SHChangeNotify since the function does not return a value. However, the parameters you are using are incorrect. Long in VB6 is Integer in VB.Net:

 

'Declarations
Private Declare Sub SHChangeNotify Lib "shell32.dll" ( _
   ByVal wEventId As Integer, _
   ByVal uFlags As Integer, _
   ByVal dwItem1 As IntPtr, _
   ByVal dwItem2 As IntPtr _
)
Const SHCNE_ASSOCCHANGED = &H8000000
Const SHCNF_IDLIST = &H0


'In a sub
'Notify shell icon has changed
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero)

 

Good luck :cool:

Never trouble another for what you can do for yourself.
  • Leaders
Posted

Just so you know, VB6 longs can translate not only into Integer, but also IntPtr and possibly a couple other uncommon types.

 

You might want to download API Viewer. It doesn't make use of the IntPtr type, which is the correct type for hWnds and other handle types, but for the most part it is very handy.

[sIGPIC]e[/sIGPIC]
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...