Ver Mensaje Individual
  #9 (permalink)  
Antiguo 27/08/2011, 10:40
Avatar de Munire
Munire
 
Fecha de Ingreso: julio-2010
Ubicación: en el ciberdespacio (España)
Mensajes: 150
Antigüedad: 13 años, 9 meses
Puntos: 4
Respuesta: Win Api y otras dudas

mira aqui tienes una lista de las funciones de la API de Windows ordenada por categorias.

http://msdn.microsoft.com/en-us/library/aa383686

de manera que si en tu programa necesitas saber por ejemplo informacion del disco duro, te vas a la categoria Disk Management y ahi ves las funciones disponibles:

GetDiskFreeSpace
Retrieves information about the specified disk, including the amount of free space on the disk.
GetDiskFreeSpaceEx
Retrieves information about the amount of space that is available on a disk volume, which is the total amount of space, the total amount of free space, and the total amount of free space available to the user that is associated with the calling thread.

a la que te interese le das y ves los argumentos. por ejemplo:


BOOL WINAPI GetDiskFreeSpaceEx(
__in_opt LPCTSTR lpDirectoryName,
__out_opt PULARGE_INTEGER lpFreeBytesAvailable,
__out_opt PULARGE_INTEGER lpTotalNumberOfBytes,
__out_opt PULARGE_INTEGER lpTotalNumberOfFreeBytes
);


para utilizarla le pasas como primer argumento el nombre del directorio. que si lees un poco

lpDirectoryName [in, optional]
A directory on the disk.

If this parameter is NULL, the function uses the root of the current disk.


si pones NULL te dara la informacion del disco duro, en vez de una carpeta.

creas variables del tipo PULARGE_INTEGER para los argumentos restantes de la funcion.

llamas a la funcion en tu programa

...
GetDiskFreeSpaceEx(..., ..., ..., ...);
...

y modificara las variables que has creado poniendo el numero total de bytes libres (en el caso de lpTotalNumberOfFreeBytes )


ahora solo queda imprimir por pantalla la variable lpTotalNumberOfFreeBytes. y ya tienes tu programa para calcular el espacio libre del disco.


no soy un experto en el tema por lo que si algo esta mal decidmelo. Mi intencion es guiarte, para que te hagas una idea de como se usa esto.