Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Just a detailed question

Just a detailed question

Scheduled Pinned Locked Moved C#
sysadmincsharphelptutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jphuphilly
    wrote on last edited by
    #1

    Okay im trying to learn server side programming and i just want to know is it possible to create a program that list all the computers on a network then puts them all in a listbox then you can select a computer and that computer we'll be shown a message box or something like that Basically im tryin to build a program like freeze tag for computers. I know c# pretty well but i don't know how to list the computers on the network then how would i show them a message box or something like that. Uh i know it kinda detailed but any help would be greatly appreciated. Thanks alot:-D:-D Da Intern

    L 1 Reply Last reply
    0
    • J jphuphilly

      Okay im trying to learn server side programming and i just want to know is it possible to create a program that list all the computers on a network then puts them all in a listbox then you can select a computer and that computer we'll be shown a message box or something like that Basically im tryin to build a program like freeze tag for computers. I know c# pretty well but i don't know how to list the computers on the network then how would i show them a message box or something like that. Uh i know it kinda detailed but any help would be greatly appreciated. Thanks alot:-D:-D Da Intern

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      There is some helpful code in my MyDUMeter article, look at the ... o here you go:

      [DllImport("Netapi32")]
      private static extern int NetServerEnum(
      string servername, //must be null
      int level, //101
      out IntPtr buffer,
      int maxlen, //out
      out int entriesread, //out
      out int totalentries, //out
      int servertype, //in 3 = all
      string domain, //null primary
      int resumehandle); //must be 0

      [DllImport("Netapi32")]
      private static extern int NetApiBufferFree(IntPtr ptr);

      [StructLayout(LayoutKind.Sequential)]
      internal class ServerInfo
      {
      public int platformid;
      [MarshalAs(UnmanagedType.LPWStr)]
      public string name;
      public int majorver;
      public int minorver;
      public int type;
      [MarshalAs(UnmanagedType.LPWStr)]
      public string comment;
      }

      class MachineConvertor : TypeConverter
      {
      public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
      {
      int eread, etot;
      IntPtr buffer;
      int l = 200;
      int size = Marshal.SizeOf(typeof(ServerInfo));
      int res = NetServerEnum(
      null,
      101,
      out buffer,
      size * l,
      out eread,
      out etot,
      3,
      null,
      0);

        IntPtr p = buffer;
        ArrayList arr = new ArrayList(etot);
        for (int i = 0; i < eread; i++)
        {
            ServerInfo si = Marshal.PtrToStructure(p, typeof(ServerInfo)) as ServerInfo;   
            if (si.majorver > 4 && si.name != "")
              arr.Add(si.name);
            p = (IntPtr)((int)p + size);
        }
      
        res = NetApiBufferFree(buffer);
        return new StandardValuesCollection(arr);
      }
      
      
      public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
      {
        return true;
      }
      

      }

      leppie::AllocCPArticle("Zee blog");
      Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups