Snippets
(Unterschied zwischen Versionen)
(Die Seite wurde neu angelegt: „<pre> class DbgGuiLeak { public: DbgGuiLeak () { _guiResCount = ::GetGuiResources (::GetCurrentProcess (), …“) |
|||
| (Der Versionsvergleich bezieht 5 dazwischenliegende Versionen mit ein.) | |||
| Zeile 1: | Zeile 1: | ||
| + | = Finding GDI Leaks by counting GDI objects = | ||
<pre> | <pre> | ||
class DbgGuiLeak | class DbgGuiLeak | ||
| Zeile 5: | Zeile 6: | ||
DbgGuiLeak () | DbgGuiLeak () | ||
{ | { | ||
| - | _guiResCount = ::GetGuiResources (::GetCurrentProcess (), | + | _guiResCount = ::GetGuiResources (::GetCurrentProcess (), GR_GDIOBJECTS); |
| - | + | ||
} | } | ||
~DbgGuiLeak () | ~DbgGuiLeak () | ||
{ | { | ||
| - | int leaks = ::GetGuiResources (::GetCurrentProcess (), | + | int leaks = ::GetGuiResources (::GetCurrentProcess (), GR_GDIOBJECTS) - _guiResCount; |
| - | + | ||
if (leaks != 0) | if (leaks != 0) | ||
{ | { | ||
| Zeile 21: | Zeile 20: | ||
}; | }; | ||
</pre> | </pre> | ||
| + | *Quelle: [http://www.relisoft.com/win32/gdileaks.html Reliable Software - GDI Leaks] | ||
| + | *Also Useful: [http://www.freedownloadmanager.org/downloads/GDIView_49337_p/free.htm GDIView] (Tool which shows which GDI resources are allocated from which process) | ||
| + | |||
| + | = Converting GUID to char* = | ||
| + | <pre><code class="cpp"> | ||
| + | #include <atlconv.h> | ||
| + | |||
| + | void main(void) | ||
| + | { | ||
| + | USES_CONVERSION; | ||
| + | OLECHAR* bstrGuid; | ||
| + | StringFromCLSID(<GUID>, &bstrGuid); | ||
| + | printf("%s\n", W2A(bstrGuid)); | ||
| + | ::CoTaskMemFree(bstrGuid); | ||
| + | } | ||
| + | </code></pre> | ||
Aktuelle Version vom 08:42, 20. Mär. 2012
Finding GDI Leaks by counting GDI objects
class DbgGuiLeak
{
public:
DbgGuiLeak ()
{
_guiResCount = ::GetGuiResources (::GetCurrentProcess (), GR_GDIOBJECTS);
}
~DbgGuiLeak ()
{
int leaks = ::GetGuiResources (::GetCurrentProcess (), GR_GDIOBJECTS) - _guiResCount;
if (leaks != 0)
{
std::cout << "Gui Resources Leaked: " << leaks << std::endl;
}
}
private:
unsigned _guiResCount;
};
- Quelle: Reliable Software - GDI Leaks
- Also Useful: GDIView (Tool which shows which GDI resources are allocated from which process)
Converting GUID to char*
<code class="cpp">
#include <atlconv.h>
void main(void)
{
USES_CONVERSION;
OLECHAR* bstrGuid;
StringFromCLSID(<GUID>, &bstrGuid);
printf("%s\n", W2A(bstrGuid));
::CoTaskMemFree(bstrGuid);
}
</code>