Solved

getting hdd @cpu id or serial no

Posted on 2001-06-07
13
831 Views
Last Modified: 2006-11-17
dear frinds


i am requisting some ocx or control or windows based software or command in visual basic and the instruction of use for reading the serial no. or(id no.)of the hard disk drive (not the lable name or no.) and also to get the id no. (serial no.) of the cpu


thanks


0
Comment
Question by:jssjss
13 Comments
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6163019
0
 
LVL 2

Expert Comment

by:Microsoft
ID: 6163425
TRY THIS MY FRIEND. This will get you the HARD disk or any other disk's serial number, just cut and paste it in VB

ive put notes in for you to follow, just create a form with a command button and put this code in to it.

cheers

Andy

code below :=



Option Explicit


Private Declare Function GetVolumeInformation& Lib "kernel32" _
    Alias "GetVolumeInformationA" (ByVal lpRootPathName _
    As String, ByVal pVolumeNameBuffer As String, ByVal _
    nVolumeNameSize As Long, lpVolumeSerialNumber As Long, _
    lpMaximumComponentLength As Long, lpFileSystemFlags As _
    Long, ByVal lpFileSystemNameBuffer As String, ByVal _
    nFileSystemNameSize As Long)
    Const MAX_FILENAME_LEN = 256


Private Sub Command1_Click()
    Label1.Caption = SerNum("C") 'C is the standard harddisk
End Sub


Public Function SerNum(Drive$) As Long
    Dim No&, s As String * MAX_FILENAME_LEN
    Call GetVolumeInformation(Drive + ":\", s, MAX_FILENAME_LEN, _
    No, 0&, 0&, s, MAX_FILENAME_LEN)
    SerNum = No
End Function


Private Sub Form_Load()
End Sub

0
 
LVL 2

Expert Comment

by:Microsoft
ID: 6163429
dont put all the code in the command button sorry.


just create a command button,

well you know what to do so ill leave it with you

0
 
LVL 2

Expert Comment

by:Microsoft
ID: 6163454
dont put all the code in the command button sorry.


just create a command button,

well you know what to do so ill leave it with you

0
 
LVL 2

Expert Comment

by:Microsoft
ID: 6163487
for information regarding your cpu this does the lot.

you will need to download :- http://msdn.microsoft.com/downloads/sdks/wmi/default.asp

before you run this code.

'***********************************************************\
'NOTES:

'YOU MUST HAVE WMI SDK INSTALLED.  YOU CAN GET IT AT
'http://msdn.microsoft.com/downloads/sdks/wmi/default.asp
'***********************************************************************

Private asCpuPaths() As String
Private m_objCPUSet As SWbemObjectSet
Private m_objWMINameSpace As SWbemServices
Option Explicit

Private Sub cmdDone_Click()
Unload Me
End Sub

Private Sub Form_Load()


Dim oCpu As SWbemObject 'WMI Object, in this case, local CPUs
Dim sPath As String, sCaption As String

Dim lElement As Long
ReDim asCpuPaths(0) As String


On Error GoTo ErrorHandler

'Get Default NameSpace, which will be the one for the local machine
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
Set m_objWMINameSpace = GetObject("winmgmts:")
lstCPU.Clear


'Get CPU set

Set m_objCPUSet = m_objWMINameSpace.InstancesOf("Win32_Processor")
sCaption = m_objCPUSet.Count & " processor"
If m_objCPUSet.Count <> 1 Then sCaption = sCaption & "s"
sCaption = sCaption & " detected on this machine"
lblTitle.Caption = sCaption
'Populate list box with CPU names
               
For Each oCpu In m_objCPUSet
     With oCpu
        sPath = .Path_ & ""
            If sPath <> "" Then
                lstCPU.AddItem .Name
                'save path to array, so on machines with multiple CPUs,
                'each can be identified and their info loaded into text box
               
                lElement = IIf(asCpuPaths(0) = "", 0, UBound(asCpuPaths) + 1)
                ReDim Preserve asCpuPaths(lElement) As String
                asCpuPaths(lElement) = sPath
            End If
     End With
Next
If lstCPU.ListCount <> 0 Then lstCPU.ListIndex = 0
     
 



CleanUp:
Set oCpu = Nothing

Exit Sub

ErrorHandler:
MsgBox "CPU Information could not be displayed due to the following error: " & Err.Description, , "WMI Demo Failed"
GoTo CleanUp
End Sub

Private Sub Form_Unload(Cancel As Integer)
Set m_objCPUSet = Nothing
Set m_objWMINameSpace = Nothing
End Sub

