Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > C++ Builder
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 06-08-2013
giulichajari giulichajari is offline
Miembro
 
Registrado: nov 2012
Posts: 306
Poder: 12
giulichajari Va por buen camino
Post Problema con funcion

Tengo una funcion asociada a un boton y los respectivos componentes pero me da un error en la tercera linea, dice "Declaration syntax error", es en la linea

Código Delphi [-]
unsigned int Drivetype = GetDriveType(Drive.c_str ());

Código Delphi [-]
AnsiString temp;
AnsiString Drive = AnsiString(DriveComboBox1->Drive) //EditDrive->Text;
unsigned int Drivetype = GetDriveType(Drive.c_str ());
switch (drivetype)
{
case 1 : temp = “No root directory”; return;
case DRIVE_REMOVABLE : temp = “Removable”; break;
case DRIVE_FIXED : temp = “Fixed”; break;
case DRIVE_REMOTE : temp = “Remote (network) drive”; break;
case DRIVE_CDROM : temp = “CD-ROM”; break;
case DRIVE_RAMDISK : temp = “RAM disk”; break;
default: temp = “Unknown”; return;
}
LabelDriveType->Caption = temp;
temp = “”;
DWORD VolumeSerialNumber = 0;
DWORD MaximumComponentLength = 0;
DWORD FileSystemFlags = 0;
char * volumeinfo = new char[255];
volumeinfo[0] = 0;
char* FileSystemNameBuffer = new char[255];
FileSystemNameBuffer[0] = 0;
GetVolumeInformation (Drive.c_str (), volumeinfo,
CHAPTER 14 Win32 API Functional Areas 530
255, &VolumeSerialNumber,
&MaximumComponentLength, &FileSystemFlags, 
?FileSystemNameBuffer,255);
if (strlen(volumeinfo) != 0)
EditVolumeInfo->Text = volumeinfo ;
else
EditVolumeInfo->Text = “- no label -”;
//Translate integer to chars for serial number
char string1[35];
char string2[35];
if (VolumeSerialNumber > 0)
{
unsigned int bottom = (LOWORD(VolumeSerialNumber));
unsigned int top = (HIWORD(VolumeSerialNumber));
sprintf(string1,”%04X”,top);
sprintf(string2,”%04X”,bottom);
LabelSerialNum->Caption = AnsiString(string1) + “-” + AnsiString(string2);
}
else
LabelSerialNum->Caption = “- unknown -”;
if (MaximumComponentLength > 0)
LabelMaxComponentLength->Caption = AnsiString(MaximumComponentLength) + “
?characters”;
else
LabelMaxComponentLength->Caption = “- unknown -”;
if (strlen(FileSystemNameBuffer) != 0)
LabelFileSystemNameBuffer->Caption = FileSystemNameBuffer;
else
LabelFileSystemNameBuffer->Caption = “- unknown -”;
LabelFileSystemFlags->Caption = “”; //AnsiString(FileSystemFlags);
if (FileSystemFlags & FS_CASE_IS_PRESERVED)
temp += AnsiString(“Filename case is preserved.\n”);
if (FileSystemFlags & FS_CASE_SENSITIVE)
temp += AnsiString(“Lookup is case-sensitive.\n”);
if (FileSystemFlags & FS_UNICODE_STORED_ON_DISK)
temp += AnsiString(“Supports Unicode in filenames.\n”);
if (FileSystemFlags & FS_PERSISTENT_ACLS)
temp += AnsiString(“Preserves and enforces ACLs.\n”);
if (FileSystemFlags & FS_FILE_COMPRESSION)
System Services 531
LISTING 14.6 Continued
temp += AnsiString(“Supports file-based compression.\n”);
if (FileSystemFlags & FS_VOL_IS_COMPRESSED)
temp += AnsiString(“Volume is compressed. (i.e., DoubleSpace).\n”);
LabelFileSystemFlags->Caption = temp;
DWORD spc = 0; //Sectors per cluster
DWORD bps = 0; //Bytes per cluster
DWORD cluster = 0; //clusters
DWORD freeclust = 0; //freeclusters
GetDiskFreeSpace (Drive.c_str (),&spc,&bps,&freeclust,&cluster) ;
unsigned long v1 = (unsigned long)cluster;
unsigned long v2 = (unsigned long) spc;
unsigned long v3 = (unsigned long) bps;
unsigned long volsize = (v1 * v2)/1024 * v3;
LabelVolumeSize->Caption = AnsiString(FormatSize(volsize));
unsigned long free_bytes = (freeclust * spc)/1024 * bps;
LabelFreeSpace->Caption = AnsiString(FormatSize(free_bytes));
if (volsize > 0)
LabelUsed->Caption = AnsiString(((volsize - free_bytes) * 100) / volsize) +
?“ %”;
else
LabelUsed->Caption = “n/a”;
}


