0

I want to write a service with Delphi that processes file system events. Basically, when files and directories are created or changed, I want to push them to the cloud. I was hoping to use TSHChangeNotify (see TSHChangeNotify on StackOverflow), but it doesn't appear to work in a service; I was able to do exactly what I needed with it in a regular GUI app, but it dies in a service. I've yet to determine where it dies, but I wonder if I'm going down the best path.

So, can anyone shed light on these two (related) questions:

  1. Can TSHChangeNotify be used in a service (FYI I am using the Aldyn SvCom framework, which is how I get the component onto a form in the first place!) and if so, what are the tricky bits?

  2. Regardless of 1, what is the best way to write a service that gets notified of file system events?

Basically, I am trying to copy files and directories that are created or modified into the cloud, transparently to the user.

Thanks!

Community
  • 1
  • 1
Bob
  • 587
  • 8
  • 17
  • What account are you running the service under? And you know about services interacting (or not) with the gui? – MartynA Sep 11 '16 at 22:15
  • Looks to me like you found some code that you just copied without early trying to understand. I'd start by looking into how the underlying API works and whether you can realistically provide it with a window. – David Heffernan Sep 12 '16 at 06:21
  • I don't know if `TSHChangeNotify()` works in a service or not. But have a look at [Obtaining Directory Change Notifications](https://msdn.microsoft.com/en-us/library/windows/desktop/aa365261.aspx) on MSDN. – Remy Lebeau Sep 12 '16 at 22:00
  • MartynA, the service is currently running as SYSTEM. David, yes I don't know in detail about the API, and your comment about "provide it" skirts on what I wanted specifically want to know. Remy, interesting reference - thanks! Looks like a little more research on my part - thanks for the pointers. – Bob Sep 13 '16 at 00:42

0 Answers0