﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
2925	_WinAPI_ShellChangeNotifyRegister problem	linbin		"
{{{
#include <APIShellExConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIShellEx.au3>

Opt('TrayAutoPause', 0)

Global Const $g_sPath = @ScriptDir & '\~TEST~'

DirCreate($g_sPath)
If Not FileExists($g_sPath) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create folder.')
    Exit
EndIf

OnAutoItExitRegister('OnAutoItExit')

Local $hWnd = GUICreate('')
Local $iMsg = _WinAPI_RegisterWindowMessage('SHELLCHANGENOTIFY')
GUIRegisterMsg($iMsg, 'WM_SHELLCHANGENOTIFY')
Global $g_iID = _WinAPI_ShellChangeNotifyRegister($hWnd, $iMsg, $SHCNE_ALLEVENTS, BitOR($SHCNRF_INTERRUPTLEVEL, $SHCNRF_SHELLLEVEL, $SHCNRF_RECURSIVEINTERRUPT), $g_sPath, 1)
If @error Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Window does not registered.')
    Exit
EndIf

While 1
    Sleep(1000)
WEnd

Func WM_SHELLCHANGENOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg

    Local $sPath = _WinAPI_ShellGetPathFromIDList(DllStructGetData(DllStructCreate('dword Item1; dword Item2', $wParam), 'Item1'))
    If $sPath Then
        ConsoleWrite('Event: 0x' & Hex($lParam) & ' | Path: ' & $sPath & @CRLF)
    Else
        ConsoleWrite('Event: 0x' & Hex($lParam) & @CRLF)
    EndIf
EndFunc   ;==>WM_SHELLCHANGENOTIFY

Func OnAutoItExit()
    If $g_iID Then
        _WinAPI_ShellChangeNotifyDeregister($g_iID)
    EndIf
    DirRemove($g_sPath)
EndFunc   ;==>OnAutoItExit
}}}
It's the Example script from Help file,and it's not working very well on WinXP.

'''1.Win7'''
run the script on Win7 and download a file(QQ6.4.exe) via Firefox.
console output:
>""C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe"" /ErrorStdOut ""D:\1.au3""   
Event: 0x00000008 | Path: D:\~TEST~
Event: 0x00040000
Event: 0x00000004 | Path: D:\~TEST~\QQ6.4.exe
Event: 0x00000002 | Path: D:\~TEST~\QQ6.4.exe
Event: 0x00000002 | Path: D:\~TEST~\QQ6.4.exe.part
Event: 0x00002000 | Path: D:\~TEST~\QQ6.4.exe.part
Event: 0x00002000 | Path: D:\~TEST~
Event: 0x00002000 | Path: D:\~TEST~\QQ6.4.exe.part
Event: 0x00000004 | Path: D:\~TEST~\QQ6.4.exe
Event: 0x00000001 | Path: D:\~TEST~\QQ6.4.exe.part
Event: 0x00002000 | Path: D:\~TEST~\QQ6.4.exe
Event: 0x00002000 | Path: D:\~TEST~

'''2.WinXP'''
run it again on WinXP and download the same file via Firefox
console output:
>Running:(3.3.12.0):D:\Program Files\AutoIt3\autoit3.exe ""D:\1.au3""    
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
Event: 0x00001000 | Path: D:\~TEST~
Event: 0x00001000 | Path: D:\~TEST~

It seems the function cannot detect temp file on WinXP?"	Bug	closed		AutoIt	3.3.12.0	None	Wont Fix	_WinAPI_ShellChangeNotifyRegister	
