ReactOS  0.4.13-dev-241-g63286c6
shelltests.cpp File Reference
#include "utility.h"
#include "shellclasses.h"
Include dependency graph for shelltests.cpp:

Go to the source code of this file.

Functions

static void dump_shell_namespace (ShellFolder &folder)
 
int main ()
 

Function Documentation

◆ dump_shell_namespace()

static void dump_shell_namespace ( ShellFolder folder)
static

Definition at line 37 of file shelltests.cpp.

38 {
39  ShellItemEnumerator enumerator(folder, SHCONTF_FOLDERS|SHCONTF_NONFOLDERS|SHCONTF_INCLUDEHIDDEN|SHCONTF_SHAREABLE|SHCONTF_STORAGE);
40 
41  LPITEMIDLIST pidl;
42  HRESULT hr = S_OK;
43 
44  do {
45  ULONG cnt = 0;
46 
47  HRESULT hr = enumerator->Next(1, &pidl, &cnt);
48 
49  if (!SUCCEEDED(hr))
50  break;
51 
52  if (hr == S_FALSE) // no more entries?
53  break;
54 
55  if (pidl) {
56  ULONG attribs = -1;
57 
58  HRESULT hr = folder->GetAttributesOf(1, (LPCITEMIDLIST*)&pidl, &attribs);
59 
60  if (SUCCEEDED(hr)) {
61  if (attribs == -1)
62  attribs = 0;
63 
64  const String& name = folder.get_name(pidl);
65 
66  if (attribs & (SFGAO_FOLDER|SFGAO_HASSUBFOLDER))
67  cout << "folder: ";
68  else
69  cout << "file: ";
70 
71  cout << "\"" << name << "\"\n attribs=" << hex << attribs << endl;
72  }
73  }
74  } while(SUCCEEDED(hr));
75 }
Definition: fci.c:115
HRESULT hr
Definition: shlfolder.c:183
const GLint * attribs
Definition: glext.h:10538
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
static WCHAR String[]
Definition: stringtable.c:55
static const char hex[16]
Definition: profile.c:123
#define cout
Definition: iostream.cpp:38
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
Definition: _ostream.h:357
wrapper class for enumerating shell namespace objects
#define S_FALSE
Definition: winerror.h:2357
LONG HRESULT
Definition: typedefs.h:77
#define S_OK
Definition: intsafe.h:59
Definition: name.c:36
unsigned int ULONG
Definition: retypes.h:1
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by main().

◆ main()

int main ( void  )

Definition at line 78 of file shelltests.cpp.

79 {
80  // initialize COM
81  ComInit usingCOM;
82 
83 
84  HWND hwnd = 0;
85 
86 
87  try {
88 
89  // example for retrieval of special folder paths
90 
93 
94  cout << "program files path = " << (LPCTSTR)programs << endl;
95  cout << "autostart folder path = " << (LPCTSTR)autostart << endl;
96 
97  cout << endl;
98 
99 
100  // example for enumerating shell namespace objects
101 
102  cout << "Desktop:\n";
104  cout << endl;
105 
106  cout << "C:\\\n";
107  dump_shell_namespace(ShellPath("C:\\").get_folder());
108  cout << endl;
109 
110 
111  // example for calling a browser dialog for the whole desktop
112 
113  FolderBrowser desktop_browser(hwnd,
115  TEXT("Please select the path:"));
116 
117  if (desktop_browser.IsOK())
118  MessageBox(hwnd, desktop_browser, TEXT("Your selected path"), MB_OK);
119 
120 
121  // example for calling a rooted browser dialog
122 
123  ShellPath browseRoot("C:\\");
124  FolderBrowser rooted_browser(hwnd,
126  TEXT("Please select the path:"),
127  browseRoot);
128 
129  if (rooted_browser.IsOK())
130  MessageBox(hwnd, rooted_browser, TEXT("Your selected path"), MB_OK);
131 
132  } catch(COMException& e) {
133 
134  //HandleException(e, hwnd);
135  cerr << e.ErrorMessage() << endl;
136 
137  }
138 
139  return 0;
140 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
file system path of special folder
#define CSIDL_PROGRAM_FILES
Definition: shlobj.h:2040
#define BIF_EDITBOX
Definition: shlobj.h:1139
Exception with context information.
Definition: shellclasses.h:113
#define cout
Definition: iostream.cpp:38
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
Definition: _ostream.h:357
#define e
Definition: ke_i.h:82
#define BIF_NEWDIALOGSTYLE
Definition: shlobj.h:1141
_STLP_DECLSPEC _Stl_aligned_buffer< ostream > cerr
Definition: iostream.cpp:102
const GLuint * programs
Definition: glext.h:6724
static void dump_shell_namespace(ShellFolder &folder)
Definition: shelltests.cpp:37
#define MessageBox
Definition: winuser.h:5688
#define CSIDL_STARTUP
Definition: shlobj.h:2010
ShellFolder & GetDesktopFolder()
Browse dialog operating on shell namespace.
Definition: shellclasses.h:947
#define TEXT(s)
Definition: k32.h:26
#define BIF_RETURNONLYFSDIRS
Definition: shlobj.h:1135
#define MB_OK
Definition: winuser.h:784
#define BIF_VALIDATE
Definition: shlobj.h:1140
wrapper class for item ID lists
Definition: shellclasses.h:651
COM Initialisation.
Definition: shellclasses.h:178