173 lines
12 KiB
HTML
173 lines
12 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
|
<meta name="generator" content="Doxygen 1.12.0"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>WinStd: WinStd</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<script type="text/javascript" src="clipboard.js"></script>
|
|
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="resize.js"></script>
|
|
<script type="text/javascript" src="cookie.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr id="projectrow">
|
|
<td id="projectalign">
|
|
<div id="projectname">WinStd
|
|
</div>
|
|
<div id="projectbrief">Windows Win32 API using Standard C++</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.12.0 -->
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
var searchBox = new SearchBox("searchBox", "search/",'.html');
|
|
/* @license-end */
|
|
</script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
$(function() { codefold.init(0); });
|
|
/* @license-end */
|
|
</script>
|
|
<script type="text/javascript" src="menudata.js"></script>
|
|
<script type="text/javascript" src="menu.js"></script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
$(function() {
|
|
initMenu('',true,false,'search.php','Search',false);
|
|
$(function() { init_search(); });
|
|
});
|
|
/* @license-end */
|
|
</script>
|
|
<div id="main-nav"></div>
|
|
</div><!-- top -->
|
|
<div id="doc-content">
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
$(function(){ initResizable(false); });
|
|
/* @license-end */
|
|
</script>
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<div id="MSearchResults">
|
|
<div class="SRPage">
|
|
<div id="SRIndex">
|
|
<div id="SRResults"></div>
|
|
<div class="SRStatus" id="Loading">Loading...</div>
|
|
<div class="SRStatus" id="Searching">Searching...</div>
|
|
<div class="SRStatus" id="NoMatches">No Matches</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div><div class="header">
|
|
<div class="headertitle"><div class="title">WinStd </div></div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<div class="textblock"><p><a class="anchor" id="md__r_e_a_d_m_e"></a></p>
|
|
<p>Provides templates and function helpers for Windows Win32 API using Standard C++ in Microsoft Visual C++ 2017-2022</p>
|
|
<h1><a class="anchor" id="autotoc_md1"></a>
|
|
Features</h1>
|
|
<h2><a class="anchor" id="autotoc_md2"></a>
|
|
Portable</h2>
|
|
<p>This project does not require building. Just <code>#include</code> individual files from this repository into your source code and get started.</p>
|
|
<h2><a class="anchor" id="autotoc_md3"></a>
|
|
Memory and Resource Helper Classes</h2>
|
|
<p>Simplify memory and resource management. The classes release memory and resources automatically. They are like <em>smart-pointers</em> for various Windows resources. Once created, you use the class instance as a snap-in replacement for pointers/handles parameters in the standard Win32 API function calls.</p>
|
|
<h3><a class="anchor" id="autotoc_md4"></a>
|
|
Example</h3>
|
|
<div class="fragment"><div class="line"> ++</div>
|
|
<div class="line"><span class="comment">// Load and set icon.</span></div>
|
|
<div class="line"><a class="code hl_class" href="classwinstd_1_1library.html">winstd::library</a> lib_shell32(LoadLibraryEx(_T(<span class="stringliteral">"shell32.dll"</span>), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE));</div>
|
|
<div class="line"><span class="keywordflow">if</span> (!lib_shell32)</div>
|
|
<div class="line"> <span class="keywordflow">throw</span> <a class="code hl_class" href="classwinstd_1_1win__runtime__error.html">winstd::win_runtime_error</a>(<span class="stringliteral">"LoadLibraryEx failed"</span>);</div>
|
|
<div class="line">m_note_icon->SetIcon(wxLoadIconFromResource(lib_shell32, MAKEINTRESOURCE(48)));</div>
|
|
<div class="ttc" id="aclasswinstd_1_1library_html"><div class="ttname"><a href="classwinstd_1_1library.html">winstd::library</a></div><div class="ttdoc">Module handle wrapper.</div><div class="ttdef"><b>Definition</b> Win.h:1045</div></div>
|
|
<div class="ttc" id="aclasswinstd_1_1win__runtime__error_html"><div class="ttname"><a href="classwinstd_1_1win__runtime__error.html">winstd::win_runtime_error</a></div><div class="ttdoc">Windows runtime error.</div><div class="ttdef"><b>Definition</b> Common.h:1403</div></div>
|
|
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md5"></a>
|
|
Functions and Templates</h2>
|
|
<p>Different Win32 API functions have different ways of returning variable-sized data. Getting tired of carefully studying MSDN for each particular Win32 API function how to preallocate the output memory correctly? We too...</p>
|
|
<p>WinStd provides a subset of Win32 API identically named functions (C++ polymorphism to the rescue), where one can use <code>std::string</code>, <code>std::wstring</code>, <code>std::vector<></code> etc. as an output parameter. WinStd handles all the dirty work with memory allocation for you, so you can focus on your code.</p>
|
|
<h3><a class="anchor" id="autotoc_md6"></a>
|
|
Example</h3>
|
|
<div class="fragment"><div class="line"> ++</div>
|
|
<div class="line"><span class="comment">// Encode response as OEM.</span></div>
|
|
<div class="line">std::string response;</div>
|
|
<div class="line"><a class="code hl_function" href="group___win_std_str_format.html#gabf5eed22d7c5d7a89334dbe1e04e2656">WideCharToMultiByte</a>(CP_OEMCP, 0, L<span class="stringliteral">"Copyright \u00A9 2017"</span>, -1, response, NULL, NULL);</div>
|
|
<div class="line">std::cout << response.c_str() << std::endl;</div>
|
|
<div class="ttc" id="agroup___win_std_str_format_html_gabf5eed22d7c5d7a89334dbe1e04e2656"><div class="ttname"><a href="group___win_std_str_format.html#gabf5eed22d7c5d7a89334dbe1e04e2656">WideCharToMultiByte</a></div><div class="ttdeci">static int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar, std::basic_string< char, _Traits, _Ax > &sMultiByteStr, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar) noexcept</div><div class="ttdoc">Maps a UTF-16 (wide character) string to a std::string. The new character string is not necessarily f...</div><div class="ttdef"><b>Definition</b> Common.h:348</div></div>
|
|
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md7"></a>
|
|
String Formatters</h2>
|
|
<p>For those situations where one must quckly compose a temporary string using <code><a class="el" href="group___win_std_str_format.html#gac397f655a858a069b3e521940af64331" title="Formats string using printf().">sprintf()</a></code> or <code>FormatMessage()</code>. Or, convert a GUID to a string on the fly.</p>
|
|
<h3><a class="anchor" id="autotoc_md8"></a>
|
|
Example</h3>
|
|
<div class="fragment"><div class="line"> ++</div>
|
|
<div class="line"><span class="keywordflow">if</span> (dwMaxSendPacketSize < <span class="keyword">sizeof</span>(EapPacket))</div>
|
|
<div class="line"> <span class="keywordflow">throw</span> std::invalid_argument(</div>
|
|
<div class="line"> <a class="code hl_class" href="classwinstd_1_1basic__string__printf.html">winstd::string_printf</a>(</div>
|
|
<div class="line"> <span class="stringliteral">"Maximum packet size too small (minimum: %zu, available: %u)"</span>,</div>
|
|
<div class="line"> <span class="keyword">sizeof</span>(EapPacket) + 1,</div>
|
|
<div class="line"> dwMaxSendPacketSize));</div>
|
|
<div class="ttc" id="aclasswinstd_1_1basic__string__printf_html"><div class="ttname"><a href="classwinstd_1_1basic__string__printf.html">winstd::basic_string_printf</a></div><div class="ttdoc">Base template class to support string formatting using printf() style templates.</div><div class="ttdef"><b>Definition</b> Common.h:1485</div></div>
|
|
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md9"></a>
|
|
What WinStd Is Not</h1>
|
|
<p>WinStd is not trying to be a full-fledged object-oriented framework on top of Win32 API. We have Microsoft to publish those once every few years - and obsolete it when they loose interest. WinStd aims at augmenting Win32 API with a little bit of help from C++.</p>
|
|
<h1><a class="anchor" id="autotoc_md10"></a>
|
|
Usage</h1>
|
|
<ol type="1">
|
|
<li>Clone the repository into your solution folder.</li>
|
|
<li>Add WinStd's <code>include</code> folder to <em>Additional Include Directories</em> in your project's C/C++ settings.</li>
|
|
<li>Include <code>.h</code> files from WinStd as needed: <div class="fragment"><div class="line"> ++</div>
|
|
<div class="line"><span class="preprocessor">#include <WinStd/Shell.h></span></div>
|
|
<div class="line"><span class="preprocessor">#include <string></span></div>
|
|
<div class="line"><span class="preprocessor">#include <iostream></span></div>
|
|
<div class="line"> </div>
|
|
<div class="line"><span class="keyword">using namespace </span>std;</div>
|
|
<div class="line"> </div>
|
|
<div class="line"><span class="keywordtype">void</span> main()</div>
|
|
<div class="line">{</div>
|
|
<div class="line"> wstring path;</div>
|
|
<div class="line"> <a class="code hl_function" href="group___win_std_shell_w_a_p_i.html#ga2bb4436e8e3b7452b48d01cbb18bc818">PathCanonicalizeW</a>(path, L<span class="stringliteral">"C:\\Windows\\Temp\\test\\.."</span>);</div>
|
|
<div class="line"> wcout << path.c_str() << endl;</div>
|
|
<div class="line">}</div>
|
|
<div class="ttc" id="agroup___win_std_shell_w_a_p_i_html_ga2bb4436e8e3b7452b48d01cbb18bc818"><div class="ttname"><a href="group___win_std_shell_w_a_p_i.html#ga2bb4436e8e3b7452b48d01cbb18bc818">PathCanonicalizeW</a></div><div class="ttdeci">static BOOL PathCanonicalizeW(std::basic_string< wchar_t, _Traits, _Ax > &sValue, LPCWSTR pszPath)</div><div class="ttdoc">Simplifies a path by removing navigation elements such as "." and ".." to produce a direct,...</div><div class="ttdef"><b>Definition</b> Shell.h:34</div></div>
|
|
</div><!-- fragment --></li>
|
|
</ol>
|
|
<p>An auto-generated documentation is <a href="https://amebis.github.io/WinStd/">here</a>.</p>
|
|
<p>More examples and use-cases can be found in <a href="https://github.com/Amebis/GEANTLink">GÉANTLink</a> and <a href="https://github.com/Amebis/ZRCola">ZRCola</a> projects source code. They make heavy use of WinStd. Examples can also be found in the <code>UnitTests</code> project.</p>
|
|
<p>This is a one-man project for the time being, so the Win32 API support is far from complete. It is added as needed. Contributions are welcome. </p>
|
|
</div></div><!-- PageDoc -->
|
|
<a href="doxygen_crawl.html"></a>
|
|
</div><!-- contents -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated on Tue Oct 1 2024 14:47:48 for WinStd by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.12.0
|
|
</small></address>
|
|
</div><!-- doc-content -->
|
|
</body>
|
|
</html>
|