Al parecer es la funcion Drive.c_str la que da el problema pero no logro darme cuenta que pasa.

Muchas gracias..
Saludos
Responder Con Cita
  #2  
Antiguo 06-08-2013
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola giulichajari.

El error que mencionas se produce por la falta de un punto y coma:
Código:
...
  AnsiString Drive = AnsiString(DriveComboBox1->Drive);  // <- Aquí !!
  unsigned int DriveType = GetDriveType(Drive.c_str());
...
Pero no será el único... a golpe de vista vas a tener que revisar:
Código:
GetVolumeInformation (
  Drive.c_str (),
  volumeinfo,
  CHAPTER 14 Win32 API Functional Areas 530255, // Esto no es C++... 
  &VolumeSerialNumber,
  &MaximumComponentLength,
  &FileSystemFlags,
  ?FileSystemNameBuffer,  // "?" error
  255
);
Código:
...
  wsprintf(string1,"%04X",top);  // En lugar de sprintf  
  wsprintf(string2,"%04X",bottom); 
...
Código:
...
  if (FileSystemFlags & FS_FILE_COMPRESSION)
    System Services 531  LISTING 14.6 Continued // Esto tampoco es C++ 
...
Saludos.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....

Última edición por ecfisa fecha: 06-08-2013 a las 08:42:50.
Responder Con Cita
  #3  
Antiguo 06-08-2013
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.044
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
Me ha recordado el (fin de la cita) de Rajoy.
Responder Con Cita
  #4  
Antiguo 06-08-2013
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Cita:
Empezado por Casimiro Notevi Ver Mensaje
Me ha recordado el (fin de la cita) de Rajoy.
.

Saludos.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita
  #5  
Antiguo 07-08-2013
giulichajari giulichajari is offline
Miembro
 
Registrado: nov 2012
Posts: 306
Poder: 12
giulichajari Va por buen camino
Gracias

Gracias por responder...

Bueno ya me di cuenta que faltaba el punto y coma, y a decir verdad copie el codigo de un libro, por eso tiene el numero de pagina y un titulo que no corresponde, ademas el programa no esta identado.
Pero acabo de hacerle muchas correciones.
Una cosa : la funcion sprintf si la pude utilizar incluyendo la libreria

Código Delphi [-]
#include stdio.h

lo que no me acepta ahora es:
Código Delphi [-]
LabelVolumeSize->Caption = AnsiString(FormatSize(volsize));

porque no me toma "FormatSize", pero no se que libreria o .h incluir para que lo tome.

Saludos
Responder Con Cita
  #6  
Antiguo 08-08-2013
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola giulichajari.

Cita:
Empezado por giulichajari Ver Mensaje
Una cosa : la funcion sprintf si la pude utilizar incluyendo la libreria

Código Delphi [-]
#include stdio.h
Lo que decis es correcto, no fuí claro en ese punto. Sólo te aconsejaba el uso de wsprintf para evitar la inclusión del .h
Cita:
lo que no me acepta ahora es:
Código Delphi [-]
LabelVolumeSize->Caption = AnsiString(FormatSize(volsize));

porque no me toma "FormatSize", pero no se que libreria o .h incluir para que lo tome.
Al menos yo no conozco ninguna función de Windows o Builder C++ con ese nombre, tal vez venga en una versión posterior de Builder C++ que la que dispongo. O también podría ser una función definida por el usuario en otra parte del código.

Saludos.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
problema con funcion!! MOCOSO07 HTML, Javascript y otros 0 12-01-2009 16:39:40
Problema con una funcion Alliance Varios 5 09-10-2008 02:38:32
Problema con declaración de función vivamotos C++ Builder 1 25-04-2008 10:35:56
Problema con la funcion mail JulioGO PHP 2 26-09-2005 11:24:15
problema al llamar una función sgarrido Varios 3 27-07-2004 01:14:33


La franja horaria es GMT +2. Ahora son las 10:51:08.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi