Ver Mensaje Individual
  #9 (permalink)  
Antiguo 07/09/2002, 22:54
hchris
 
Fecha de Ingreso: abril-2002
Mensajes: 20
Antigüedad: 22 años
Puntos: 0
Re: Visual Basic: Como leer el serial del disco duro.


GetVolumeSerialNumber( pszRootPathName, pdwSerialNum )

Retrieves the serial number of a local or remote volume.

Parameters
pszRootPathName
The volume to get the serial number of. Must be specified as
one of:
A drive letter, colon and trailing backslash. C:\
A UNC name with trailing backslash. \\svr\share\

pdwSerialNum
A pointer to a DWORD that will contain the serial number when
the function returns. Note: the caller must allocate the memory
for this parameter.

Return value
Returns TRUE if it successfully retrieves a volume serial number, or
FALSE if it can't.
*/
BOOL GetVolumeSerialNumber (LPCSTR pszRootPathName, DWORD *pdwSerialNum)
{
BOOL bReturn = FALSE; // Assume that we haven't get the serial number,
// then set it to true if we do get it.

HANDLE hFile;
BY_HANDLE_FILE_INFORMATION bhFileInfo;

HANDLE hFileFind;
WIN32_FIND_DATA wfdFileData;
char szFindFileName[MAX_PATH];


/*
Search for any file that we can open and retrieve information about.
That information will include the serial number of the volume on
which the file resides.
*/
lstrcpy (szFindFileName, pszRootPathName);
lstrcat (szFindFileName, "*");

hFileFind = FindFirstFile (szFindFileName, &wfdFileData);
if (INVALID_HANDLE_VALUE == hFileFind)
goto EXIT_DONE;

do
{
/* Make sure that we've found a file and not a directory */
if (!(wfdFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{