Private Sub lstCPU_Click()
Dim oCpu As SWbemObject
'Refer to SDK documentation for more detail about each of these properties
Dim sInfoString As String
On Error Resume Next
Set oCpu = m_objCPUSet(asCpuPaths(lstCPU.ListIndex))
With oCpu
    sInfoString = "Description: " & .Description & vbCrLf
    sInfoString = sInfoString & "Processor ID: " & .ProcessorID & vbCrLf
    sInfoString = sInfoString & "Status: " & .Status & vbCrLf
    sInfoString = sInfoString & "Manufacturer: " & .Manufacturer & vbCrLf
    sInfoString = sInfoString & "Availability: " & AvailabilityToString(.Availability) & vbCrLf
    sInfoString = sInfoString & "Load Percentage: " & .LoadPercentage & vbCrLf
    sInfoString = sInfoString & "Current Clock Speed: " & .CurrentClockSpeed & " MHz" & vbCrLf
    sInfoString = sInfoString & "Maximum Clock Speed: " & .MaxClockSpeed & vbCrLf
    sInfoString = sInfoString & "Level 2 Cache Size: " & .L2CacheSize & vbCrLf
    sInfoString = sInfoString & "Level 2 Cache Speed: " & .L2CacheSpeed & vbCrLf
    sInfoString = sInfoString & "Power Management Supported: " & .PowerManagementSupported
End With
txtCpu.Text = sInfoString

End Sub
'Conversions from code to string were developed
'based on information in WMI SDK documentation
Private Function AvailabilityToString(Code As Integer) As String
Dim sAns As String

Select Case Code
    Case 1, 2
        sAns = "Unknown"
    Case 3
        sAns = "Running/Full Power"
    Case 4
        sAns = "Warning"
    Case 5
        sAns = "In Test"
    Case 6
        sAns = "Not Applicable"
    Case 7
        sAns = "Power Off"
    Case 8
        sAns = "Off Line"
    Case 9
        sAns = "Off Duty"
    Case 10
        sAns = "Degraded"
    Case 11
        sAns = "Not Installed"
    Case 12
        sAns = "Install Error"
    Case 13
        sAns = "Power Save - Unknown"
    Case 14
        sAns = "Power Save - Low Power Mode"
    Case 15
        sAns = "Power Save - Standby"
    Case 16
        sAns = "Power Cycle"
    Case 17
        sAns = "Power Save - Warning"
    Case Else
        sAns = "Unknown"
End Select
AvailabilityToString = sAns

End Function


       

good luck
hope thats what you wanted

Andy
0
 

Author Comment

by:jssjss
ID: 6195373
the answer you giv to me is not correct with all respect

the code that you giv is only read the volum name but what i am waiting for is the hdd serial no. by manufacturer like that software dm(disk manager) but under windows

also i have additional quistion:

how i can use or create cheqbox in db grid in visual basic programing so that i can make acheq mark on items i did

thanks
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6195995
Did u try the links, that I have provided. It should return the serial number only, and not the vol. name, if I am right.

I dont think, you could create a check box in db grid. You should get some other tools, like, the one from Sheridan. Sheridan DBGrid, has options for cheque box, etc.

Or, may be, some other tools, like Apex TrueDbgrid, I have not used this. I think, they also have this.

hope this helps.

Cheers.
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6196001
Sorry, the one I typed,

for cheque box, etc.

should read as,

for check box, etc.
0
 
LVL 27

Accepted Solution

by:
Ark earned 50 total points
ID: 6552956
Hi
Take a look on my samples:

http://www.freevbcode.com/ShowCode.Asp?ID=3292
>>This class allows you to get BIOS information. For NT/2000, it reads the registry for this information; for 95/98/ME, you can do it by reading the system's memory using pointers<<

http://www.freevbcode.com/ShowCode.Asp?ID=3380
>>Here is a code to get low level HDD info. Tested on w95(OSR2)/98/NT/2000. At least Primary master HDD info is available (including HDD serial number, physical geometry and miscelaneous HDD parameters).<<

Cheers
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7017626
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101, Netminder or Mindphaser will return to finalize these if they are still open in 7 days.  Experts, please post closing recommendations before that time.

Below are your open questions as of today.  Questions which have been inactive for 21 days or longer are considered to be abandoned and for those, your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.  

Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added.  When you grade the question less than an A, please comment as to why.  This helps all involved, as well as others who may access this item in the future.  PLEASE DO NOT AWARD POINTS TO ME.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20116540.html
http://www.experts-exchange.com/questions/Q.20131201.html
http://www.experts-exchange.com/questions/Q.20146436.html
http://www.experts-exchange.com/questions/Q.20146810.html
http://www.experts-exchange.com/questions/Q.20290432.html
http://www.experts-exchange.com/questions/Q.20297023.html
http://www.experts-exchange.com/questions/Q.20297025.html
http://www.experts-exchange.com/questions/Q.20300111.html



*****  E X P E R T S    P L E A S E  ******  Leave your closing recommendations.
If you are interested in the cleanup effort, please click this link
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643
POINTS FOR EXPERTS awaiting comments are listed in the link below
http://www.experts-exchange.com/commspt/Q.20277028.html
 
Moderators will finalize this question if in @7 days Asker has not responded.  This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
 
Thanks everyone.
Moondancer
Moderator @ Experts Exchange
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7133393
Hi jssjss,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:

    Accept Ark's comment(s) as an answer.
*** Ark's second link provides request info (low-level serial#, not 'soft' volume id)

jssjss, if you think your question was not answered at all or if you need help, you can simply post a new comment here.  Community Support moderators will follow up.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Expert Comment

by:Computer101
ID: 7167816
Comment from expert accepted as answer

Computer101
E-E Moderator
0
 

Expert Comment

by:alialyosofy
ID: 12571040
Dear frinds

Is there any body who has ocx or code to encrypt data stored in data base
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now