Partager via


Interface IJournalReader

Fournit un accès en lecture à un fichier Journal Windows, renvoyant un flux contenant une version XML du contenu du fichier.

Notes

Le composant Lecteur de journal ne peut pas lire les fichiers journaux Windows créés par des machines exécutant Windows 7 ou version ultérieure. L’interface IJournalReader doit être considérée comme déconseillée ou obsolète et ne doit pas être utilisée.

Membres

L’interface IJournalReader hérite de l’interface IUnknown. IJournalReader a également les types de membres suivants :

Méthodes

L’interface IJournalReader possède ces méthodes.

Méthode Description
ReadFromStream Prend un flux vers un fichier note de journal et retourne un flux XML représentant le contenu du document.

Notes

La classe JournalReader vous permet de charger un flux de documents journal et de recevoir un flux XML représentant le contenu. Vous pouvez reconstituer, afficher et manipuler l’entrée manuscrite.

Exemples

L’exemple suivant de gestionnaire pour l’événement Click d’un bouton crée un instance de la classe JournalReader et l’utilise pour lire un fichier Journal existant.

Notes

La méthode DisplayXml appelée à partir de cet exemple n’est pas affichée. L’implémentation spécifique d’une telle méthode dépend des besoins de votre application.

void CJntlReaderMFCDlg::OnBnClickedButton1()
{
  static TCHAR BASED_CODE szFilter[] = 
    _T("Journal files (*.jnt)|*.jnt|All files (*.*)|*.*");
  CFileDialog* fileDialog = new CFileDialog(TRUE, _T("*.jnt"), NULL, 
                                 OFN_FILEMUSTEXIST, szFilter, this);

  // Get the filename from the user via a File Open dialog
  if (fileDialog != NULL &&
      fileDialog->DoModal() == IDOK)
  {
    CString strFileName = fileDialog->GetPathName();

    // Read a JNT file into a memory buffer
    HANDLE hFile = CreateFile(strFileName,
                              GENERIC_READ,
                              FILE_SHARE_READ,
                              NULL,
                              OPEN_EXISTING,
                              FILE_ATTRIBUTE_NORMAL,
                              NULL);
    
    if (hFile != INVALID_HANDLE_VALUE)
    {
      // Allocate memory to hold the file contents
      DWORD dwFileSize = GetFileSize(hFile, NULL);
      HGLOBAL hGlobal = GlobalAlloc(GHND, dwFileSize);

      if (hGlobal != NULL)
      {
        LPBYTE pData = (LPBYTE)GlobalLock(hGlobal);

        if (pData != NULL)
        {
          DWORD dwRead;

          // Read the Journal file into the pData buffer
          if (ReadFile(hFile, pData, dwFileSize, &dwRead, NULL) &&
              (dwRead == dwFileSize))
          {
            HRESULT hr;
            IStream* pJntStream;

            // Create an IStream that points to the buffer
            hr = CreateStreamOnHGlobal(hGlobal, FALSE, &pJntStream);

            if (SUCCEEDED(hr))
            {
              IJournalReader* pJntReader;

              // Create a JournalReader object
              hr = CoCreateInstance(CLSID_JournalReader, NULL, CLSCTX_ALL, 
                          IID_IJournalReader, (void**)&pJntReader);

              if (SUCCEEDED(hr))
              {
                IStream* pXmlStream;

                // Read in the JNT file via the JournalReader
                hr = pJntReader->ReadFromStream(pJntStream, &pXmlStream);

                if (SUCCEEDED(hr))
                {
                  // Display results
                  DisplayXml(pXmlStream);

                  // Clean up
                  pXmlStream->Release();
                }
                pJntReader->Release();
              }
              pJntStream->Release();
            }
          }
          GlobalUnlock(hGlobal);
        }
        GlobalFree(hGlobal);
      }
      CloseHandle(hFile);
    }
    delete fileDialog;
  }
}

Spécifications

Condition requise Valeur
Client minimal pris en charge
Windows XP Édition Tablet PC [applications de bureau uniquement]
Serveur minimal pris en charge
Aucun pris en charge
En-tête
Journal.h (nécessite également journal_i.c)
DLL
Journal.dll

Voir aussi

GUID de propriété personnalisée

ReadFromStream, méthode