#include <winstl/control_panel/applet_module.hpp>
The following code enumerates all the applet modules in the Windows system directory, and prints out the name and description of each applet contained within.
#include <winstl/findfile_sequence.hpp> #include <winstl/system_directory.hpp> #include <winstl/control_panel/applet_module.hpp> #include <iostream> int main() { try { winstl::system_directory sysDir; winstl::findfile_sequence files(sysDir, "*.cpl", winstl::findfile_sequence::files); { for(winstl::findfile_sequence::const_iterator b = files.begin(); b != files.end(); ++b) { winstl::applet_module module(*b, winstl::applet_module:dontExpectNonZeroInit); winstl::applet_module::const_iterator b = module.begin(); winstl::applet_module::const_iterator e = module.end(); std::cout << "path: " << module.get_path() << std::endl; for(; b != e; ++b) { winstl::applet const &applet = *b; std::cout << " applet index: " << applet.get_index() << std::endl; std::cout << " name: " << applet.get_name() << std::endl; std::cout << " description: " << applet.get_description() << std::endl; } std::cout << std::endl; }} } catch(std::exception &x) { std::cerr << "Exception: " << x.what() << std::endl; } return 0; }
Note the use of the dontExpectNonZeroInit flag, which is recommended because several common control panel modules do not correctly implement their CPL_INIT handlers.
Member Types | |
| typedef applet_module | class_type |
| The type of this class. | |
| typedef applet | value_type |
| The value type. | |
| typedef size_t | size_type |
| The size type. | |
| typedef size_t | index_type |
| The index type. | |
| typedef stlsoft::basic_simple_string < TCHAR > | string_type |
| The string type. | |
| typedef applets_type_::iterator | iterator |
| The mutating (non-const) iterator type. | |
| typedef applets_type_::const_iterator | const_iterator |
| The non-mutating (const) iterator type. | |
| typedef void(__stdcall * | onFailureS )(TCHAR const *path) |
| Prototype of stdcall function that receives error notifications. | |
| typedef | void (1 *onFailureC)(TCHAR const *path) |
| Prototype of cdecl function that receives error notifications. | |
Public Types | |
Member Constants | |
| enum | load_flags { ignoreIconLoadFailures = 0x0001, dontExpectNonZeroInit = 0x0002, assumeOneAppletIfNone = 0x0004 } |
| Flags that moderate the load behaviour. More... | |
Public Member Functions | |
Construction | |
| applet_module (TCHAR const *path, int flags=ignoreIconLoadFailures, HWND hwndParent=NULL) | |
| Constructs an instance containing all the applets in the given module. | |
Attributes | |
| string_type const & | get_path () const |
| The path used to initialise the instance. | |
Accessors | |
| size_type | size () const |
| The number of applets in the module. | |
| value_type & | operator[] (index_type index) |
| Returns a mutable (non-const) reference to the applet at the index. | |
| value_type const & | operator[] (index_type index) const |
| Returns a non-mutable (const) reference to the applet at the index. | |
Iteration | |
| iterator | begin () |
| Begins the iteration. | |
| iterator | end () |
| Ends the iteration. | |
| const_iterator | begin () const |
| Begins the iteration. | |
| const_iterator | end () const |
| Ends the iteration. | |
Classes | |
| struct | error_translator |
| typedef applet_module class_type |
The type of this class.
| typedef applet value_type |
The value type.
| typedef size_t size_type |
The size type.
| typedef size_t index_type |
The index type.
| typedef stlsoft:: basic_simple_string<TCHAR> string_type |
The string type.
| typedef applets_type_::iterator iterator |
The mutating (non-const) iterator type.
| typedef applets_type_::const_iterator const_iterator |
The non-mutating (const) iterator type.
| typedef void( __stdcall * onFailureS)(TCHAR const *path) |
Prototype of stdcall function that receives error notifications.
| enum load_flags |
| applet_module | ( | TCHAR const * | path, | |
| int | flags = ignoreIconLoadFailures, |
|||
| HWND | hwndParent = NULL | |||
| ) | [explicit] |
Constructs an instance containing all the applets in the given module.
| path | [in] Path of the applet module. | |
| flags | [in] Flags that moderate the loading behaviour. | |
| hwndParent | [in] Handle to a window to act as the parent for the dialog(s) of the applet(s) contained in the module |
| winstl::control_panel_exception | Thrown if the applet module initialisation fails. | |
| winstl::resource_exception | Thrown if the icon cannot be loaded for a given applet, and ignoreIconLoadFailures. |
| typedef void | ( | 1 * | onFailureC | ) | const |
Prototype of cdecl function that receives error notifications.
| string_type const& get_path | ( | ) | const |
The path used to initialise the instance.
| value_type& operator[] | ( | index_type | index | ) |
| value_type const& operator[] | ( | index_type | index | ) | const |
| iterator begin | ( | ) |
Begins the iteration.
| iterator end | ( | ) |
Ends the iteration.
| const_iterator begin | ( | ) | const |
Begins the iteration.
| const_iterator end | ( | ) | const |
Ends the iteration.
1.5.6