02-11-2007 09:56 AM
02-12-2007 06:07 AM
02-12-2007 09:53 AM
There is an example on NI website teach you how to do this:
Creating a Windows NT Service Using LabVIEW: http://zone.ni.com/devzone/cda/tut/p/id/3185
George Zou
02-12-2007 02:40 PM
Thanks for the replies.
George, I think that link just goes back to the old srvany bodge which isn't really the solution I was after in this case.
Jon, I hadent actually got to any coding yet - still very much in the design phase.
The first api call I think should be the following:
Advapi32.dll StartServiceCtrlDispatcher(const SERVICE_TABLE_ENTRY* lpServiceTable)
http://msdn2.microsoft.com/en-us/library/ms686324.aspx
Where lpServiceTable is a pointer to an array of structures with each structure being more pointers to service main functions.
There are a few people on the web who seem to have simplified what is available on MSDN:
http://www.google.co.uk/search?hl=en&q=write+windows+service&meta=
(first link is quite good but sometimes dosent respond so try googles cache)
Thing is while I'm sure most of the problems calling these functions can be overcome either with some creative datatype use in LV or a simple wrapper dll I'm more concerned about getting 90% of the way through and finding something that just isnt possible in LV - like if the windows service manager can't call back the service by function name or something.
I'm still a little surprised there is not more demand for this. - Some of the places I have worked have security policies in place that don't allow process software to run on logged in machines, this seems more and more common actually.
Again I'm very grateful for any comments.
Pete
02-13-2007 02:07 AM - edited 02-13-2007 02:07 AM
@petere wrote:
Hi,I have been trying for a while to write some windows services using various versions of labview. In the past I have used srvany or even firedemon. This time I need to do it properly as I want to take advantage of the fact that windows will be able to act as a watchdog for my service, not to mention more graceful exit.Looking at the winapi it seems quite straight forward. Windows calls your service program main, your then have to call it back (startServiceCtrlDispacher()) with the function you want it to run as a service. Windows will then call this function etc...Immediate problem is Labview datatypes. Allot of the win32 service api functions use structures that dont seem possible to create from labview using a call library function.Before I invest allot of time on this, writing wrapper dlls etc. I really wanted to see if anone has done this before? I think there could be some show stoper alsong the way, like how will windows call back a function name, would a lv written dll be the answer or just multiple top level VIs in one exe?For me it actually seems strange that creating a service is not a built in feature of LV? Services seem the perfect answer for most process control?I really would appreciate any help or comments.Pete
Message Edited by rolfk on 02-13-2007 09:08 AM