Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Global events in VO 2.5

16 views
Skip to first unread message

Tom Walden

unread,
May 8, 2006, 9:14:39 AM5/8/06
to
In VO 2.5 (for now), I need an event handler that can monitor a given folder
location, and if a file gets dropped into that folder, then I need to
trigger and event method. Has anybody done that and can share a code
snippet on how it's done?

Thanks,
Tom Walden < if replying privately, be sure to remove NO SPAM from my email
address >


Carlos Vazquez

unread,
May 8, 2006, 10:30:37 AM5/8/06
to
Tom,

I use ShellWindow:Timer() for such situations and it works great.

HTH

Tom Walden wrote:


--
Carlos Vazquez
c...@NOSPAMtelefonica.net

Steph

unread,
May 8, 2006, 11:52:10 AM5/8/06
to
Tom,

You might want to look at SHChangeNotifyRegister

http://msdn.microsoft.com/library/?url=/library/en-us/shellcc/platform/shell/reference/functions/shchangenotify.asp

I'm pretty sure there are other Win32 APIs out there to do this.

Steph


"Tom Walden" <twald...@SPAMcfl.rr.com> wrote in message
news:3vH7g.2050$LE4...@tornado.tampabay.rr.com...

Amilcar A. Camargo

unread,
May 8, 2006, 4:46:08 PM5/8/06
to
Hi Tom,

On Mon, 08 May 2006 13:14:39 GMT, "Tom Walden"
<twald...@SPAMcfl.rr.com> wrote:

>In VO 2.5 (for now), I need an event handler that can monitor a given folder
>location, and if a file gets dropped into that folder, then I need to
>trigger and event method. Has anybody done that and can share a code
>snippet on how it's done?

Well, haven't done it yet. It's on my 'to-do' list with a high
priority. That said, have a look at "Obtaining Directory Change
Notifications" in the Plataform SDK, more specifically you can read
info on 'FindFirstChangeNotification()',
'FindNextChangeNotification()', 'FindCloseChangeNotification()',
'WaitForSingleObject()' and the related topics.

This functions will need you to program a 'waiting' thread. The thread
will 'wait' for any change to occur and signal your main App, usually
with a PostMessage(..) to your shell window that something is
happening.

Other way around: use a timer and inspect your directory every time it
fires.

HTH,
Amilcar A. Camargo F.
Sand, S. A.
Guatemala, C. A.

(pls remove _no_ to e-mail)

Phil McGuinness

unread,
May 8, 2006, 6:29:33 PM5/8/06
to
Tom,

What I do is have a timer and in the Dispatch() method I react to the Timer
and then call a Directory() function to look for the files types I want and
get an array of files. Remember that before you take work on the file you
should try and get and EXCLUSIVE lock on the file(s) to check they are is
still not being written like an FTP upload as an example.

We have for about 6 years now allowed upload of files / images in a
'package' and every 10 seconds we establish the completed files are there
and we move them up a level in the directory structure to stop somebody
downloading the same files.

We then decrypt the data and build information from it.. like other image
sizes, turn data into other XML formats and then re FTP to multiple
locations.

Hope this helps.

Phil McGuinness
-----------

"Tom Walden" <twald...@SPAMcfl.rr.com> wrote in message
news:3vH7g.2050$LE4...@tornado.tampabay.rr.com...

Tom Walden

unread,
May 8, 2006, 7:57:25 PM5/8/06
to
Thanks for all the tips guys. I've certainly got many options to play with
now...

Tom


gstark

unread,
May 8, 2006, 8:32:56 PM5/8/06
to
Tom,


== Quote from Tom Walden (twald...@SPAMcfl.rr.com)'s article


> In VO 2.5 (for now), I need an event handler that can monitor a given folder
> location, and if a file gets dropped into that folder, then I need to
> trigger and event method. Has anybody done that and can share a code
> snippet on how it's done?

About four years ago I wrote exactly such an application, and I had it setup as a
service running under NT. Let me see if I can find the code for that if you're
interested.


--
g.
Gary Stark
gst...@RedbacksWeb.com
http:\\www.RedbacksWeb.com

Conrad Breuer

unread,
May 9, 2006, 1:54:42 AM5/9/06
to
Hello Tom,

look in the Mainmenu of VO "New Application--> Samples--> NT-Service" .

HTH
Conrad


"gstark" <gst...@RedbacksWeb.com> schrieb im Newsbeitrag
news:445fe338$0$25245$61c6...@un-2park-reader-01.sydney.pipenetworks.com.au...

Gerd Hoernemann

unread,
May 9, 2006, 8:29:37 AM5/9/06
to
Tom Walden schrieb:

> In VO 2.5 (for now), I need an event handler that can monitor a given folder
> location, and if a file gets dropped into that folder, then I need to
> trigger and event method. Has anybody done that and can share a code
> snippet on how it's done?
>
Tom,

I found the following sample, I think it's based on the work of Uwe Heyer.

HTH
Gerd


FUNCTION MyFunc( cDir AS STRING ) AS VOID PASCAL
LOCAL pThread AS PTR
LOCAL dwID AS DWORD
LOCAL dwExitCode AS DWORD
LOCAL pszDir AS PSZ

pszDir := StringAlloc( cDir )

hEvent[1] := CreateEvent( NULL, TRUE, FALSE, NULL )

hEvent[2] := FindFirstChangeNotification( pszDir, FALSE,;
FILE_NOTIFY_CHANGE_FILE_NAME )

pThread := CreateVOThread( NULL_PTR, 0, @_Worker(), NULL_PTR,;
0, dwID )

GetExitCodeThread( pThread, @dwExitCode )

// the function will run until you raise hEvent[1]:
TextBox{, " MyFunc ", "Cancel" }:show()
SetEvent( hEvent[1] ) // Cancel
WaitForSingleObject( pThread, INFINITE )

CloseHandle( pThread )
CloseHandle( hEvent[1] )
FindCloseChangeNotification( hEvent[2] )

MemFree( pszDir )
RETURN


FUNCTION _Worker AS VOID PASCAL
LOCAL dwState AS DWORD

WHILE TRUE

dwState := WaitForMultipleObjects( 2, @hEvent, FALSE, INFINITE )

// hEvent[1] is used to signal a cancel ( with SetEvent...)
// hEvent[2] is the pointer to FindFirstChangeNotification

IF dwState == WAIT_OBJECT_0+1 // hEvent[2] has raised
// Do something ...
TextBox{ , "_Worker ", ;
" A change in the Directory has occured " }:show()

FindNextChangeNotification( hEvent[2] ) // go on
ENDIF

IF dwState == WAIT_OBJECT_0 // Cancel

EXIT
ENDIF

ENDDO

ExitVOThread( 0 )

STATIC GLOBAL DIM hEvent[2] AS PTR

0 new messages