FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour SOS cual es el nombre del disco
Posts: 17
Joined: Sat Apr 07, 2007 10:20 PM
SOS cual es el nombre del disco
Posted: Fri Aug 03, 2007 11:27 PM

Estimados

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

Gracias de antemano

Marcelo

Posts: 336
Joined: Wed May 16, 2007 09:40 PM
El cDrive es la unidad de disco que necesitas la informacion
Posted: Sat Aug 04, 2007 12:10 AM

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 %

Fivewin-Xharbour 24.09, Iquique, Chile
Posts: 17
Joined: Sat Apr 07, 2007 10:20 PM
Nombre del disco
Posted: Sat Aug 04, 2007 03:42 PM

Gracias Elmo, pero me sale un error
Unresolved external _HB_FUN_TDISKINFO ..........

Posts: 234
Joined: Tue Oct 25, 2005 12:39 AM
y esto
Posted: Thu Aug 09, 2007 05:58 PM

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

Posts: 336
Joined: Wed May 16, 2007 09:40 PM
aca esta el tdiskinfo.prg
Posted: Thu Aug 09, 2007 06:29 PM

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"


Fivewin-Xharbour 24.09, Iquique, Chile
Posts: 248
Joined: Wed Jan 11, 2006 11:30 AM
SOS cual es el nombre del disco
Posted: Fri Aug 10, 2007 11:39 AM

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

aleseribeli@hotmail.com

FwH, Hb Svn, ADS 8.1, ADS 10, Pelles C, FwPPC, MsVc 2008, MsVc 2010
"Conhecimento, voc锚 n茫o subtrai quando divide; mas soma e multiplica."
**---M谩rio Persona---**
Posts: 336
Joined: Wed May 16, 2007 09:40 PM
SOS cual es el nombre del disco
Posted: Fri Aug 10, 2007 03:41 PM

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

Fivewin-Xharbour 24.09, Iquique, Chile
Posts: 248
Joined: Wed Jan 11, 2006 11:30 AM
SOS cual es el nombre del disco
Posted: Fri Aug 10, 2007 04:37 PM

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

aleseribeli@hotmail.com

FwH, Hb Svn, ADS 8.1, ADS 10, Pelles C, FwPPC, MsVc 2008, MsVc 2010
"Conhecimento, voc锚 n茫o subtrai quando divide; mas soma e multiplica."
**---M谩rio Persona---**

Continue the discussion