Solved

Triggering an Event that runs a program

Posted on 2002-05-13
6
183 Views
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.
DJ

0
Comment
Question by:johnstde
6 Comments
 

Expert Comment

by:hakre
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.
0
 
LVL 43

Accepted Solution

by:
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: http://support.microsoft.com/default.aspx?scid=http://msdn.microsoft.com/library/techart/msdn_ntsrvocx.htm

You should also use code such as this:

Private Const FILE_NOTIFY_CHANGE_ATTRIBUTES = &H4
Private Const FILE_NOTIFY_CHANGE_DIR_NAME = &H2
Private Const FILE_NOTIFY_CHANGE_FILE_NAME = &H1
Private Const FILE_NOTIFY_CHANGE_SIZE = &H8
Private Const FILE_NOTIFY_CHANGE_LAST_WRITE = &H10
Private Const FILE_NOTIFY_CHANGE_SECURITY = &H100
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
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    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.
0
 

Author Comment

by:johnstde
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.

Dj
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Expert Comment

by:kcleary
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

kcleary
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7009728
Hearing...
0
 
LVL 43

Expert Comment

by:TimCottee
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to open Waze.com/livemap from address saved in DB? 26 177
MS Access Search and Replace Using VBA 6 57
Best way to parse out a json string in VB6? 10 115
Spell Check in VB6 13 99
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

895 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now