Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Memory Resident Program

Status
Not open for further replies.

budman48

MIS
Dec 20, 2002
23
0
0
US
I need to write a program that is memory resident that keeps checking a specific folder. If at any point during the day a file comes into this folder, I need to rename this file and move it to a different folder. Once it it moved the folder is empty but the program got to still check that folder. The program got to be running all the time.
 
Your description "Memory Resident" gives away that you've used computers for a while!

Since Windows really is multi-tasking now, "Memory Resident" programs are no longer necessary... regular applications can run in the background and do the work that you describe.

So, In VFP, you can simply add this loop in your program:
Code:
PUBLIC glFinished
glFinished = .F.
DECLARE Sleep IN Win32Api AS apiSleep LONG dwMilliseconds
do while not glFinished
  apiSleep( 1000 )  
  if file( 'c:\my path\my file.txt')
    DO WhateverIsNeeded
  endif
enddo

Include a menu item that sets glFinished to .T. when the user wants to terminate the process.

If you want to show an icon in the system tray (in the lower right of the screen, on the "start bar") use the suggestions in this MS article:
You could then make your main window invisible (and not show in the task list or on the Start bar): _SCREEN.Visible = .F.

And you could display a menu to control your program in reaction to the Right-Click event of the system tray icon.

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Another option is to set up a timer object and have it check every so often for the file.

Tamar
 
Why Tamar's suggestion of the timer didn't cross my mind, I don't know... The Timer is a much cleaner way to to implement the continuous checks.

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top