Ramesh_Kumar_02a072

Hi everyone,

I m newbie for VB2005. I m trying to create DLL for my project. I want know how to code for a DLL, means any template for the DLL.

If anybody help me to get Processor ID or some other hardwares.

Help Plz

Ramesh




Re: Visual Basic Express Edition how to create DLL and get Processor ID using VB2005

Jay Vora

DLL files r automatically made in ur Bin debug folder of the project by the name of ur solution explorer..

try this..

Declare following three object variables

Dim objMOS As ManagementObjectSearcher

Dim objMOC As Management.ManagementObjectCollection

Dim objMO As Management.ManagementObject

Now, execute the query to get the results

objMOS = New ManagementObjectSearcher("Select * From Win32_Processor")

objMOC = objMOS.Get

Finally, get the CPU's id.

For Each objMO In objMOC

MessageBox.Show("CPU ID = " & objMO("ProcessorID"))

Next

Dispose object variables.

objMOS.Dispose()

objMOS = Nothing






Re: Visual Basic Express Edition how to create DLL and get Processor ID using VB2005

Tall Dude

Using Jay's code, (but ignoring multiple processors.)

¡® Project name = ProcessorID

¡® Class to make a dll

¡® Created dll name ProcessorID.dll

Imports System.Management

Public Class ProcID

Public Sub New()

Dim objMOS As ManagementObjectSearcher

Dim objMOC As Management.ManagementObjectCollection

Dim objMO As Management.ManagementObject

'Now, execute the query to get the results

objMOS = New ManagementObjectSearcher("Select * From Win32_Processor")

objMOC = objMOS.Get

'Finally, get the CPU's id.

For Each objMO In objMOC

m_ID = CStr(objMO("ProcessorID"))

'MessageBox.Show("CPU ID = " & objMO("ProcessorID"))

Next

objMOS.Dispose()

objMOS = Nothing

End Sub

Private m_ID As String

Public ReadOnly Property GetID() As String

Get

Return m_ID

End Get

End Property

End Class

¡® Program to use the dll

¡® Needs a refernce to ProcessorID added

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles Button1.Click

Dim p As New ProcessorID.ProcID

MsgBox(p.GetID)

End Sub

End Class






Re: Visual Basic Express Edition how to create DLL and get Processor ID using VB2005

Ramesh Kumar

Thanks for help Sir!

Let me check.






Re: Visual Basic Express Edition how to create DLL and get Processor ID using VB2005

Ramesh Kumar

Code Snippet
Imports System.Management

System.Management namespace isn't existing and giving error.

I have searched in MSDN but unable to use with my VB2005

What should I to do this






Re: Visual Basic Express Edition how to create DLL and get Processor ID using VB2005

ReneeC

Add System.Management as a project reference.

Main Menu | Project | Properties | references






Re: Visual Basic Express Edition how to create DLL and get Processor ID using VB2005

Blue8481

Hello,
you can also use a Microsoft utility named WMI code creator to easily find system information and generate the code needed for your needs. It can find things like processorID, memory info, HDD, and network info. Its available here www.microsoft.com/downloads/details.aspx familyid=2CC30A64-EA15-4661-8DA4-55BBC145C30E&displaylang=en
have a good day