Author Topic: How to write functions and get ID as STRING type from WMI (win32)?  (Read 6956 times)

puncher

  • Guest
Hi,


Today I have first time in my life used Code Blocks program. So far I have not heard about this programm. Can someone help me write in C++ or C the DLL that returns two (following) functions as STRING type using WMI (Windows Management Instrumentation)?

1/. My first code I would like to use (writen in C#) in DLL is here:
"
using System;
using System.Management;
using System.Windows.Forms;

namespace WMISample
{
    public class MyWMIQuery
    {
        public static void Main()
        {
            try
            {
                ManagementObjectSearcher searcher =
                    new ManagementObjectSearcher("root\\CIMV2",
                    "SELECT * FROM Win32_Processor");

                foreach (ManagementObject queryObj in searcher.Get())
                {
                    Console.WriteLine("-----------------------------------");
                    Console.WriteLine("Win32_Processor instance");
                    Console.WriteLine("-----------------------------------");
                    Console.WriteLine("ProcessorId: {0}", queryObj["ProcessorId"]);
                }
            }
            catch (ManagementException e)
            {
                MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
            }
        }
    }
}

"

2/. My second code I would like to use (writen in C#) in DLL is here:
"
using System;
using System.Management;
using System.Windows.Forms;

namespace WMISample
{
    public class MyWMIQuery
    {
        public static void Main()
        {
            try
            {
                ManagementObjectSearcher searcher =
                    new ManagementObjectSearcher("root\\CIMV2",
                    "SELECT * FROM Win32_DiskDrive");

                foreach (ManagementObject queryObj in searcher.Get())
                {
                    Console.WriteLine("-----------------------------------");
                    Console.WriteLine("Win32_DiskDrive instance");
                    Console.WriteLine("-----------------------------------");
                    Console.WriteLine("SerialNumber: {0}", queryObj["SerialNumber"]);
                }
            }
            catch (ManagementException e)
            {
                MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
            }
        }
    }
}

"

My Questions Are:

1/. How to write and export above functions into one DLL ?
2/. What debugger should I use and how to configure compiler ?

P.s.: I have already installed on my PC (Windows7 32 Bit): SDK for .NET 3.5 SP1, SDK for .NET 4.

3/. Please for any example here and/or e-mail me.
« Last Edit: October 26, 2011, 10:36:03 pm by puncher »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: How to write functions and get ID as STRING type from WMI (win32)?
« Reply #1 on: October 26, 2011, 10:52:59 pm »
Why is it so hard to read and respect the forum rules ?
With registering here, you accepted to follow this rules !
Your question is ageneral programming questions and therefore not allowed here,
you post it in a sub-forum, that is dedicated to C::B development,
you ask someone to do your work.

The rules clearly state this all as forbidden, and there are good causes for this (just read the rules and you know why).

Topic locked !

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: How to write functions and get ID as STRING type from WMI (win32)?
« Reply #2 on: October 26, 2011, 11:14:44 pm »
Please stop violating our forum rules.
Please try to read and understand the rules.

I just deleted the same post in another sub-forum.
If I have to do it once more, you will be banned from the forum.