Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can you teach me how to create an NT service?
Message
From
15/11/2001 14:36:00
 
 
To
15/11/2001 13:49:42
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00582226
Message ID:
00582291
Views:
29
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		&& 1 = Disables Service Mode, 0 enables it
>>=SYS(2340,lnNtService)		&& VFP 7.0 function - You will need VFP 7.0 for this!
>>
>>SET CLASSLIB TO wwipstuff	&& Web Connection Internet Library.
>>*
>>** Create wwIpStuff Object
>>*
>>loIP = CREATEOBJECT("wwIpStuff")
>>
>>=WriteLog(PROGRAM(),"Starting Up")
>>
>>IF VARTYPE(loIP) == "O"
>>   *
>>   ** Set up Sleep Mode
>>   *
>>   DECLARE Sleep IN WIN32API INTEGER lnMilliseconds	&& Make Windows API Sleep function available.
>>
>>   CLEAR TYPEAHEAD
>>   IF LocalFileCheck()					&& Checks for and creates any necessary tables.
>>      IF TokenPass()						&& Process to actually exchange data with Transaction Server.
>>                                    && Validates if TS is 'live'.
>>         DO WHILE .T.
>>            ServerReceive(loIP)		&& Receive loacally any Transaction Server-based data.
>>            ServerSend(loIP)			&& Send any local data to Transaction Server.
>>
>>            =Sleep(lnMilliseconds)	&& Pause for 'n' seconds.
>>
>>            IF FILE("stop.txt") OR CHRSAW()	&& Back door way to stop service.
>>               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.
Previous
Reply
Map
View

Click here to load this message in the networking platform