Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 31-05-2007
Avatar de lookmydoom
lookmydoom lookmydoom is offline
Miembro
 
Registrado: abr 2006
Posts: 102
Poder: 19
lookmydoom Va por buen camino
Question leer las propiedades de los archivos

Buenas, tengo un problemita y es que no se como podria obtener los detalles de un archio X por ejemplo, un archivo .doc, cuando le dan clic derecho a uno archivo .doc y la parte de propiedades hay una pestaña que dice "Resumen", ahi estan todos los detalles de dicho archivo como ser Titulo, Asunto, Categoria, Palabra Clave, Autor, Fecha de creacion, Fecha de modificacion, etc. me gustaria saber como podria leer dichas propiedades de los archivos.
Responder Con Cita
  #2  
Antiguo 02-06-2007
Avatar de lookmydoom
lookmydoom lookmydoom is offline
Miembro
 
Registrado: abr 2006
Posts: 102
Poder: 19
lookmydoom Va por buen camino
Bueno ya veo por que nadie me responde, no pence que algo que devuelve un resultado tan simple podria ser tan complicado de hacer, de todas formas estube buscando una solucion por todos lados y termine encontrando este codigo:
Código Delphi [-]
function IsNTFS(AFileName : string) : boolean;
    var
    fso, drv : OleVariant;
    begin
    IsNTFS := False;
    fso := CreateOleObject('Scripting.FileSystemObject');
    drv := fso.GetDrive(fso.GetDriveName(AFileName));
    if drv.FileSystem = 'NTFS' then
    IsNTFS := True;
    end;

function StgOpenStorageEx (
    const pwcsName : POleStr; //Pointer to the path of the
    //file containing storage object
    grfMode : LongInt; //Specifies the access mode for the object
    stgfmt : DWORD; //Specifies the storage file format
    grfAttrs : DWORD; //Reserved; must be zero
    pStgOptions : Pointer; //Address of STGOPTIONS pointer
    reserved2 : Pointer; //Reserved; must be zero
    riid : PGUID; //Specifies the GUID of the interface pointer
    out stgOpen : //Address of an interface pointer
    IStorage ) : HResult; stdcall; external 'ole32.dll';

function GetFileSummaryInfo(const FileName: WideString): String;
    const
    FmtID_SummaryInformation: TGUID = '{F29F85E0-4FF9-1068-AB91-08002B27B3D9}';
    FMTID_DocSummaryInformation : TGUID = '{D5CDD502-2E9C-101B-9397-08002B2CF9AE}';
    FMTID_UserDefinedProperties : TGUID = '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}';
    IID_IPropertySetStorage : TGUID = '{0000013A-0000-0000-C000-000000000046}';
    const
    STGFMT_FILE = 3; //Indicates that the file must not be a compound file.
    //This element is only valid when using the StgCreateStorageEx
    //or StgOpenStorageEx functions to access the NTFS file system
    //implementation of the IPropertySetStorage interface.
    //Therefore, these functions return an error if the riid
    //parameter does not specify the IPropertySetStorage interface,
    //or if the specified file is not located on an NTFS file system volume.
    STGFMT_ANY = 4; //Indicates that the system will determine the file type and
    //use the appropriate structured storage or property set
    //implementation.
    //This value cannot be used with the StgCreateStorageEx function.
    // Summary Information
    PID_TITLE = 2;
    PID_SUBJECT = 3;
    PID_AUTHOR = 4;
    PID_KEYWORDS = 5;
    PID_COMMENTS = 6;
    PID_TEMPLATE = 7;
    PID_LASTAUTHOR = 8;
    PID_REVNUMBER = 9;
    PID_EDITTIME = 10;
    PID_LASTPRINTED = 11;
    PID_CREATE_DTM = 12;
    PID_LASTSAVE_DTM = 13;
    PID_PAGECOUNT = 14;
    PID_WORDCOUNT = 15;
    PID_CHARCOUNT = 16;
    PID_THUMBNAIL = 17;
    PID_APPNAME = 18;
    PID_SECURITY = 19;
    // Document Summary Information
    PID_CATEGORY = 2;
    PID_PRESFORMAT = 3;
    PID_BYTECOUNT = 4;
    PID_LINECOUNT = 5;
    PID_PARCOUNT = 6;
    PID_SLIDECOUNT = 7;
    PID_NOTECOUNT = 8;
    PID_HIDDENCOUNT = 9;
    PID_MMCLIPCOUNT = 10;
    PID_SCALE = 11;
    PID_HEADINGPAIR = 12;
    PID_DOCPARTS = 13;
    PID_MANAGER = 14;
    PID_COMPANY = 15;
    PID_LINKSDIRTY = 16;
    PID_CHARCOUNT2 = 17;
    var
    I: Integer;
    PropSetStg: IPropertySetStorage;
    PropSpec: array of TPropSpec;
    PropStg: IPropertyStorage;
    PropVariant: array of TPropVariant;
    Rslt: HResult;
    S: String;
    Stg: IStorage;
    PropEnum: IEnumSTATPROPSTG;
    HR : HResult;
    PropStat: STATPROPSTG;
    k : integer;
    

