JumpyNET Posted December 21, 2006 Posted December 21, 2006 (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 December 21, 2006 by JumpyNET Quote
MrPaul Posted December 21, 2006 Posted December 21, 2006 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: Quote Never trouble another for what you can do for yourself.
Leaders snarfblam Posted December 21, 2006 Leaders Posted December 21, 2006 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. Quote [sIGPIC]e[/sIGPIC]
Administrators PlausiblyDamp Posted December 21, 2006 Administrators Posted December 21, 2006 http://www.pinvoke.net/default.aspx/shell32/SHChangeNotify.html might be worth a look. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
JumpyNET Posted December 23, 2006 Author Posted December 23, 2006 It works! http://www.pinvoke.net/default.aspx/shell32/SHChangeNotify.html might be worth a look. Thanks I got it working now. I can recommend this link that PlausiblyDamp gave for everyone since it has also the enums for the parameters. Quote
Recommended Posts