Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Extraer el número de rie de un disco

1 view
Skip to first unread message

Mundivia

unread,
Oct 22, 2001, 8:53:55 AM10/22/01
to
Necesito extraer el número de serie de un disquete. Estoy intentándolo con
la instrucción siguiente:

AnsiString cUnidad = UpperCase(DriveComboBox1->Drive) + ":\\";
char cLabel[12];
unsigned long *nSerie;

memset(cLabel, '\0', 12);
GetVolumeInformation(cUnidad.c_str(), NULL, NULL, nSerie, NULL, NULL, NULL,
NULL);

pero al tratar de pasar nSerie a una variable tipo char (cLabel) mediante el
comando sprintf no logro el valor correcto que estoy viendo con el comando
VOL de MS-DOS. ¿Puede alguien sugerirme cómo obtener el resultado deseado?

--
Un saludo.
--------------------------------------
Ángel Matilla Candás - Toledo - España
ICQ: 14388338
*****************************************
http://www.internautas.org/
http://groups.icq.com/Internet/group.asp?no=1509237


Christophe Brun

unread,
Oct 24, 2001, 4:04:07 PM10/24/01
to
A lo menos me parece que aqui falta une alocacion para nSerie.
Quizas sera mejor asi :

AnsiString cUnidad = UpperCase(DriveComboBox1->Drive) + ":\\";
char cLabel[12];

unsigned long nSerie;

memset(cLabel, '\0', 12);
GetVolumeInformation(cUnidad.c_str(), NULL, NULL, &nSerie, NULL, NULL, NULL,
NULL);


Angelito

unread,
Oct 26, 2001, 8:32:07 AM10/26/01
to
Gracias Christophe. Ese ha sido el cámino. Efectivamente, me faltaba alocar
nSerie. Luego he tenido que convertirlo a hexadecimal porque tenía que
comparar con un fichero ASCII precargado que traía los números como en el
comando VOL de MS-DOS.

Por si os vale, la rutina me ha quedado así:

unsigned long nSerie;


AnsiString cUnidad = UpperCase(DriveComboBox1->Drive) + ":\\";

AnsiString cLabel = "";
int nResto;
char cHexa[16][2] =
{"0\0","1\0","2\0","3\0","4\0","5\0","6\0","7\0","8\0","9\0","A\0","B\0","C\
0","D\0","E\0","F\0"};

GetVolumeInformation(cUnidad.c_str(), NULL, NULL, &nSerie, NULL, NULL, NULL,
NULL);

while (nSerie > 1)
{
nResto = nSerie % 16;
cLabel = AnsiString(cHexa[nResto]) + cLabel;
nSerie = INT(nSerie / 16);
}

Al terminar el bucle en cLabel está al valor que se obtendría con VOL.

0 new messages