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


/*
Found a file. Now, use the full path to open the file and get
information about it. This information includes the serial
number of the volume on which the file resides. If we do get
the info, we can bail out because we're done.

If we can't open this file, look for another one we can open.
*/
lstrcpy (szFindFileName+lstrlen(pszRootPathName),
wfdFileData.cFileName);

hFile = CreateFile (szFindFileName,
0, // don't need to open for read or write
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, 0, NULL);
if (INVALID_HANDLE_VALUE != hFile)
{
bReturn = GetFileInformationByHandle(hFile, &bhFileInfo);
CloseHandle(hFile);

if (bReturn)
break;
}
}
}
while (FindNextFile(hFileFind, &wfdFileData));
CloseHandle (hFileFind); /* don't need the find handle anymore */

/* If we have the serial number, return it to the caller */
if (bReturn )
{
__try
{
*pdwSerialNum = bhFileInfo.dwVolumeSerialNumber;
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
SetLastError (ERROR_INVALID_PARAMETER);
bReturn = FALSE;
}
}

EXIT_DONE:
return (bReturn);
}
Status
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.


UFFF, que me salio largo... En cuanto tenga el código migrado a visual se los envío...
si a alguien se le ocurre otra ingeniosa idea no dejen de avisarme...

Saludos Amigos.