JdP Posted June 8, 2006 Report Share Posted June 8, 2006 Hi people, I want to read the ID of the hard drive of a computer and I've read that it is posible using WMI of Microsoft but I don't how to use so, is there anybody who knows? Bye Quote Link to comment
Mike Ashe Posted June 8, 2006 Report Share Posted June 8, 2006 Hi people,I want to read the ID of the hard drive of a computer and I've read that it is posible using WMI of Microsoft but I don't how to use so, is there anybody who knows? Bye Try this post: Kernel32.dll call to get volume info Cheers, PS: A little use of the Search feature makes it easy to find stuff like this. Quote Link to comment
JdP Posted June 9, 2006 Author Report Share Posted June 9, 2006 Hi Michael, Firstly, thanks for answering so quickly. I've been reading some messages in the forum of National Instruments and I've got the VI that I atach you. The VI uses .NET platform to comunicate with WMI (Windows Management Instrumentation) that is an API to Windows OS. With this I can do what I wanted. It's necessary to be installed .NET Framework in the computer but it can be downloaded from www.microsoft.com and it's redistributable. cheers Download File:post-4923-1149835114.vi Quote Link to comment
Mike Ashe Posted June 9, 2006 Report Share Posted June 9, 2006 JdP, you're welcome. Yes, the .NET - WMI method works. Thanks for posting the VI you have, however, if you got this off of NI's site you may not be able to post it hear, depending on the license. Please check the applicable license or Terms Of Use agreement for where you got it from. It is permissible to post a link to the topic at NI's forums and that is the prefered method. If you did this VI yourself, kudo's. The only problem with the .NET method is the needed installation of the .NET framework, whereas the kernel32 call is simple and works as is. YMMV Quote Link to comment
JdP Posted June 12, 2006 Author Report Share Posted June 12, 2006 Hello Michael, I think there isn't any problem with the VI because I got it from a person who post it in discussion forum in the NI's website so, I suppose that the 'intellectual property' belongs to the person who post it in the web and no to NI. And when you put something in a forum like this or like NI's forum is to other people helps you and uses code you post. I know that it's neccesary to have installed in the computer the .NET framework. This is quite normal nowdays because the new applications are programmed with .NET within Visual Studio .NET of Microsoft. I've got one program from Microsoft that can be interested. The name is 'Microsoft Component Installer Software Development Kit for Windows (x86) Version 2.0'. It can be downloaded from the following link: http://www.microsoft.com/downloads/details...&DisplayLang=en With this program you can do an Installer CD to install the necessary MS components for you application. There is help file. I've just used to install the .NET framework and after that I excute the installer of my LabVIEW program. Cheers, Quote Link to comment
Rolf Kalbermatter Posted June 12, 2006 Report Share Posted June 12, 2006 Hello Michael,I think there isn't any problem with the VI because I got it from a person who post it in discussion forum in the NI's website so, I suppose that the 'intellectual property' belongs to the person who post it in the web and no to NI. And when you put something in a forum like this or like NI's forum is to other people helps you and uses code you post. I know that it's neccesary to have installed in the computer the .NET framework. This is quite normal nowdays because the new applications are programmed with .NET within Visual Studio .NET of Microsoft. I've got one program from Microsoft that can be interested. The name is 'Microsoft Component Installer Software Development Kit for Windows (x86) Version 2.0'. It can be downloaded from the following link: http://www.microsoft.com/downloads/details...&DisplayLang=en With this program you can do an Installer CD to install the necessary MS components for you application. There is help file. I've just used to install the .NET framework and after that I excute the installer of my LabVIEW program. Cheers, I know this might be a moot point with LabVIEW 8 only supporting 2000 and XP anyhow, but there are many people still running on older LabVIEW versions and Windows OSes. And for them .Net is not just an inconvinience but simply an impossibility. So why use a high tech laser cutter for something where a simple pocket knife will do more than well enough? Rolf Kalbermatter Quote Link to comment
JdP Posted June 12, 2006 Author Report Share Posted June 12, 2006 I know this might be a moot point with LabVIEW 8 only supporting 2000 and XP anyhow, but there are many people still running on older LabVIEW versions and Windows OSes. And for them .Net is not just an inconvinience but simply an impossibility. So why use a high tech laser cutter for something where a simple pocket knife will do more than well enough?Rolf Kalbermatter I suppose that you're right. I only wanted to start to use WMI because it's very useful to communicate with MS Windows OS. With WMI you can do a lot of things with the same interface. Quote Link to comment
Mike Ashe Posted June 12, 2006 Report Share Posted June 12, 2006 I suppose that you're right. I only wanted to start to use WMI because it's very useful to communicate with MS Windows OS. With WMI you can do a lot of things with the same interface. Rolf is right about the hi-low tech trade off. Liberal use of Occum's Razor will keep your code neat and portable over the years. However, it is also good to learn new and more powerful interfaces/APIs, so perhaps your use of WMI on this simple case will give you some experience that you can use later on more complicated problems that actually require something with the power of WMI. Elegant, well written code almost always uses the simplest means to get the job done. Quote Link to comment
osvaldo Posted June 28, 2006 Report Share Posted June 28, 2006 Hi people,I want to read the ID of the hard drive of a computer and I've read that it is posible using WMI of Microsoft but I don't how to use so, is there anybody who knows? Bye Hi In alternative you can use the utility attached, that report any data from the drives of the PC... You can call the utility via the System Exec VI... :thumbup: Osvaldo Download File:post-457-1151488070.zip Quote Link to comment
JdP Posted June 28, 2006 Author Report Share Posted June 28, 2006 HiIn alternative you can use the utility attached, that report any data from the drives of the PC... You can call the utility via the System Exec VI... :thumbup: Osvaldo Hello Osvaldo, Thanks for posting this executable file. It is a very easy and simple solution to get the Id of the hard disk. The only problem I've seen is that the output of the command is not direct so I must use String functions to get the HardDisk_Id that is the only what I want. Thanks again. Quote Link to comment
rayodyne Posted April 24, 2009 Report Share Posted April 24, 2009 QUOTE (JdP @ Jun 28 2006, 05:07 AM) Hello Osvaldo,Thanks for posting this executable file. It is a very easy and simple solution to get the Id of the hard disk. The only problem I've seen is that the output of the command is not direct so I must use String functions to get the HardDisk_Id that is the only what I want. Thanks again. Hello there, I've read this post with much interest, however from the comments on the NI Forums and here at LAVA have never addressed how to access a byte array returned from the .NET ManagementBaseObject. All postings and examples (which I'm most thankful for!) have always referred to single string parameter output, from the System.Object (ToString) LabVIEW Invoke node. My problem is I'm not a .NET programmer and the literal translation of the .VB .NET, .VBS or C# is not as simple as one would hope. See attached screen shot example from WMI Code Creator. Imports System Imports System.Management Imports System.Windows.Forms Namespace WMISample Public Class MyWMIQuery Public Overloads Shared Function Main() As Integer Try Dim searcher As New ManagementObjectSearcher( _ "root\WMI", _ "SELECT * FROM MSStorageDriver_ATAPISmartData") For Each queryObj As ManagementObject in searcher.Get() Console.WriteLine("-----------------------------------") Console.WriteLine("MSStorageDriver_ATAPISmartData instance") Console.WriteLine("-----------------------------------") If queryObj("VendorSpecific") Is Nothing Then Console.WriteLine("VendorSpecific: {0}", queryObj("VendorSpecific")) Else Dim arrVendorSpecific As Byte() arrVendorSpecific = queryObj("VendorSpecific") For Each arrValue As Byte In arrVendorSpecific Console.WriteLine("VendorSpecific: {0}", arrValue) Next End If Next Catch err As ManagementException MessageBox.Show("An error occurred while querying for WMI data: " & err.Message) End Try End Function End Class End Namespace The specifics is translating the two lines, Dim arrVendorSpecific As Byte(), arrVendorSpecific = queryObj("VendorSpecific") into something meaningful that LabVIEW can understand. Ultimately, we should receive a byte array and be able to select the elements as appropriate from this. Can someone more savvy with .NET and LabVIEW integration help me sleep better at night? Regards, Chroma Quote Link to comment
rayodyne Posted May 13, 2009 Report Share Posted May 13, 2009 QUOTE (rayodyne @ Apr 23 2009, 12:38 PM) Hello there,I've read this post with much interest, however from the comments on the NI Forums and here at LAVA have never addressed how to access a byte array returned from the .NET ManagementBaseObject. All postings and examples (which I'm most thankful for!) have always referred to single string parameter output, from the System.Object (ToString) LabVIEW Invoke node. My problem is I'm not a .NET programmer and the literal translation of the .VB .NET, .VBS or C# is not as simple as one would hope. See attached screen shot example from WMI Code Creator. Imports System Imports System.Management Imports System.Windows.Forms Namespace WMISample Public Class MyWMIQuery Public Overloads Shared Function Main() As Integer Try Dim searcher As New ManagementObjectSearcher( _ "root\WMI", _ "SELECT * FROM MSStorageDriver_ATAPISmartData") For Each queryObj As ManagementObject in searcher.Get() Console.WriteLine("-----------------------------------") Console.WriteLine("MSStorageDriver_ATAPISmartData instance") Console.WriteLine("-----------------------------------") If queryObj("VendorSpecific") Is Nothing Then Console.WriteLine("VendorSpecific: {0}", queryObj("VendorSpecific")) Else Dim arrVendorSpecific As Byte() arrVendorSpecific = queryObj("VendorSpecific") For Each arrValue As Byte In arrVendorSpecific Console.WriteLine("VendorSpecific: {0}", arrValue) Next End If Next Catch err As ManagementException MessageBox.Show("An error occurred while querying for WMI data: " & err.Message) End Try End Function End Class End Namespace The specifics is translating the two lines, Dim arrVendorSpecific As Byte(), arrVendorSpecific = queryObj("VendorSpecific") into something meaningful that LabVIEW can understand. Ultimately, we should receive a byte array and be able to select the elements as appropriate from this. Can someone more savvy with .NET and LabVIEW integration help me sleep better at night? Regards, Chroma No takers? -Chroma Quote Link to comment
Cool-LV Posted June 12, 2009 Report Share Posted June 12, 2009 QUOTE (rayodyne @ May 12 2009, 05:33 PM) No takers?-Chroma Hi, From "Current" invoke node, wire to "Get Text" property node, Select "Mod" Format, it would feedback Vendor specifici of Byte[], is it your goal? Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.