ReactOS 0.4.15-dev-8092-ge0ba2f3
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}
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
Definition: _ostream.h:357
const GLint * attribs
Definition: glext.h:10538
int hex(char ch)
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define cout
Definition: iostream.cpp:38
HRESULT hr
Definition: shlfolder.c:183
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
wrapper class for enumerating shell namespace objects
Definition: fci.c:116
Definition: name.c:39
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
#define S_FALSE
Definition: winerror.h:2357

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 GLuint * programs
Definition: glext.h:6724
#define cerr
Definition: iostream.cpp:39
#define TEXT(s)
Definition: k32.h:26
#define e
Definition: ke_i.h:82
ShellFolder & GetDesktopFolder()
static void dump_shell_namespace(ShellFolder &folder)
Definition: shelltests.cpp:37
#define BIF_VALIDATE
Definition: shlobj.h:1215
#define CSIDL_PROGRAM_FILES
Definition: shlobj.h:2195
#define BIF_RETURNONLYFSDIRS
Definition: shlobj.h:1210
#define CSIDL_STARTUP
Definition: shlobj.h:2165
#define BIF_NEWDIALOGSTYLE
Definition: shlobj.h:1216
#define BIF_EDITBOX
Definition: shlobj.h:1214
Exception with context information.
Definition: shellclasses.h:114
COM Initialisation.
Definition: shellclasses.h:179
Browse dialog operating on shell namespace.
Definition: shellclasses.h:948
wrapper class for item ID lists
Definition: shellclasses.h:652
file system path of special folder
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define MB_OK
Definition: winuser.h:790
#define MessageBox
Definition: winuser.h:5822
const CHAR * LPCTSTR
Definition: xmlstorage.h:193