Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Creating an application for detecting USB devices ?

$
0
0

Hello Everyone,

I am hoping someone can clear all mu confusion. 

The main aim of building an application in C# is so that it can be used in another software by calling its ProgID.

All I need is to get the Serial number of the USB devices that are connected.

I tried the following code :

static void Main(string[] args)
        {
            ResourceManager rMgr = new ResourceManager();
            object resources = null;
            resources = rMgr.FindRsrc("USB[0-9]*::?*");
            string[] resource_list = (string[])resources;

            foreach ( string msg in resource_list)
            {
                
                string[] array = msg.Split(':',':','"').ToArray();
                Console.WriteLine("Serial Number: " + array[6]);
                Console.WriteLine(msg);
            }
Console.Read();
}
 

Here I get the Serial numbers.

But what I am getting confused with is, when I want to use this code with another application( a calibration software which has scripting capability) , then how will I get the serial number there? 

Do I have to store the serial number in a variable and then use the same variable name in the script of the software?

Or do I write a function which returns the serial number and call that function?

Does this make any sense?

Please let me know. 

Thanks.


 


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>