Triggering an Event that runs a program

Posted on 2002-05-13
Last Modified: 2010-05-02
We have a program running on an old UNIX box, written in Tickle, that FTPs files to a NT directory. Another program (VB) picks up the files, converts their format, moves them to another directory,etc...

Rather than have a service that runs every few minutes,  I would like to have the VB program waiting, idly, for a message from the sending program, who will then do the converts, etc..

The data is ultimately stored in a SQL_Database. The originating program could (maybe) write to a field in the SQL database that would trigger the event. The VB program could be coded and set up on NT to wait for a specific instruction from the Tickle program. Of course it will have to cross platforms from old UNIX to NT.

Any help is appreciated.

Question by:johnstde
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 7007352
a) Use your file system
b) Use a Win32 Message / DDE

a) Just let the Tickle program create a file. The VB app will watch for this file in a loop. If it's created, VB will start processing. After doing all tasks, it will delete the file and the tickle program then knows, it can continue to work.

b) Let the tickle program, when ported to win32, send a message to your vb app which, in a subclassed routine, can pickup the message and start a working task. You could use DDE for this either.
LVL 43

Accepted Solution

TimCottee earned 300 total points
ID: 7008284
hakre, you are new to this site so may not be aware of the guidelines. Please re-read these at the bottom of this page. Your "answer" which does not 100% solve this problem should have been posted as a comment as it now places this question in the "locked" section which will not allow it the attention it deserves. If you continue to post answers inappropriately your account may be referred to customer services for possibly penalty.

johnstde: I would suggest that you reject this proposed answer at this time to allow more experts the opportunity to comment. If you feel that hakre in the end has offered the best solution you may choose the accept comment as answer button to award him/her the points at any time after you have rejected this proposed answer.

Anyway hakre is probably on the right lines. Basically I would use the file system to handle this with a few api calls. Add in a touch of an NT service (NTSRV.OCX) get it here:

You should also use code such as this:

Private Const FILE_NOTIFY_CHANGE_ALL = &H4 Or &H2 Or &H1 Or &H8 Or &H10 Or &H100
Private Declare Function FindFirstChangeNotification Lib "kernel32" Alias "FindFirstChangeNotificationA" (ByVal lpPathName As String, ByVal bWatchSubtree As Long, ByVal dwNotifyFilter As Long) As Long
Private Declare Function FindCloseChangeNotification Lib "kernel32" (ByVal hChangeHandle As Long) As Long
Private Declare Function FindNextChangeNotification Lib "kernel32" (ByVal hChangeHandle As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function ResetEvent Lib "kernel32" (ByVal hEvent As Long) As Long
Private Sub Form_Load()
    'KPD-Team 2000
    Dim Ret As Long
    'Set the notification hook
    Ret = FindFirstChangeNotification("C:\", &HFFFFFFFF, FILE_NOTIFY_CHANGE_ALL)
    'Wait until the event is triggered
    WaitForSingleObject Ret, &HFFFFFFFF
    MsgBox "Event Triggered for the first time"
    'Reactivate our hook
    FindNextChangeNotification Ret
    'Wait until the event is triggered
    WaitForSingleObject Ret, &HFFFFFFFF
    MsgBox "Event Triggered for the second time"
    'Remove our hook
    FindCloseChangeNotification Ret
End Sub

To watch a specified folder (your ftp target folder) for new files being added. You can then run your conversion and output code and VB will then sit idle as a service until the next notification.

Author Comment

ID: 7008656
Following above suggestion, I am rejecting the answer for now so I can spend some time looking at the options offered. Good ideas guys! Thanks for the link and details Tim.

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 7008945
I've worked with something like this in the past, and both Harke and TimCottee have the right idea.  One possible option/enhancement would be to have another 'listener' process sit in front of your main VB program (the one that 'picks up the files, converts their format, moves them to another directory,etc...').

This helps mainly if your main VB app is rather large and you don't want to have it constantly residing in memory.  Your 'listener' would instantiate the main program any time it received data or saw that the file was out there, and pass the data along.

Good luck

LVL 16

Expert Comment

ID: 7009728
LVL 43

Expert Comment

ID: 7010486
True kcleary but of course this could be the service process and you could either use an activex dll/exe or just shell out to a standard exe for the conversion process when necessary.

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question