use win32 functions - SHChangeNotify lazarus / 34-Windows ---------------------------------------------------------------------- MickeSommar · 2012-12-06 10:51 Hi I'm new to Free Pascal/Lazarus, I'm trying to execute a Win32 function. The goal is to pragmatically refresh the desktop. I have solved this in Dot.NET c#. The win32 function: SHChangeNotify (http://msdn.microsoft.com/en- us/library/windows/desktop/bb762118%28v=vs.85%29.aspx) The c# Code: Code: [Select][DllImport("shell32.dll")] public static extern void SHChangeNotify( int eventID, uint flags, IntPtr item1, IntPtr item2);     public const int SHCNE_ASSOCCHANGED = 0x8000000;   public const int SHCNF_IDLIST = 0; SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero); I have tried to find an example to reuse in the tutorial: http://www.friends-of-fpc.org/view/Win32%20API%20Introduction but with no success. Anyone here who have a small example how to use the win32 SHChangeNotify function? Best regards Micke Sommar ---------------------------------------------------------------------- marcov · 2012-12-06 22:41 Ouch, that C# looks painful. In FPC it is simpler: Code: [Select]uses shlobj; begin   SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil); end. ---------------------------------------------------------------------- MickeSommar · 2012-12-07 06:43 Hi So instead of calling the win32-api this was already implemented in FPC. Thanks for the replay, it solved my problem. But I'm still curios how it should be solved with the win32 api =) . Best regards Micke Sommar ---------------------------------------------------------------------- BigChimp · 2012-12-07 08:35 If you click on SHChangeNotify in marcov's code, type ctrl-alt-up (I think) or right click, go to declaration, you go to the declaration of the function. From this you can go to the implementation, and drill down to the implementation of the functions/procedures below it. (This probably comes as no surprise to you ) There's a fair chance that that Windows API call is in there somewhere in the Windows platform code of the LCL. Otherwise, there are some wiki articles on Windows programming tips and converting c++ code that might be useful. ---------------------------------------------------------------------- marcov · 2012-12-07 08:48 Quote from: MickeSommar on December 07, 2012, 07:43:50 amSo instead of calling the win32-api this was already implemented in FPC. This is via the Win32/64 API.  Units like Windows and shlobj are just large headers containing win32 declarations in Pascal QuoteBut I'm still curios how it should be solved with the win32 api =) . If you want to know how to declare your own win32 functions, see those units (many in fpc/rtl/win/*, nearly all in fpc/packages/winunits-base and fpc-packages/winunits-jedi). There are tens of thousands calls predefined, typically you only need to declare very new ones yourself.