Exemple #1
0
        internal static ServiceControlManager Connect(INativeInterop nativeInterop, string machineName, string databaseName, ServiceControlManagerAccessRights desiredAccessRights)
        {
            var mgr = nativeInterop.OpenSCManagerW(machineName, databaseName, desiredAccessRights);

            mgr.NativeInterop = nativeInterop;

            if (mgr.IsInvalid)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }

            return(mgr);
        }
 private void GivenTheServiceControlManagerCanBeOpened()
 {
     A.CallTo(() => serviceControlManager.IsInvalid).Returns(value: false);
     A.CallTo(() => nativeInterop.OpenSCManagerW(TestMachineName, TestDatabaseName, A <ServiceControlManagerAccessRights> ._))
     .Returns(serviceControlManager);
 }