#include <winstl/system/module_directory.hpp>
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> |
Public Types | |
Member Constants | |
| enum | { internalBufferSize = 128 } |
| enum | { allowImplicitConversion = 1 } |
| enum | { sharedState = 0 } |
Member Types | |
| typedef C | char_type |
| typedef HINSTANCE | argument_0_type |
| typedef processheap_allocator< C > | allocator_type |
| typedef size_t | size_type |
| typedef size_type(* | pfn_type )(argument_0_type, char_type *, size_type) |
Static Public Member Functions | |
Operations | |
| static pfn_type | get_fn () |
1.5.6