コード例 #1
0
ファイル: ServiceDataObject.cs プロジェクト: jwg4/gtools
        public bool ApplyStartupChanges(NativeSCManager scm, SC_START_TYPE startupType)
        {
            bool success = true;

            if (startupType != StartType)
            {
                Log.InfoFormat("{0}: Change SC_START_TYPE from {1} to {2}", InternalID, StartType, startupType);
                using (NativeService ns = new NativeService(scm,
                                                            InternalID,
                                                            ACCESS_MASK.SERVICE_CHANGE_CONFIG | ACCESS_MASK.SERVICE_QUERY_STATUS))
                {
                    success = NativeServiceFunctions.ChangeServiceConfig(ns.Handle,
                                                                         StartType: startupType);
                    if (success)
                    {
                        StartType = startupType;
                    }
                }
            }
            return(success);
        }
コード例 #2
0
ファイル: ServiceDataObject.cs プロジェクト: jwg4/gtools
        public void ApplyChanges(
            NativeSCManager scm,
            SC_START_TYPE startupType,
            string displayName,
            string binaryPathName,
            string description)
        {
            using (NativeService ns = new NativeService(scm,
                                                        InternalID,
                                                        ACCESS_MASK.SERVICE_CHANGE_CONFIG | ACCESS_MASK.SERVICE_QUERY_STATUS))
            {
                bool success = NativeServiceFunctions.ChangeServiceConfig(ns.Handle,
                                                                          StartType: startupType,
                                                                          DisplayName: displayName,
                                                                          BinaryPathName: binaryPathName);
                if (success)
                {
                    StartType = startupType;
                    if (displayName != null)
                    {
                        SetStringProperty("DisplayName", displayName);
                    }
                    if (binaryPathName != null)
                    {
                        SetStringProperty("BinaryPathName", binaryPathName);
                        NotifyPropertyChanged("InstallLocation");
                    }

                    if ((description != null) && !description.Equals(Description))
                    {
                        ns.Description = description;
                        SetStringProperty("Description", description);
                    }
                }
            }
        }