|
|
|
|
|
|
|
|
|
|
|
|||||||
#include <winstl_module_directory.h>
Public Types | |
| typedef C | char_type |
| The char type. | |
| typedef T | traits_type |
| The traits type. | |
| typedef basic_module_directory< C, T > | class_type |
| The current parameterisation of the type. | |
| typedef ws_size_t | size_type |
| The size type. | |
Public Methods | |
| basic_module_directory (HINSTANCE hinst=NULL) | |
| Default constructor. | |
| char_type const * | get_path () const |
| Returns a non-mutable (const) pointer to the path. | |
| char_type const * | c_str () const |
| Returns a pointer to a nul-terminated string. | |
| size_type | length () const |
| Returns the length of the converted path. | |
| operator char_type const * () const | |
| Implicit conversion to a non-mutable (const) pointer to the path. | |
Static Public Methods | |
| size_type | get_path (HINSTANCE hinst, ws_char_a_t *buffer, size_type cchBuffer) |
| Gets the module directory into the given buffer. | |
| size_type | get_path (HINSTANCE hinst, ws_char_w_t *buffer, size_type cchBuffer) |
| Gets the module directory into the given buffer. | |
An instance of basic_module_directory encapsulates the directory of a given module. You instantiate it from a given module handle, as follows:
[STLSOFT-DOC:VERBATIM:start;comment:/// ;] HINSTANCE hinst = . . .; basic_module_directory<char>(hinst) mdir(hinst); puts(mdir); [STLSOFT-DOC:VERBATIM:end]
You can also use one of the three given typedefs: module_directory (parameterised on TCHAR), module_directory_a (parameterised on CHAR), module_directory_w (parameterised on WCHAR).
1. It affords a simpler syntax. You can use temporary instances of the class, and use the char_type const * implicit conversion, or the c_str() method inline
[STLSOFT-DOC:VERBATIM:start;comment:/// ;] puts(module_directory_a(hinst)); [STLSOFT-DOC:VERBATIM:end]
You can also use it with the IOStreams:
[STLSOFT-DOC:VERBATIM:start;comment:/// ;] cout << L"The module was loaded from the " << module_directory_w(hinst) << L" directory" << endl; [STLSOFT-DOC:VERBATIM:end]
2. It relieves you from the boilerplate coding of calling GetModuleFileName() and then parsing the returned path to trim off the directory. All that is handled in the class.
| C | The character type |
| T | The traits type. On translators that support default template arguments, this defaults to filesystem_traits<C> |
|
|
The char type.
|
|
|
The current parameterisation of the type.
|
|
|
The size type.
|
|
|
The traits type.
|
|
|
Default constructor.
|
|
|
Returns a pointer to a nul-terminated string.
|
|
|
Returns a non-mutable (const) pointer to the path.
|
|
||||||||||||||||
|
Gets the module directory into the given buffer.
|
|
||||||||||||||||
|
Gets the module directory into the given buffer.
|
|
|
Returns the length of the converted path.
|
|
|
Implicit conversion to a non-mutable (const) pointer to the path.
|
|
|
| STLSoft Libraries documentation © Synesis Software Pty Ltd, 2001-2004 |