143 lines
8.1 KiB
HTML
143 lines
8.1 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">Windows Win32 API using Standard C++</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 templates and function helpers for Windows Win32 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>
|
|
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"> {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 >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", -1, 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><a class="el" href="group___win_std_str_format.html#gac397f655a858a069b3e521940af64331" title="Formats string using printf().">sprintf()</a></code> or <code><a class="el" href="group___win_std_str_format.html#ga78bf19793ce080f2826f56f228d64623" title="Formats a message string.">FormatMessage()</a></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"> {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>
|
|
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"> {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. 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 -->
|
|
</div><!-- contents -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated on Mon Mar 7 2022 14:52:03 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>
|