Aus einer Datei informationen holen?



  • Hallo,

    wenn man ein Foto von der Digitalkamera auf den PC abspeichert und dann im Explorer mit der Maus über diese Datei drüber geht wird einem gezeigt wann das
    Foto aufgenommen worden ist, mit was und paar andere infos. Ist es möglich diese Information über MFC auszulesen.
    Der Hinetrgrund ist der Folgende:
    Ich möchte Dateien (fotos) umbennenen und im neuen Namen soll das Aufnahmedatum enthalten sein.

    Bedanke mich im Voraus! 🙂



  • Hier ist die Funktion mit der man das macht wenn du mit CFile arbeitest, ein blick in die MSDN hätte auch geholfen, denn hier das passende Zitat.

    Zitat

    CFile::GetStatus
    The virtual version of GetStatus retrieves the status of the open file associated with this CFile object.

    BOOL GetStatus(
       CFileStatus& rStatus 
    ) const;
    static BOOL PASCAL GetStatus(
       LPCTSTR lpszFileName,
       CFileStatus& rStatus 
    );
    

    Parameters
    rStatus
    A reference to a user-supplied CFileStatus structure that will receive the status information. The CFileStatus structure has the following fields:
    CTime m_ctime The date and time the file was created.
    CTime m_mtime The date and time the file was last modified.
    CTime m_atime The date and time the file was last accessed for reading.
    LONG m_size The logical size of the file in bytes, as reported by the DIR command.
    BYTE m_attribute The attribute byte of the file.
    char m_szFullName[_MAX_PATH] The absolute filename in the Windows character set.
    lpszFileName
    A string in the Windows character set that is the path to the desired file. The path can be relative or absolute, or it can contain a network name.
    Return Value
    TRUE if the status information for the specified file is successfully obtained; otherwise, FALSE.

    Remarks
    It does not insert a value into the m_szFullName structure member.

    The static version gets the status of the named file and copies the filename to m_szFullName. This function obtains the file status from the directory entry without actually opening the file. It is useful for testing the existence and access rights of a file.

    The m_attribute is the file attribute. The Microsoft Foundation classes provide an enum type attribute so that you can specify attributes symbolically:

    enum Attribute {
       normal =    0x00,
       readOnly =  0x01,
       hidden =    0x02,
       system =    0x04,
       volume =    0x08,
       directory = 0x10,
       archive =   0x20
       };
    

    Example

    //example for CFile::GetStatus
    CFileStatus status;
    extern CFile cfile;
    if( cfile.GetStatus( status ) )    // virtual member function
       {
          #ifdef _DEBUG
             afxDump << "File size = " << status.m_size << "\n";
          #endif
       }
    char* pFileName = "test.dat";
    if( CFile::GetStatus( pFileName, status ) )   // static function
       {
          #ifdef _DEBUG
             afxDump << "Full file name = " << status.m_szFullName << "\n";
          #endif
       }
    

    🤡 🤡 😉 🤡 🤡 😮 🤡 🤡

    Devil™



  • Hallo (D)Evil,

    danke für die Antwort aber das ist es nicht wonach ich suche.
    Das "CTime m_ctime The date and time the file was created" gibt mir das
    Datum von dem Tag wo ich es auf dem rechner von der kamera gedownloaded habe,
    nicht das Datum wan das Foto Aufgenommen worden ist. Und das wird wenn ich im Explorer mit der Maus drüber gehe angezeigt.
    Hast du vielleicht noch'ne Idee?

    Danke! 🙂



  • DAs kann aber irgendwie nicht sein, das er Explorer nen anderes Datum anzeigt, da es sich dabei ja um das erstellungs Datum handelt, da er ja nicht wissen kann wann das Foto geschoßen wurde!

    Guck mal bei CFile in der MSDN Bibliothek.



  • Hallo bbatec,

    das CFile wird dir nicht weiterhelfen, weil die Infos, die der Explorer anzeigt die EXIF-Metadaten sind, also Daten, die der Photoapparat mit in die Datei geschrieben hat.
    Und an die zu kommen, ist etwas aufwändiger. Es geht z.B. mit gdiplus. Such' auf www.codeguru.com oder www.codeproject.com einfach mal nach "EXIF"



  • Danke Uwe für den Tip! 🙂
    Bin auch fundig geworden "Cexif" heisst es. Falls es jemand braucht. Die Klasse
    zeigt alle Infos die mit dem Foto gespeichert sind, z.Bsp. Auflösung, Datum der Fotoerstellung usw.


Anmelden zum Antworten