function PropertyPIDToCaption(const ePID: Cardinal): string;
    begin
    case ePID of
    PID_TITLE:
    Result := 'Title';
    PID_SUBJECT:
    Result := 'Subject';
    PID_AUTHOR:
    Result := 'Author';
    PID_KEYWORDS:
    Result := 'Keywords';
    PID_COMMENTS:
    Result := 'Comments';
    PID_TEMPLATE:
    Result := 'Template';
    PID_LASTAUTHOR:
    Result := 'Last Saved By';
    PID_REVNUMBER:
    Result := 'Revision Number';
    PID_EDITTIME:
    Result := 'Total Editing Time';
    PID_LASTPRINTED:
    Result := 'Last Printed';
    PID_CREATE_DTM:
    Result := 'Create Time/Date';
    PID_LASTSAVE_DTM:
    Result := 'Last Saved Time/Date';
    PID_PAGECOUNT:
    Result := 'Number of Pages';
    PID_WORDCOUNT:
    Result := 'Number of Words';
    PID_CHARCOUNT:
    Result := 'Number of Characters';
    PID_THUMBNAIL:
    Result := 'Thumbnail';
    PID_APPNAME:
    Result := 'Creating Application';
    PID_SECURITY:
    Result := 'Security';
    else
    Result := '$' + IntToHex(ePID, 8);
    end
    end;
    begin
    Result := '';
    try
    OleCheck(StgOpenStorageEx(PWideChar(FileName),
    STGM_READ or STGM_SHARE_DENY_WRITE,
    STGFMT_FILE,
    0, nil, nil, @IID_IPropertySetStorage, stg));
    PropSetStg := Stg as IPropertySetStorage;
    OleCheck(PropSetStg.Open(FmtID_SummaryInformation,
    STGM_READ or STGM_SHARE_EXCLUSIVE, PropStg));
    OleCheck(PropStg.Enum(PropEnum));
    I := 0;
    hr := PropEnum.Next(1, PropStat, nil);
    while hr = S_OK do
    begin
    inc(I);
    SetLength(PropSpec,I);
    PropSpec[i-1].ulKind := PRSPEC_PROPID;
    PropSpec[i-1].propid := PropStat.propid;
    hr := PropEnum.Next(1, PropStat, nil);
    end;
    SetLength(PropVariant,i);
    Rslt := PropStg.ReadMultiple(i, @PropSpec[0], @PropVariant[0]);
    if Rslt = S_FALSE then Exit;
    for k := 0 to i -1 do
    begin
    S := '';
    if PropVariant[k].vt = VT_LPSTR then
    if Assigned(PropVariant[k].pszVal) then
    S := PropVariant[k].pszVal;
    S := Format(PropertyPIDToCaption(PropSpec[k].Propid)+ ' %s',[s]);
    if S <> '' then Result := Result + S + #13;
    end;
    finally
    end;
    end;
Ahora lo rraro es que me produce un error de EOleSysError generado por la funcion que se encuentra en la dll, el codigo original lo encontre aqui y la descripcion de la funcion que produce el error esta aqui, espero que alguien le de una revisada y pueda ayudarme.

Última edición por lookmydoom fecha: 02-06-2007 a las 08:35:39.
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
Leer archivos RDF OscarGarcia Internet 1 12-05-2007 16:03:10
Leer archivos DXF chux Gráficos 1 25-05-2006 18:01:50
Leer Archivos Rar lucasarts_18 Varios 3 01-07-2005 18:59:27
Propiedades de archivos pborges36 API de Windows 1 14-10-2004 16:54:26
propiedades de archivos TheBearWhite Varios 0 16-06-2004 18:00:18


La franja horaria es GMT +2. Ahora son las 01:26:54.


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