How get list of local network computers?

前端 未结 6 454
甜味超标
甜味超标 2020-12-01 04:47

I am trying to get a list of local network computers. I tried to use NetServerEnum and WNetOpenEnum API, but both API return error code 6118

6条回答
  •  遥遥无期
    2020-12-01 05:28

    I made a function out of it. The SchemaClassName has to be Computer

        public List NetworkComputers()
        {
            return (
            from Computers 
            in (new DirectoryEntry("WinNT:")).Children
            from Computer 
            in Computers.Children
            where Computer.SchemaClassName == "Computer"
            orderby Computer.Name
            select Computer.Name).ToList;
        }
    

提交回复
热议问题