141 lines
7.5 KiB
HTML
141 lines
7.5 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">
|
|
<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.9.3"/>
|
|
<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>
|
|
<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">Additional templates and function helpers for Microsoft Windows using Standard C++ classes</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.9.3 -->
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
|
|
/* @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');
|
|
$(document).ready(function() { init_search(); });
|
|
});
|
|
/* @license-end */
|
|
</script>
|
|
<div id="main-nav"></div>
|
|
</div><!-- top -->
|
|
<!-- 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">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</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_README"></a> Provides additional templates and function helpers for Windows API using Standard C++ in Microsoft Visual C++ 2017-2019</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>
|
|
Lightweight Classes</h2>
|
|
<p >...to simplify Windows allocated memory and resources focused on their release to prevent leakage</p>
|
|
<p >The classes provide unified create methods and free destructors. 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 functions.</p>
|
|
<h3><a class="anchor" id="autotoc_md4"></a>
|
|
Example</h3>
|
|
<div class="fragment"><div class="line"> {C++}</div>
|
|
<div class="line">// Load and set icon.</div>
|
|
<div class="line">winstd::library lib_shell32(LoadLibraryEx(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE));</div>
|
|
<div class="line">if (!lib_shell32)</div>
|
|
<div class="line"> throw winstd::win_runtime_error("LoadLibraryEx failed");</div>
|
|
<div class="line">m_note_icon->SetIcon(wxLoadIconFromResource(lib_shell32, MAKEINTRESOURCE(48)));</div>
|
|
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md5"></a>
|
|
Functions and Templates</h2>
|
|
<p >...to extend standard Win32 API functions for variable-size outputs</p>
|
|
<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"> {C++}</div>
|
|
<div class="line">// Encode response as OEM.</div>
|
|
<div class="line">std::string response;</div>
|
|
<div class="line">WideCharToMultiByte(CP_OEMCP, 0, L"Copyright \u00A9 2017", response, NULL, NULL);</div>
|
|
<div class="line">std::cout << response.c_str() << std::endl;</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>sprintf()</code> or <code>FormatMessage()</code></p>
|
|
<h3><a class="anchor" id="autotoc_md8"></a>
|
|
Example</h3>
|
|
<div class="fragment"><div class="line"> {C++}</div>
|
|
<div class="line">if (dwMaxSendPacketSize < sizeof(EapPacket))</div>
|
|
<div class="line"> throw std::invalid_argument(</div>
|
|
<div class="line"> winstd::string_printf(</div>
|
|
<div class="line"> "Maximum packet size too small (minimum: %zu, available: %u).",</div>
|
|
<div class="line"> sizeof(EapPacket) + 1,</div>
|
|
<div class="line"> dwMaxSendPacketSize));</div>
|
|
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md9"></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"> {C++}</div>
|
|
<div class="line">#include <WinStd/Shell.h></div>
|
|
<div class="line">#include <string></div>
|
|
<div class="line">#include <iostream></div>
|
|
<div class="line"> </div>
|
|
<div class="line">using namespace std;</div>
|
|
<div class="line"> </div>
|
|
<div class="line">void main()</div>
|
|
<div class="line">{</div>
|
|
<div class="line"> wstring path;</div>
|
|
<div class="line"> PathCanonicalizeW(path, L"C:\\Windows\\Temp\\test\\..");</div>
|
|
<div class="line"> wcout << path.c_str() << endl;</div>
|
|
<div class="line">}</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. </p>
|
|
</div></div><!-- PageDoc -->
|
|
</div><!-- contents -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated on Thu Feb 10 2022 11:16:57 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.9.3
|
|
</small></address>
|
|
</body>
|
|
</html>
|