Пример #1
0
        public override RuleInstanceInfo[] List()
        {
            List <RuleInstanceInfo> result = new List <RuleInstanceInfo>();

            Native.EnumWindowStationsDelegate childProc = new Native.EnumWindowStationsDelegate((windowStation, lParam) =>
            {
                GCHandle gch        = GCHandle.FromIntPtr(lParam);
                IList <string> list = gch.Target as List <string>;

                if (null == list)
                {
                    return(false);
                }

                list.Add(windowStation);

                return(true);
            });

            IList <string> workstationList = new List <string>();

            GCHandle gcHandle = GCHandle.Alloc(workstationList);

            Native.EnumWindowStations(childProc, GCHandle.ToIntPtr(gcHandle));

            foreach (string workstation in workstationList)
            {
                result.Add(new RuleInstanceInfo()
                {
                    Name = workstation
                });
            }

            return(result.ToArray());
        }
        public override CellInstanceInfo[] List()
        {
            List<CellInstanceInfo> result = new List<CellInstanceInfo>();

            Native.EnumWindowStationsDelegate childProc = new Native.EnumWindowStationsDelegate((windowStation, lParam) =>
            {
                GCHandle gch = GCHandle.FromIntPtr(lParam);
                IList<string> list = gch.Target as List<string>;

                if (null == list)
                {
                    return (false);
                }

                list.Add(windowStation);

                return (true);
            });

            IList<string> workstationList = new List<string>();

            GCHandle gcHandle = GCHandle.Alloc(workstationList);
            Native.EnumWindowStations(childProc, GCHandle.ToIntPtr(gcHandle));

            foreach (string workstation in workstationList)
            {
                result.Add(new CellInstanceInfo() { Name = workstation });
            }

            return result.ToArray();
        }
Пример #3
0
 private static bool NativeEnumWindowsStations(Native.EnumWindowStationsDelegate childProc, GCHandle gcHandle)
 {
     return(Native.EnumWindowStations(childProc, GCHandle.ToIntPtr(gcHandle)));
 }