Hi Anatoliy,
what does WMI stand for?
From what I gathered from the link, the code doesn't create a service. The logic I need is:
Check if service exists, if it does delete it.
Create the service and start it.
I've got pretty close, but have a slight problem with the definition of:
DECLARE INTEGER CreateService IN advapi32;
INTEGER hSCManager,;
STRING lpServiceName,;
STRING lpDisplayName,;
LONG dwDesiredAccess,;
LONG dwServiceType,;
LONG dwStartType,;
LONG dwErrorControl,;
STRING lpBinaryPathName,;
STRING lpLoadOrderGroup,;
INTEGER lpdwTagId,;
STRING lpDependencies,;
STRING lpServiceStartName,;
STRING lpPassword
m.lnService = CreateService(m.lnSCM,;
m.tcServiceName, ;
m.tcServiceName, ;
SERVICE_ALL_ACCESS, ;
SERVICE_WIN32_OWN_PROCESS, ;
SERVICE_AUTO_START,;
0,;
m.tcFileName,;
"",;
0,;
"",;
"",;
"")
I have a feeling the problem is the INTEGER lpdwTagId.
>Not exactly a sharing, but the WMI version of this code is free:
>
>
Encapsulating access to the Windows Services in a class>
http://www.news2news.com/vfp/?example=476>
>API functions used:
>CloseServiceHandle
>ControlService
>EnumServicesStatus
>GetLastError
>LocalAlloc
>LocalFree
>LockServiceDatabase
>OpenSCManager
>OpenService
>StartService
>UnlockServiceDatabase