I'm making a watch folder class, but at the moment I'm unable to figure out what would cause it to give the error #1, INVALID_FUNCTION. I'm trying to make an asynchronous call by giving the CompletionRoutine, but I just don't see what I'm doing against what is said over at MSDN.
I know there are other VB6 codes that do work, but they always use events or synchronous processing, which means they're looping a tight loop with DoEvents to see if something has happened or not. This is not something I want. The callback code is tested and works with SelfTimer for an example (known as SelfCallback) - I did it like this to only have this one class and atleast some degree of IDE safety (but I'm pretty sure this is not enough).
Some test code that I have put together, which just triggers the error from the Watch function:
Code:
Option Explicit
Private WithEvents Folder As WatchFolder
Private Sub Folder_Change(ByVal Filename As String, ByVal Action As WatchFileAction)
Debug.Print Filename
End Sub
Private Sub Folder_Error(ByVal ErrorCode As Long)
Debug.Print "Error #" & Hex$(ErrorCode)
End Sub
Private Sub Form_Load()
Set Folder = New WatchFolder
Folder.Watch "C:\Documents and Settings\"
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set Folder = Nothing
End Sub