SOL9 Sample: KnownFolder

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * KnownFolder.cpp 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


#define UNICODE

#include <sol/shell/KnownFolderManager.h>
#include <sol/shell/KnownFolder.h>
#include <sol/ole/OleInitializer.h>
#include <sol/Locale.h>
#include <sol/Guid.h>
#include <sol/FileWriter.h>

void _tmain(int argc, const TCHAR** argv)
{
  OleInitializer initializer;

  try {
    Locale locale;
    FileWriter writer(L".\\KnownFolder.xml");

    writer.write(L"<?xml version='1.0'?>\n");

    //1 Create a manager object of class KnownFolerManager     
    SOL::KnownFolderManager manager;

    writer.write(L"<ShellApplication>\n");
    
    //2 Ge all knownFolderId and the count of the folders 
    KNOWNFOLDERID* pKFId = NULL;
    UINT         count = 0;
    manager.getFolderIds(&pKFId, &count);

    //3 Display the name of each folder of the known folders.
    writer.write(L"<KnownFolders count='%d'>\n", count);
    for(UINT i = 0; i<count; i++) {
      try {
        SOL::KnownFolder folder = manager.getFolder(pKFId[i]);
        folder.write(writer);
      } catch (HRESULT hr) {
        //Ignore this IException
      }
    }
    CoTaskMemFree(pKFId);
    writer.write(L"</KnownFolders>\n");

    writer.write(L"</ShellApplication>\n");
    writer.close();

  } catch (HRESULT hr) {
    printf("Exception HRESULT=%0x", hr); 
  } catch (Exception& ex) {
    ex.printf();
  } catch (...) {
    printf("Unknown IException\n");
  }
}





Last modified: 2 May 2016

Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.