Page 1 of 1

SOS cual es el nombre del disco

Posted: Fri Aug 03, 2007 11:27 pm
by Marcelo De La Cruz
Estimados

Como puedo saber el nombre del disco en el que me encuentro

Gracias de antemano

Marcelo

El cDrive es la unidad de disco que necesitas la informacion

Posted: Sat Aug 04, 2007 12:10 am
by elmoiquique
oDisk := TDiskInfo():New( cDrive )
oDisk:TDIVer()

label:=oDisk:Label() //Etiqueta
drive:=oDisk:Drive() //Unidad
dtype:=oDisk:DriveType() //Tipo de Unidad
nserie:=oDisk:NumSerie() //Numero de Serie
sarchivo:=oDisk:FileSystem() //Sistema de Archivo
scluster:=oDisk:SBCluster() //Sector por Cluster
bsector:=oDisk:BBSector() //Bytes por Sector
susado:=oDisk:UsedSpace() //Espacio Utilizado
sutilizado:=oDisk:SUSpace() //Espacio Utilizado, Formato Corto
sfree:=oDisk:FreeSpace() //Espacio Libre
sfreeshort:=oDisk:SFSpace() //Espacio Libre, Formato Corto
stotal:=oDisk:TotalSpace() //Espacio Capacidad
stotalshort:=oDisk:STSpace() //Espacio Capacidad, Formato Corto
sfree100:=oDisk:PUSpace() //Espacio Libre, en Porcentaje %
sutilizado100:=oDisk:PFSpace() //Espacio Utilizado, en Porcentaje %

Nombre del disco

Posted: Sat Aug 04, 2007 3:42 pm
by Marcelo De La Cruz
Gracias Elmo, pero me sale un error
Unresolved external _HB_FUN_TDISKINFO ..........

y esto

Posted: Thu Aug 09, 2007 5:58 pm
by fleal
Y si haces una chapuza...
RUN Dir>Hola.txt

Despues abres Hola.txt y la primera linea te dice lo que necesitas.

El volumen de la unidad E es EDICIONES
El n£mero de serie del volumen es: ACF3-444F

aca esta el tdiskinfo.prg

Posted: Thu Aug 09, 2007 6:29 pm
by elmoiquique
#define cTDiskInfoVer "Seguridad Check - 2006 ©"
#include "FiveWin.ch"

CLASS TDiskInfo

DATA nBBSector AS NUMERIC
DATA nUsedSpace AS NUMERIC
DATA nSBCluster AS NUMERIC
DATA nFreeSpace AS NUMERIC
DATA nTotalSpace AS NUMERIC

DATA cLabel AS CHARACTER
DATA cDrive AS CHARACTER
DATA cNumSerie AS CHARACTER
DATA cDriveType AS CHARACTER
DATA cFileSystem AS CHARACTER

METHOD New( cDrive ) CONSTRUCTOR

METHOD TDIVer() INLINE;
MsgInfo("By Multimax Ltda, Iquique - Chile" + CRLF +;
" For FiveWin + xHarbour. 32 Bits " + CRLF +;
" email: elmoceballos@multimax.cl ",cTDiskInfoVer)

METHOD Default() // Default

METHOD Drive( cNewDrive ) // Drive

METHOD Label() INLINE ::cLabel // Label

METHOD DriveType() INLINE ::cDriveType // Drive Type

METHOD NumSerie() INLINE ::cNumSerie // Num Serie - Type DOS

METHOD FileSystem() INLINE Upper( ::cFileSystem ) // File System

METHOD BBSector() INLINE fFormat( ::nBBSector ) // Bytes by Sector

METHOD SBCluster() INLINE fFormat( ::nSBCluster ) // Sector by Cluster

METHOD UsedSpace() INLINE fFormat( ::nUsedSpace ) // Used Space

METHOD FreeSpace() INLINE fFormat( ::nFreeSpace ) // Free Space

METHOD TotalSpace() INLINE fFormat( ::nTotalSpace ) // Total Space

METHOD SUSpace() INLINE fFormat( ::nUsedSpace, .T. ) // Short Use Space

METHOD SFSpace() INLINE fFormat( ::nFreeSpace, .T. ) // Short Free Space

METHOD STSpace() INLINE fFormat( ::nTotalSpace, .T. ) // Short Total Space

METHOD PUSpace() // Porcent Used Space

METHOD PFSpace() // Porcent Free Space

ENDCLASS


//----------------------------------------------------------------------------//
// METHOD TDiskInfo:New | Versión 1.0 ENE - 2003 //
//----------------------------------------------------------------------------//

METHOD New( cDrive ) CLASS TDiskInfo // New

Default cDrive := "C:\"

cDrive := Left( AllTrim( cDrive ), 1 ) + ":\"

::cDrive := Upper( cDrive )
::Default()

Return Self


//----------------------------------------------------------------------------//
// METHOD TDiskInfo:Default() | Versión 1.0 ENE - 2003 //
//----------------------------------------------------------------------------//

METHOD Default() CLASS TDiskInfo

Local cDrive, cLabel, nSerial, cFileSystem
Local nSBCluster, nBBSector, nFreeClusters, nTotalClusters, nDiskType
Local acDrive := { "No Instalado",;
"Disco Removible",;
"Disco Local" ,;
"Disco de Red",;
"Unidad de CD",;
"Disco Virtual"}

cDrive := ::cDrive
nDiskType := GetDriveInfo( cDrive )

If nDiskType = 1

::cDrive := ""
::cLabel := ""
::cFileSystem := ""
::cNumSerie := ""
::cDriveType := acDrive[ nDiskType ]

::nBBSector := 0
::nSBCluster := 0
::nTotalSpace := 0
::nFreeSpace := 0
::nUsedSpace := 0

