473,386 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how to read HDD No

Hi every body
anyone can help me that how to read HDD No while VB programming is running....? is it possible or not if pos how to campare the value with a given string...?
Oct 19 '07 #1
5 1227
kadghar
1,295 Expert 1GB
Hi every body
anyone can help me that how to read HDD No while VB programming is running....? is it possible or not if pos how to campare the value with a given string...?
use the GetVolumeInformation function.first declare it (you can find this in google):

Expand|Select|Wrap|Line Numbers
  1. Private Declare Function GetVolumeInformation Lib "kernel32.dll" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Integer, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
And then just use it, you'll need a couple of longs and strings of character 0 many times in the buffers. something like this should do

Expand|Select|Wrap|Line Numbers
  1. sub HDDtest()
  2. dim Lng1 as long
  3. dim HDDnum as long
  4. lng1=getvolumeinformation("C:\",string(100,chr(0)),100,hddnum,0,0,string(100,chr(0)),100)
  5. msgbox "The HDD number is: " & hddnum
  6. end sub
well HTH
Oct 19 '07 #2
Killer42
8,435 Expert 8TB
Or if you prefer not to dabble in API funtions, just add Microsoft Scripting Runtime to your project, and try this code...
Expand|Select|Wrap|Line Numbers
  1. Dim f As New FileSystemObject
  2. Dim d As Drive
  3. On Error Resume Next
  4. For Each d In f.Drives
  5.   Debug.Print d.DriveLetter, d.DriveType, d.VolumeName, d.SerialNumber
  6. Next
Oct 21 '07 #3
jamesd0142
469 256MB
just add Microsoft Scripting Runtime
what does that mean?
Oct 22 '07 #4
kadghar
1,295 Expert 1GB
what does that mean?
its an activeX reference to get acces to files and all that stuff. I didnt know you could get hdd's serials with it :) nice.
Oct 22 '07 #5
Killer42
8,435 Expert 8TB
what does that mean?
Since I don't think you've mentioned your version, I'm going to assume VB6. Pull down the Project menu, select Components. On the list that comes up, select the checkbox next to "Microsoft Scripting Runtime". Don't know how it works in later versions.

For more details, look up "FileSystemObject model" in your documentation. There's also a sample in the VB Articles area (see the "Articles" dropdown menu at the top of this page) which shows how to read a text file using the FileSystemObject. This might help to get you started.
Oct 22 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Gunnar | last post by:
Hello, I've just written a CPP program that reads integers from a binary file, and used this code while (my_ifstram.read( (char* ) &number, sizeof(int)) { // do something with number } My...
11
by: Markus Breuer | last post by:
I have a question about oracle commit and transactions. Following scenario: Process A performs a single sql-INSERT into a table and commits the transaction. Then he informs process B (ipc) to...
12
by: Steven T. Hatton | last post by:
I know of a least one person who believes std::ifstream::read() and std::ofstream::write() are "mistakes". They seem to do the job I want done. What's wrong with them. This is the code I...
2
by: Sandman | last post by:
Just looking for suggestion on how to do this in my Web application. The goal is to keep track of what a user has and hasn't read and present him or her with new material I am currently doing...
4
by: Ollie Cook | last post by:
Hi, I am having some difficulty with read(2) and interrupting signals. I expect I am misunderstanding how the two work together, so would appreciate some guidance. I am trying to 'time out' a...
6
by: BBM | last post by:
I have an object that has a fairly complex construction sequence, so I have written a dedicated "factory" class that invokes the constructor of my object class (which does nothing but instantiate...
8
by: a | last post by:
I have a struct to write to a file struct _structA{ long x; int y; float z; } struct _structA A; //file open write(fd,A,sizeof(_structA)); //file close
1
by: Jose Reckoner | last post by:
I'm running python 2.3 on Windows XP. Anyone have a quick small script to convert .DT1 and .DEM data to ASCII or some other format? I don't need a viewer. Thanks!
0
by: phplasma | last post by:
Hey, I am currently attempting to implement a multi-threaded C# socket, using SSL (.pem file/certification/private key combo) server using Visual Studio C# Express. I have successfully made...
6
by: arnuld | last post by:
This works fine, I welcome any views/advices/coding-practices :) /* C++ Primer - 4/e * * Exercise 8.9 * STATEMENT: * write a program to store each line from a file into a *...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.