Luis,
Here's a copy of the help file entry:
Parameters
0
Disables support for NT Service (default).
1
Enables support for NT Service.
Return Value
Character
Remarks
This function intercepts Windows logoff messages (WM_QUERYENDSESSION and WM_ENDSESSION) to Visual FoxPro and specifies whether to keep Visual FoxPro COM Server instances running or to shut them down. A Visual FoxPro application will terminate when the current user logs off Windows. If the application is a Windows Service, then that service will terminate. Enabling support for NT service will make it possible for Visual FoxPro applications to continue even if the current user logs off Windows.
I'm sure there is a method for doing this with VFP 6.0 but I'm not sure what it would be. Perhaps someone else knows...
>What Does SYS(2340,lnNtService) do? I don't have VFP7?
>
>TIA
>
>LUIS
>
>>Luis,
>>
>>>Sorry for disturbing you but, can you be so kind as to teach how to create an NT service?
>>>
>>>TIA
>>>
>>>Luis
>>
>>No problem! I am sorry for not getting back to you sooner. I have been very busy.
>>
>>Essentially you need to create a normal FoxPro program that has the following behaviors:
>>
>>1) It must
not attempt to write anything to the screen.
>>2) It must either use a Timer event or the Windows Sleep function in a loop. I have chosen the second method.
>>3) Give yourself an easy way of stopping the service manually - My code shows a crude but effective method for this. Remember that you can manage Services through the Service panel.
>>4) Read up on SRVANY.EXE - Here's a link to one of Microaoft's support articles:
http://support.microsoft.com/support/kb/articles/q137/8/90.asp>>
>>Here is the main program I am currently working on. The comments should help explain what I am doing. My service is VERY simple. Every few seconds look on our Transaction Server for some files. If they exist get them using Web Connection's (
www.west-wind.com) pre-built functions. (They have saved me a LOT of work!)
>>
>>If I've missed anything someone will jump in and help - or if you have any more questions, please ask!
>>
>>Also, I have
not included any support functions that you will see referenced. You'll have to write your own.
>>
>>
>>*
>>** MtgSvrMain
>>*
>>** Main or 'start' program for Mortgage Server Service
>>*
>>SET TALK OFF
>>SET NOTIFY OFF
>>SET EXCLUSIVE OFF
>>
>>SET PROCEDURE TO wwapi.prg, wwutils.prg ADDITIVE
>>
>>LOCAL lnMilliseconds, lnSleepSeconds, lnNtService, loIP
>>
>>IF FILE("seconds.txt")
>> lnSleepSeconds = FILETOSTR("seconds.txt")
>>ENDIF
>>
>>IF ISDIGIT(lnSleepSeconds)
>> lnSleepSeconds = INT(VAL(lnSleepSeconds))
>>ELSE
>> STORE 15 TO lnSleepSeconds
>>ENDIF
>>
>>STORE lnSleepSeconds * 1000 TO lnMilliseconds
>>
>>*
>>** Service Support
>>*
>>STORE 0 TO lnNtService
>>=SYS(2340,lnNtService)
>>
>>SET CLASSLIB TO wwipstuff
>>*
>>** Create wwIpStuff Object
>>*
>>loIP = CREATEOBJECT("wwIpStuff")
>>
>>=WriteLog(PROGRAM(),"Starting Up")
>>
>>IF VARTYPE(loIP) == "O"
>> *
>> ** Set up Sleep Mode
>> *
>> DECLARE Sleep IN WIN32API INTEGER lnMilliseconds
>>
>> CLEAR TYPEAHEAD
>> IF LocalFileCheck()
>> IF TokenPass()
>>
>> DO WHILE .T.
>> ServerReceive(loIP)
>> ServerSend(loIP)
>>
>> =Sleep(lnMilliseconds)
>>
>> IF FILE("stop.txt") OR CHRSAW()
>> EXIT
>> ENDIF
>> ENDDO
>> ELSE
>> =WriteLog(PROGRAM(),"Token Pass Failed")
>> ENDIF
>> ENDIF
>>ENDIF
>>
>>=WriteLog(PROGRAM(),"Shutting Down")
>>
>>
Best,
DD
A man is no fool who gives up that which he cannot keep for that which he cannot lose.
Everything I don't understand must be easy!
The difficulty of any task is measured by the capacity of the agent performing the work.