Solved

How can I get the ser.no of Hdisks & CDROM

Posted on 1998-07-15
6
164 Views
Last Modified: 2010-05-19
How do i get the serial number from a hard disk or cdrom, directly from the
controller, this function must be able  to work with both ide and scsi devices!
Source code must be in c or c++
0
Comment
Question by:gx
  • 3
  • 2
6 Comments
 
LVL 2

Accepted Solution

by:
warmcat earned 100 total points
Comment Utility
This is dependent on which OS you're using, dude.

I can only say for Win32:

GetVolumeInformation  
The GetVolumeInformation function returns information about a file system and volume whose root directory is specified.

BOOL GetVolumeInformation( LPCTSTR lpRootPathName,
 // address of root directory of the file system
 
LPTSTR lpVolumeNameBuffer,
 // address of name of the volume
 
DWORD nVolumeNameSize,
 // length of lpVolumeNameBuffer
 
LPDWORD lpVolumeSerialNumber,
 // address of volume serial number
 
LPDWORD lpMaximumComponentLength,
 // address of system’s maximum filename length
 
LPDWORD lpFileSystemFlags,
 // address of file system flags
 
LPTSTR lpFileSystemNameBuffer,
 // address of name of file system
 
DWORD nFileSystemNameSize
 // length of lpFileSystemNameBuffer
 
);
 


Parameters
lpRootPathName

Points to a string that contains the root directory of the volume to be described. If this parameter is NULL, the root of the current directory is used. If this parameter is a UNC name, you must follow it with an additional backslash. For example, you would specify \\MyServer\MyShare as \\MyServer\MyShare\.

lpVolumeNameBuffer

Points to a buffer that receives the name of the specified volume.

nVolumeNameSize

Specifies the length, in characters, of the volume name buffer. This parameter is ignored if the volume name buffer is not supplied.

lpVolumeSerialNumber

Points to a variable that receives the volume serial number. This parameter can be NULL if the serial number is not required.

lpMaximumComponentLength

Points to a doubleword value that receives the maximum length, in characters, of a filename component supported by the specified file system. A filename component is that portion of a filename between backslashes.

The value stored in variable pointed to by *lpMaximumComponentLength is used to indicate that long names are supported by the specified file system. For example, for a FAT file system supporting long names, the function stores the value 255, rather than the previous 8.3 indicator. Long names can also be supported on systems that use the New Technology file system.

lpFileSystemFlags

Points to a doubleword that receives flags associated with the specified file system. This parameter can be any combination of the following flags, with one exception: FS_FILE_COMPRESSION and FS_VOL_IS_COMPRESSED are mutually exclusive. Value
 Meaning
 
FS_CASE_IS_PRESERVED
 If this flag is set, the file system preserves the case of filenames when it places a name on disk.
 
FS_CASE_SENSITIVE
 If this flag is set, the file system supports case-sensitive filenames.
 
FS_UNICODE_STORED_ON_DISK
 If this flag is set, the file system supports Unicode in filenames as they appear on disk.
 
FS_PERSISTENT_ACLS
 If this flag is set, the file system preserves and enforces ACLs. For example, NTFS preserves and enforces ACLs, and FAT does not.
 
FS_FILE_COMPRESSION
 The file system supports file-based compression.
 
FS_VOL_IS_COMPRESSED
 The specified volume is a compressed volume; for example, a DoubleSpace volume.
 


lpFileSystemNameBuffer

Points to a buffer that receives the name of the file system (such as FAT or NTFS).

nFileSystemNameSize

Specifies the length, in characters, of the file system name buffer. This parameter is ignored if the file system name buffer is not supplied.

Return Values
If all the requested information is retrieved, the return value is nonzero.

If not all the requested information is retrieved, the return value is zero. To get extended error information, call GetLastError.

Remarks
If you are attempting to obtain information about a floppy drive that does not have a floppy disk or a CD-ROM drive that does not have a compact disc, the system displays a message box asking the user to insert a floppy disk or a compact disc, respectively. To prevent the system from displaying this message box, call the SetErrorMode function with SEM_FAILCRITICALERRORS.

The FS_VOL_IS_COMPRESSED flag is the only indicator of volume-based compression. The file system name is not altered to indicate compression. This flag comes back set on a DoubleSpace volume, for example. With volume-based compression, an entire volume is either compressed or not compressed.

The FS_FILE_COMPRESSION flag indicates whether a file system supports file-based compression. With file-based compression, individual files can be compressed or not compressed.

The FS_FILE_COMPRESSION and FS_VOL_IS_COMPRESSED flags are mutually exclusive; both bits cannot come back set.

The maximum component length value, stored in the DWORD variable pointed to by lpMaximumComponentLength, is the only indicator that a volume supports longer-than-normal FAT (or other file system) file names. The file system name is not altered to indicate support for long file names.

The GetCompressedFileSize function obtains the compressed size of a file. The GetFileAttributes function can determine whether an individual file is compressed.




0
 

Author Comment

by:gx
Comment Utility
Thanx Yes I am using Win32 as I have already read the above info in the BCB(Borland C++ Builder) help files I can only give an average grade. If possible I need something
more low level or sample source code :}

I appreciate the help
GX
0
 
LVL 11

Expert Comment

by:alexo
Comment Utility
gx, if you feel an answer (any answer) is not acceptable, you should reopen the question instead of grading it.  The current situation is that this question is closed -- nobody will even look at it (because it costs 10 points).
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 2

Expert Comment

by:warmcat
Comment Utility
Yes, gx, while I'm happy you accepted my answer for those whole ten juicy points, what exactly are you asking for that a full description of the API doesn't deliver?  It seems to be self-explanatory.  For my part I'd prefer to be rejected than get a C grade manking up my straight-As.
0
 
LVL 11

Expert Comment

by:alexo
Comment Utility
>> Yes, gx, while I'm happy you accepted my answer for those whole ten juicy points.
Boy, you ARE a newbie, aren't you?
That was 100 points (actually, 200 because of the grade).  10 points is what the question is worth as a PAQ.

As to your answer, gx asked about "the serial number from a hard disk or cdrom, directly from the controller", NOT about the the volume serial number.
0
 
LVL 2

Expert Comment

by:warmcat
Comment Utility
I may only have tripped over this site 1998-07-13, but I'm not so much a newbie I can't detect self-aggrandizing pique when I see it.  Maybe you take the thing too seriously?
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

744 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

12 Experts available now in Live!

Get 1:1 Help Now