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. [Message Deleted]

[Message Deleted]

Scheduled Pinned Locked Moved C#
4 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.
  • M Offline
    M Offline
    Marutar
    wrote on last edited by
    #1

    [Message Deleted]

    E 1 Reply Last reply
    0
    • M Marutar

      [Message Deleted]

      E Offline
      E Offline
      ekynox
      wrote on last edited by
      #2

      you can try using the WMI C# code generator, refer to link: http://veeralp.blogspot.com/2007/11/wmi-code-generation-for-c-vbnetvb.html[^] WMI is not that hard to learn, there is alot of information available on MSDN. If you have any more problems post back.

      M 1 Reply Last reply
      0
      • E ekynox

        you can try using the WMI C# code generator, refer to link: http://veeralp.blogspot.com/2007/11/wmi-code-generation-for-c-vbnetvb.html[^] WMI is not that hard to learn, there is alot of information available on MSDN. If you have any more problems post back.

        M Offline
        M Offline
        Marutar
        wrote on last edited by
        #3

        I've been using the WMI code generator to get my start, but I'm having trouble figuring out how to implement WMI in C# on my own. I've figured out that what I'll probably do to check who is logged on the computer remotly is use: -Win32_Process, filter where name='explorer.exe' And then: -GetOwner to throw back the username. Are u familiar on how to implement WMI in C#? I could really use a hand.

        E 1 Reply Last reply
        0
        • M Marutar

          I've been using the WMI code generator to get my start, but I'm having trouble figuring out how to implement WMI in C# on my own. I've figured out that what I'll probably do to check who is logged on the computer remotly is use: -Win32_Process, filter where name='explorer.exe' And then: -GetOwner to throw back the username. Are u familiar on how to implement WMI in C#? I could really use a hand.

          E Offline
          E Offline
          ekynox
          wrote on last edited by
          #4

          try this. I got the code snippet from the code generator itself. However, makesure you know which Win32_Process.Handle you want t10execute GetOwner on. In the code snippet its tied to 1076. using System; using System.Management; using System.Windows.Forms; namespace WMISample { public class CallWMIMethod { public static void Main() { try { ManagementObject classInstance = new ManagementObject("root\\CIMV2", "Win32_Process.Handle='1076'", null); // no method in-parameters to define // Execute the method and obtain the return values. ManagementBaseObject outParams = classInstance.InvokeMethod("GetOwner", null, null); // List outParams Console.WriteLine("Out parameters:"); Console.WriteLine("Domain: " + outParams["Domain"]); Console.WriteLine("ReturnValue: " + outParams["ReturnValue"]); Console.WriteLine("User: " + outParams["User"]); } catch(ManagementException err) { MessageBox.Show("An error occurred while trying to execute the WMI method: " + err.Message); } } } }

          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