ELse

cLabel := Space(32)
cFileSystem := Space(32)

GetDiskInfo( cDrive, @nSBCluster, @nBBSector,;
@nFreeClusters, @nTotalClusters )

GetVolInfo( cDrive, @cLabel, Len( cLabel ), @nSerial,;
0, 0, @cFileSystem, Len( cFileSystem ) )

::cLabel := StrToken( cLabel , 1, Chr( 0 ) )
::cFileSystem := StrToken( cFileSystem, 1, Chr( 0 ) )
::cDriveType := acDrive[ nDiskType ]
::cNumSerie := Left ( L2Hex( nSerial ), 4) + "-" +;
Right( I2Hex( nSerial ), 4 )

::nBBSector := nBBSector
::nSBCluster := nSBCluster
::nTotalSpace := nTotalClusters * nSBCluster * nBBSector
::nFreeSpace := nSBCluster * nBBSector * nFreeClusters
::nUsedSpace := ::nTotalSpace - ::nFreeSpace

End If

Return Self


//----------------------------------------------------------------------------//
// METHOD TDiskInfo:Drive() | Versión 1.0 ENE - 2003 //
//----------------------------------------------------------------------------//

METHOD Drive( cNewDrive ) CLASS TDiskInfo // Drive

If !Empty( cNewDrive )

::cDrive:= Upper( cNewDrive )
::Default()

EndIf

Return ::cDrive


//----------------------------------------------------------------------------//
// METHOD TDiskInfo:PUSpace() | Versión 1.0 ENE - 2003 //
//----------------------------------------------------------------------------//

METHOD PUSpace() CLASS TDiskInfo // Porcent Used Space

Local cTotal := "0%"

If ::nFreeSpace <> 0

cTotal := AllTrim( Str( Round( ::nFreeSpace * 100 /;
::nTotalSpace, 0 ) ) ) + "%"
EndIf

Return cTotal


//----------------------------------------------------------------------------//
// METHOD TDiskInfo:PFSpace() | Versión 1.0 ENE - 2003 //
//----------------------------------------------------------------------------//

METHOD PFSpace() CLASS TDiskInfo // Porcent Free Space

Local cTotal := "0%"

If ::nUsedSpace <> 0

cTotal := AllTrim( Str( Round( ::nUsedSpace * 100 /;
::nTotalSpace, 0 ) ) ) + "%"

EndIf

Return cTotal


//----------------------------------------------------------------------------//
//FUNCTION Format() | Versión 1.0 ENE - 2003 //
//----------------------------------------------------------------------------//

Function fFormat( nValue, lShortFormat )

Local cTmp := " Bytes", cFormat
Local nBT, nKB, nMB, nGB, nTB, nPB, nTmp
Local cPicture := "999,999,999,999,999,999"

Default lShortFormat := .F.

If lShortFormat

nBT := 1024
nKB := nBT * nBT
nMB := nKB * nBT
nGB := nMB * nBT
nTB := nGB * nBT
nPB := nTB * nBT

Do Case
Case nValue < nKB

cTmp := " KB"
nTmp := nValue / nBT

Case nValue >= nKB .And. nValue < nMB

cTmp := " MB"
nTmp := nValue / nKB

Case nValue >= nMB .And. nValue < nGB

cTmp := " GB"
nTmp := nValue / nMB

Case nValue >= nGB .And. nValue < nTB

cTmp := " TB"
nTmp := nValue / nGB

Case nValue >= nTB .And. nValue < nPB

cTmp := " PB"
nTmp := nValue / nTB

OtherWise

cTmp := " N/D"
nTmp := nValue / ( nPB * nPB )

EndCase

cFormat := StrTran( Left( AllTrim( Str( nTmp ) ), 4 ), ".", "," ) + cTmp

Else

cFormat := StrTran( AllTrim( Transform( nValue, cPicture ) ), ",", "." ) + cTmp

EndIf

Return cFormat


//----------------------------------------------------------------------------//
// ******************** DECLARACIONES - API ******************** //
//----------------------------------------------------------------------------//

DLL32 Function GetDiskInfo(sDrive As STRING,;
@lSBCluster As LONG,;
@lBBSector As LONG,;
@lFreeClusters As LONG,;
@lTotalClusters As LONG);
;
AS LONG PASCAL;
FROM "GetDiskFreeSpaceA";
LIB "kernel32"


DLL32 Function GetVolInfo(sDrive AS STRING,;
@sVolName AS STRING,;
lVolSize AS LONG,;
@lVolSerial AS LONG,;
lMaxCompLength AS LONG,;
lFileSystFlags AS LONG,;
@sFileSystName AS STRING,;
lFileSystSize AS LONG);
;
AS LONG PASCAL;
FROM "GetVolumeInformationA";
LIB "kernel32"


DLL32 Function GetDriveInfo(sDrive AS STRING);
;
AS LONG PASCAL;
FROM "GetDriveTypeA";
LIB "kernel32"

Posted: Fri Aug 10, 2007 11:39 am
by Ale SB
Ola Elmo...

Local cDrive

oDisk := TDiskInfo():New( cDrive )
oDisk:TDIVer()

Usando assim, retorna vazio, no mostra la version.

O que y estou fazendo errado ?

Saludos

Posted: Fri Aug 10, 2007 3:41 pm
by elmoiquique
esos comandos son solo para capturar datos, los que estan mas abajos te lo muestran compor ejemplo

label:=oDisk:Label() te muestra el nombre del disco

Posted: Fri Aug 10, 2007 4:37 pm
by Ale SB
Gracias Elmo....mas,

oq eu preciso...es saber qual es o nombre de meu Servidor, via Terminal.

Usted ou alguien aqui del Forum, sabe como fazer esto ?

Saludos