IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 Delphi Discussion :

Date de création d'une photo


Sujet :

Delphi

  1. #61
    Modérateur
    Avatar de tourlourou
    Homme Profil pro
    Biologiste ; Progr(amateur)
    Inscrit en
    Mars 2005
    Messages
    3 858
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Biologiste ; Progr(amateur)

    Informations forums :
    Inscription : Mars 2005
    Messages : 3 858
    Points : 11 301
    Points
    11 301
    Billets dans le blog
    6
    Par défaut
    cette photo test m'a permis de corriger le cas où la longueur des données est impaire, où un #0 est ajouté en fin de segment APP13 pour garder l'alignement sur les mots :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
        // longueur données qui suivent
        Card:=SwapEndian(AStream.ReadDWord);
        if Odd(Card) then Inc(Card); // ligne à ajouter pour gérer le cas
        if AStream.Position+Card<>FinApp13 then Exit; // discordance données de longueur
    Delphi 5 Pro - Delphi 11.3 Alexandria Community Edition - CodeTyphon 6.90 sous Windows 10 ; CT 6.40 sous Ubuntu 18.04 (VM)
    . Ignorer la FAQ Delphi et les Cours et Tutoriels Delphi nuit gravement à notre code !

  2. #62
    Nouveau Candidat au Club
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    118
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2008
    Messages : 118
    Points : 0
    Points
    0
    Par défaut ne marche pas
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    SwapEndian(AStream.ReadDWord);
    2 identificateurs non déclarés
    swapendian
    et
    readdword

  3. #63
    Modérateur
    Avatar de tourlourou
    Homme Profil pro
    Biologiste ; Progr(amateur)
    Inscrit en
    Mars 2005
    Messages
    3 858
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Biologiste ; Progr(amateur)

    Informations forums :
    Inscription : Mars 2005
    Messages : 3 858
    Points : 11 301
    Points
    11 301
    Billets dans le blog
    6
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
        // longueur données qui suivent
        AStream.Read(Card, 4);
        Card:=Swap32(Card);
        if Odd(Card) then Inc(Card); // ligne à ajouter pour gérer le cas
        if AStream.Position+Card<>FinApp13 then Exit; // discordance données de longueur
    Si je me souviens bien, face à ce problème d'adaptation lazarus vers delphi, la solution a été proposée il y a quelques posts. La ligne en question sert à lire un entier non signé de 4 octets à partir d'un TStream et à inverser l'ordre des octets. Il ne devrait pas y avoir de problème d'interprétation.

    Donc soit tu as la mémoire courte, soit tu ne comprends rien, ce qui n'est pas forcément un défaut incurable.

    Ce serait ne pas chercher à comprendre qui serait coupable, et malheureusement, c'est cette impression - peut être fausse, je te prie de m'en excuser - que je ressens.
    Delphi 5 Pro - Delphi 11.3 Alexandria Community Edition - CodeTyphon 6.90 sous Windows 10 ; CT 6.40 sous Ubuntu 18.04 (VM)
    . Ignorer la FAQ Delphi et les Cours et Tutoriels Delphi nuit gravement à notre code !

  4. #64
    Nouveau Candidat au Club
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    118
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2008
    Messages : 118
    Points : 0
    Points
    0
    Par défaut suite
    J'ai, en effet, du mal à comprendre car:
    par exemple cette photo
    http://justjared.buzznet.com/photo-g...ils-double-04/
    a pour date de création

    - par ton logiciel :2011
    -par XnView :2011
    -par Windows 7 : 2001
    -par PhotoME: 2001
    etc....

  5. #65
    Nouveau Candidat au Club
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    118
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2008
    Messages : 118
    Points : 0
    Points
    0
    Par défaut suite
    Si seulement je pouvais capturer en D6 la date de la photo affichée par l'explorateur de windows 7 ! Est-ce possible par shellapi ?

  6. #66
    Expert éminent sénior
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    13 459
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 13 459
    Points : 24 873
    Points
    24 873
    Par défaut
    Tu as vraiment la mémoire courte !
    Si tu veux utiliser le comportement de Windows 7, il faut utiliser l'interface IWICMetadataQueryReader fourni par la DLL WindowsCodecs.dll

    Sur mon XP (SP3), sur la photo du nouveau Conan, c'est 02/02/2001 18:57 mais un Copyright de 2011
    Mais en réalité, je pense que la Date est FAUSSE (mal encodée où que sais-je)
    L'image date de 20/06/2011 !
    Comment prendre une photo en 2001 sur un film qui n'est sorti 29 juillet 2011 !
    Tu veux volontairement une valeur fausse alors que depuis plusieurs sujets, tu as les algos pour la bonne valeur ! n'est-ce pas idiot !

    Il faudrait utiliser des images avec des données FIABLES et prévisibles !
    Par exemple des images prises avec TON appareil photo !
    Aide via F1 - FAQ - Guide du développeur Delphi devant un problème - Pensez-y !
    Attention Troll Méchant !
    "Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson" Confucius
    Mieux vaut se taire et paraître idiot, Que l'ouvrir et de le confirmer !
    L'ignorance n'excuse pas la médiocrité !

    L'expérience, c'est le nom que chacun donne à ses erreurs. (Oscar Wilde)
    Il faut avoir le courage de se tromper et d'apprendre de ses erreurs

  7. #67
    Modérateur
    Avatar de tourlourou
    Homme Profil pro
    Biologiste ; Progr(amateur)
    Inscrit en
    Mars 2005
    Messages
    3 858
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Biologiste ; Progr(amateur)

    Informations forums :
    Inscription : Mars 2005
    Messages : 3 858
    Points : 11 301
    Points
    11 301
    Billets dans le blog
    6
    Par défaut
    @Shaï : +1 ; un troll, mais pas de lézard : Exif dit 02.02.2001 et IPTC 20.06.2011 ! (vu sous XnView)

    donc Windows donne la priorité aux infos Exif, ce qui est logique : un cliché au format Exif peut avoir d'autres segments application, mais qui devraient être ignorés par les décodeurs (cf norme Exif)

    après, la fiabilité des données, c'est le boulot de la source : le décodeur doit juste restituer fidèlement celles inscrites...
    Delphi 5 Pro - Delphi 11.3 Alexandria Community Edition - CodeTyphon 6.90 sous Windows 10 ; CT 6.40 sous Ubuntu 18.04 (VM)
    . Ignorer la FAQ Delphi et les Cours et Tutoriels Delphi nuit gravement à notre code !

  8. #68
    Nouveau Candidat au Club
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    118
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2008
    Messages : 118
    Points : 0
    Points
    0
    Par défaut suite
    "il faut utiliser l'interface IWICMetadataQueryReader fourni par la DLL WindowsCodecs.dll"
    Incompréhensible pour la majorité
    Merci pour vos nombreuses explications
    a+

  9. #69
    Expert éminent sénior
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    13 459
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 13 459
    Points : 24 873
    Points
    24 873
    Par défaut
    Toulouru confirme avec XnView

    mecyber25, tu as donc ta solution, ton programme doit afficher toutes les Metadata existantes !
    Impossible de deviner laquelle est la plus pertinente !
    Tu dois donc intégrer EXIF et IPTC en même temps, et afficher tout ce qui est disponible, ton utilisateur fera le tri !

    Pour l'interface IWICMetadataQueryReader, c'est une interface entièrement documenté dans la MSDN avec des exemples complets !
    C'est un objet intégré à l'OS,
    Je ne vois pas ce qu'il y a d'Incompréhensible, l'utilisation des Interfaces dans les API Microsoft est un classique, en plus tu parlais des ShellAPI, c'est drôle mais c'est justement dans le Shell qu'il y a le plus d'interface comme IShellIcon, IShellLink, IShellFolder ... en plus, tu n'es pas la majorité !
    Et puis même si la majorité ne sait pas, ce n'est pas une excuse pour ne pas chercher à savoir !

    Et cela répond exactement à ta question "utiliser le comportement de Windows 7", si tu n'es pas content de la réponse, ben cherches-en une autre !

    Il te reste tous les codes fournis pour lire les deux meta EXIF et IPTC, tu dois pouvoir nous concocter une fonction qui lit les deux !
    Aide via F1 - FAQ - Guide du développeur Delphi devant un problème - Pensez-y !
    Attention Troll Méchant !
    "Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson" Confucius
    Mieux vaut se taire et paraître idiot, Que l'ouvrir et de le confirmer !
    L'ignorance n'excuse pas la médiocrité !

    L'expérience, c'est le nom que chacun donne à ses erreurs. (Oscar Wilde)
    Il faut avoir le courage de se tromper et d'apprendre de ses erreurs

  10. #70
    Membre expérimenté
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    2 426
    Détails du profil
    Informations personnelles :
    Âge : 71
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 2 426
    Points : 1 326
    Points
    1 326
    Par défaut
    Bonjour à toutes et à tous,

    J'ai souvent constaté qu'avec les appareils numériques, la date ou l'heure n'était pratiquement jamais remise en temps réels après une batterie morte ou déchargée.

    Le propriétaire de l'appareil photo ne remet pas toujours ces données à jour.

    Ce qui explique bien des choses au sujet de la date de prise de vue.

    Comme déjà dit, les photos proposées ne contiennent pas de données Exif.

    Petite démo en D6 pour les photos contenant des données Exif et qui fonctionne sous Seven 64bits.

    Sinon il y a aussi cet Api (non testée !) :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
     
    unit storage;
     
    interface  
     
    uses  
      Windows, ComObj, ActiveX, SysUtils;
     
    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}';  
      FMTID_AudioSummaryInformation     : TGuid =  
        '{64440490-4C8B-11D1-8B70-080036B11A03}';  
      FMTID_VideoSummaryInformation     : TGUID =  
        '{64440491-4C8B-11D1-8B70-080036B11A03}';  
      FMTID_ImageSummaryInformation     : TGUID =  
        '{6444048f-4c8b-11d1-8b70-080036b11a03}';  
      FMTID_MediaFileSummaryInformation : TGUID =  
        '{64440492-4c8b-11d1-8b70-080036b11a03}';  
     
      STGFMT_STORAGE     = 0;  
      STGFMT_FILE        = 3;  
      STGFMT_ANY         = 4;
      STGFMT_DOCFILE     = 5;
     
      // Summary Information  
      PIDSI_TITLE        = $00000002;     // VT_LPSTR  
      PIDSI_SUBJECT      = $00000003;  
      PIDSI_AUTHOR       = $00000004;  
      PIDSI_KEYWORDS     = $00000005;  
      PIDSI_COMMENTS     = $00000006;  
      PIDSI_TEMPLATE     = $00000007;  
      PIDSI_LASTAUTHOR   = $00000008;  
      PIDSI_REVNUMBER    = $00000009;  
      PIDSI_EDITTIME     = $0000000A;     // VT_FILETIME (UTC)  
      PIDSI_LASTPRINTED  = $0000000B;  
      PIDSI_CREATE_DTM   = $0000000C;  
      PIDSI_LASTSAVE_DTM = $0000000D;  
      PIDSI_PAGECOUNT    = $0000000E;     // VT_I4  
      PIDSI_WORDCOUNT    = $0000000F;  
      PIDSI_CHARCOUNT    = $00000010;  
      PIDSI_THUMBNAIL    = $00000011;     // VT_CF  
      PIDSI_APPNAME      = $00000012;     // VT_LPSTR  
      PIDSI_DOC_SECURITY = $00000013;     // VT_I4  
     
      // Document Summary Information  
      PIDDSI_CATEGORY    = $00000002;     // VT_LPSTR  
      PIDDSI_PRESFORMAT  = $00000003;  
      PIDDSI_BYTECOUNT   = $00000004;     // VT_I4  
      PIDDSI_LINECOUNT   = $00000005;  
      PIDDSI_PARCOUNT    = $00000006;  
      PIDDSI_SLIDECOUNT  = $00000007;  
      PIDDSI_NOTECOUNT   = $00000008;  
      PIDDSI_HIDDENCOUNT = $00000009;  
      PIDDSI_MMCLIPCOUNT = $0000000A;  
      PIDDSI_SCALE       = $0000000B;     // VT_BOOL  
      PIDDSI_HEADINGPAIR = $0000000C;     // VT_VARIANT | VT_VECTOR  
      PIDDSI_DOCPARTS    = $0000000D;     // VT_LPSTR | VT_VECTOR  
      PIDDSI_MANAGER     = $0000000E;     // VT_LPSTR  
      PIDDSI_COMPANY     = $0000000F;  
      PIDDSI_LINKSDIRTY  = $00000010;     // VT_BOOL  
     
      // FMTID_MediaFileSummaryInfo  
      PIDMSI_EDITOR      = $00000002;     // VT_LPWSTR  
      PIDMSI_SUPPLIER    = $00000003;  
      PIDMSI_SOURCE      = $00000004;  
      PIDMSI_SEQUENCE_NO = $00000005;  
      PIDMSI_PROJECT     = $00000006;  
      PIDMSI_STATUS      = $00000007;     // VT_UI4  
      PIDMSI_OWNER       = $00000008;     // VT_LPWSTR  
      PIDMSI_RATING      = $00000009;  
      PIDMSI_PRODUCTION  = $0000000A;     // VT_FILETIME (UTC)  
      PIDMSI_COPYRIGHT   = $0000000B;     // VT_LPWSTR  
     
      // FMTID_AudioSummaryInformation  
      PIDASI_FORMAT        = $00000002;   // VT_BSTR  
      PIDASI_TIMELENGTH    = $00000003;   // VT_UI4, milliseconds  
      PIDASI_AVG_DATA_RATE = $00000004;   // VT_UI4,  Hz  
      PIDASI_SAMPLE_RATE   = $00000005;   // VT_UI4,  bits  
      PIDASI_SAMPLE_SIZE   = $00000006;   // VT_UI4,  bits  
      PIDASI_CHANNEL_COUNT = $00000007;   // VT_UI4  
      PIDASI_STREAM_NUMBER = $00000008;   // VT_UI2  
      PIDASI_STREAM_NAME   = $00000009;   // VT_LPWSTR  
      PIDASI_COMPRESSION   = $0000000A;   // VT_LPWSTR  
     
      // FMTID_VideoSummaryInformation  
      PIDVSI_STREAM_NAME   = $00000002;   // "StreamName", VT_LPWSTR  
      PIDVSI_FRAME_WIDTH   = $00000003;   // "FrameWidth", VT_UI4  
      PIDVSI_FRAME_HEIGHT  = $00000004;   // "FrameHeight", VT_UI4  
      PIDVSI_TIMELENGTH    = $00000007;   // "TimeLength", VT_UI4, milliseconds  
      PIDVSI_FRAME_COUNT   = $00000005;   // "FrameCount". VT_UI4  
      PIDVSI_FRAME_RATE    = $00000006;   // "FrameRate", VT_UI4, frames/millisecond  
      PIDVSI_DATA_RATE     = $00000008;   // "DataRate", VT_UI4, bytes/second  
      PIDVSI_SAMPLE_SIZE   = $00000009;   // "SampleSize", VT_UI4  
      PIDVSI_COMPRESSION   = $0000000A;   // "Compression", VT_LPWSTR  
      PIDVSI_STREAM_NUMBER = $0000000B;   // "StreamNumber", VT_UI2  
     
    type  
      TMultipleArray     = record  
        pidInfoType : cardinal;  
        pidInfoStr  : pchar;  
      end;  
      TMultipleArrayList = array of TMultipleArray;  
     
    function GetFileSummaryInfo(const FileName: WideString;  
      GUID_SummaryType: TGUID; PID_InfoType: cardinal): string;  
    function SetFileSummaryInfo(const FileName: WideString; GUID_InfoType: TGUID;  
      PID_InfoType: cardinal; InfoStr: string): boolean;  
    function SetMultipleFileSummaryInfo(const FileName: WideString;  
      GUID_InfoType: TGUID; MultipleArrayList: TMultipleArrayList): boolean;  
    function IsNTFS(AFileName : string) : boolean;
     
    implementation
     
    const
      szOleDll                = 'ole32.dll';
      IID_IPropertySetStorage : TGUID = '{0000013A-0000-0000-C000-000000000046}';
    type
      TStgOpenStorageEx       = function(const pwcsName: PWideChar;
        grfMode: DWORD; stgfmt: DWORD; grfAttrs: DWORD; pStgOptions: pointer;
        reserved2: pointer; riid: PGUID; out ppObjectOpen: IStorage): HRESULT;  
        stdcall;  
    var  
      StgOpenStorageEx        : TStgOpenStorageEx = nil;
      dll                     : dword = 0;  
      Win2k                   : boolean = false;  
     
    function GetHardDiskPartitionType(const DriveLetter: Char): string;
    var
      NotUsed: DWORD;
      VolumeFlags: DWORD;
      VolumeSerialNumber: DWORD;
      PartitionType: array[0..32] of Char;
    begin
      GetVolumeInformation(PChar(DriveLetter + ':\'),
        nil, MAX_PATH+1, @VolumeSerialNumber, NotUsed,
        VolumeFlags, PartitionType, 32);
      Result := PartitionType; // "FAT" ou "NTFS"
    end;
     
    function IsNTFS(AFileName : string) : boolean;
    begin
         IsNTFS := False;
         if GetHardDiskPartitionType(ExtractFileDrive(AFileName)[1])='NTFS' then IsNTFS := True;
    end;
     
    function GetFileSummaryInfo(const FileName: WideString;  
      GUID_SummaryType: TGUID; PID_InfoType: cardinal): string;  
    var  
      hr          : HRESULT;  
      Stg         : IStorage;  
      PropSetStg  : IPropertySetStorage;  
      PropStg     : IPropertyStorage;  
      PropSpec    : TPropSpec;  
      PropVariant : TPropVariant;  
    begin  
      Result      := '';  
      hr          := S_FALSE;  
     
      // for 9x and NT4 users  
      if(not Win2k) or (@StgOpenStorageEx = nil) then  
        hr := StgOpenStorage(pwidechar(FileName),nil,STGM_READ or  
          STGM_SHARE_DENY_WRITE,nil,0,Stg)  
      // for 2000, XP and higher  
      else if(@StgOpenStorageEx <> nil) then  
        hr := StgOpenStorageEx(pwidechar(FileName),STGM_READ or
          STGM_SHARE_DENY_WRITE,STGFMT_ANY,0,nil,nil,  
          @IID_IPropertySetStorage,Stg);  
     
     
      if(hr = S_OK) then  
      begin  
        PropSetStg := Stg as IPropertySetStorage;  
     
     
        if(PropSetStg.Open(GUID_SummaryType,STGM_READ or  
          STGM_SHARE_EXCLUSIVE,PropStg) = S_OK) then  
        begin  
          PropSpec.ulKind := PRSPEC_PROPID;  
          PropSpec.propid := PID_InfoType;  
     
     
          if(PropStg.ReadMultiple(1,@PropSpec,@PropVariant) = S_OK) and  
            (PropVariant.vt = VT_LPSTR) and  
            (PropVariant.pszVal <> nil) then  
          Result := PropVariant.pszVal;  
        end;  
      end;  
    end;  
     
     
    function SetFileSummaryInfo(const FileName: WideString; GUID_InfoType: TGUID;  
      PID_InfoType: cardinal; InfoStr: string): boolean;  
    var  
      hr          : HRESULT;  
      Stg         : IStorage;  
      PropSetStg  : IPropertySetStorage;  
      PropStg     : IPropertyStorage;  
      PropSpec    : TPropSpec;  
      PropVariant : TPropVariant;  
    begin  
      Result      := false;  
      hr          := S_FALSE;
     
      // 9x and NT4  
      if(not Win2k) or (@StgOpenStorageEx = nil) then  
        hr := StgOpenStorage(pwidechar(FileName),nil,STGM_SHARE_EXCLUSIVE or  
          STGM_READWRITE,nil,0,Stg)  
      // 2000, XP and higher  
      else if(@StgOpenStorageEx <> nil) then  
        hr := StgOpenStorageEx(pwidechar(FileName),STGM_SHARE_EXCLUSIVE or  
        STGM_READWRITE,STGFMT_ANY,0,nil,nil,@IID_IPropertySetStorage,Stg);
     
      if(hr = S_OK) then  
      begin  
        PropSetStg := Stg as IPropertySetStorage;  
     
     
        // try to open an existing Property set  
        hr         := PropSetStg.Open(GUID_InfoType,STGM_READWRITE or
          STGM_SHARE_EXCLUSIVE,PropStg);
     
     
        // create a new set  
        if(hr <> S_OK) then  
          hr       := PropSetStg.Create(GUID_InfoType,GUID_InfoType,
            PROPSETFLAG_DEFAULT,STGM_CREATE or STGM_READWRITE or
            STGM_SHARE_EXCLUSIVE,PropStg);
     
     
        if(hr = S_OK) then  
        begin  
          PropSpec.ulKind    := PRSPEC_PROPID;  
          PropSpec.propid    := PID_InfoType;  
          PropVariant.vt     := VT_LPSTR;  
          PropVariant.pszVal := pchar(InfoStr);  
     
     
          if(PropStg.WriteMultiple(1,@PropSpec,@PropVariant,2) = S_OK) then  
          begin  
            Result := (PropStg.Commit(STGC_DEFAULT) = S_OK);  
          end;  
        end;  
      end;  
    end;  
     
     
    function SetMultipleFileSummaryInfo(const FileName: WideString;  
      GUID_InfoType: TGUID; MultipleArrayList: TMultipleArrayList): boolean;  
    var  
      Stg         : IStorage;  
      PropSetStg  : IPropertySetStorage;  
      hr          : HRESULT;  
      PropStg     : IPropertyStorage;  
      PropSpec    : array of TPropSpec;  
      PropVariant : array of TPropVariant;  
      i           : integer;  
    begin  
      Result      := false;  
      hr          := S_FALSE;  
      if(length(MultipleArrayList) = 0) then exit;  
     
     
      // 9x, NT4  
      if(not Win2k) or (@StgOpenStorageEx = nil) then  
        hr := StgOpenStorage(pwidechar(FileName),nil,STGM_SHARE_EXCLUSIVE or  
          STGM_READWRITE,nil,0,Stg)  
      // 2000, XP and higher  
      else if(@StgOpenStorageEx <> nil) then  
        hr := StgOpenStorageEx(pwidechar(FileName),STGM_SHARE_EXCLUSIVE or  
        STGM_READWRITE,STGFMT_ANY,0,nil,nil,@IID_IPropertySetStorage,Stg);  
     
     
      if(hr = S_OK) then  
      begin  
        PropSetStg := Stg as IPropertySetStorage;  
     
     
        // try to open an existing Property set  
        hr         := PropSetStg.Open(GUID_InfoType,STGM_READWRITE or  
          STGM_SHARE_EXCLUSIVE,PropStg);  
     
     
        // create a new set  
        if(hr <> S_OK) then  
          hr       := PropSetStg.Create(GUID_InfoType,GUID_InfoType,  
            PROPSETFLAG_DEFAULT,STGM_CREATE or STGM_READWRITE or  
            STGM_SHARE_EXCLUSIVE,PropStg);  
     
     
        if(hr = S_OK) then  
        begin  
          // set default length  
          SetLength(PropSpec,0);  
          SetLength(PropVariant,0);  
     
     
          // fill  
          for i := 0 to length(MultipleArrayList) - 1 do  
            if(MultipleArrayList[i].pidInfoType <> 0) and  
              (MultipleArrayList[i].pidInfoStr <> nil) then  
            begin  
              SetLength(PropSpec,length(PropSpec) + 1);  
              PropSpec[length(PropSpec)-1].ulKind       := PRSPEC_PROPID;  
              PropSpec[length(PropSpec)-1].propid       :=  
                MultipleArrayList[i].pidInfoType;  
     
     
              SetLength(PropVariant,length(PropVariant) + 1);  
              PropVariant[length(PropVariant)-1].vt     := VT_LPSTR;  
              PropVariant[length(PropVariant)-1].pszVal :=  
                MultipleArrayList[i].pidInfoStr;  
            end;  
     
     
          // write  
          if(length(PropSpec) > 0) and  
            (length(PropVariant) > 0) and  
            (length(PropSpec) = length(PropVariant)) then  
          begin  
            if(PropStg.WriteMultiple(length(PropSpec),@PropSpec[0],  
              @PropVariant[0],2) = S_OK) then  
            begin  
              Result := (PropStg.Commit(STGC_DEFAULT) = S_OK);  
            end;  
     
     
            SetLength(PropSpec,0);  
            SetLength(PropVariant,0);  
          end;  
        end;  
      end;  
    end;  
     
     
     
     
    //  
    // Main  
    //  
    var  
      os : TOSVersionInfo;  
     
     
    initialization  
      // get OS  
      ZeroMemory(@os,sizeof(os));  
      os.dwOSVersionInfoSize := sizeof(os);  
     
     
      // is it Windows 2000 or higher?  
      Win2k                  := (GetVersionEx(os)) and  
        (os.dwMajorVersion >= 5) and  
        (os.dwPlatformId = VER_PLATFORM_WIN32_NT);  
     
     
      CoInitialize(nil);  
     
     
      dll := LoadLibrary(szOleDll);  
      if(dll <> 0) then  
      begin  
        StgOpenStorageEx := GetProcAddress(dll,'StgOpenStorageEx');  
        if(@StgOpenStorageEx = nil) then  
        begin  
          FreeLibrary(dll);  
          dll := 0;  
        end;  
      end;  
    finalization  
      if(dll <> 0) then FreeLibrary(dll);  
      CoUninitialize;  
    end.
    @+,

    Cincap
    Fichiers attachés Fichiers attachés

Discussions similaires

  1. Date de création d'une table
    Par LBO72 dans le forum SQL
    Réponses: 5
    Dernier message: 25/05/2007, 09h24
  2. Date de cliché d'une photo
    Par Invité dans le forum Langage
    Réponses: 1
    Dernier message: 20/05/2007, 11h21
  3. Réponses: 4
    Dernier message: 20/04/2007, 09h13
  4. Réponses: 2
    Dernier message: 13/07/2006, 17h01
  5. [requete] Date de création d'une base oracle.
    Par Cyborg289 dans le forum Oracle
    Réponses: 2
    Dernier message: 14/02/2006, 11h14

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo