<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>JEDI Windows API</title>
	<atom:link href="http://blog.delphi-jedi.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.delphi-jedi.net</link>
	<description>Joint Endeavor of Delphi Innovators of Windows Programming</description>
	<pubDate>Sat, 05 Jul 2008 13:35:37 +0000</pubDate>
	<generator>http://wordpress.org/?v=</generator>
	<language>en</language>
			<item>
		<title>The Delphi JEDI Project needs your help</title>
		<link>http://blog.delphi-jedi.net/2008/04/20/the-delphi-jedi-project-needs-your-help/</link>
		<comments>http://blog.delphi-jedi.net/2008/04/20/the-delphi-jedi-project-needs-your-help/#comments</comments>
		<pubDate>Sun, 20 Apr 2008 20:16:40 +0000</pubDate>
		<dc:creator>Remko</dc:creator>
		
		<category><![CDATA[Common]]></category>

		<category><![CDATA[JEDI Windows API Headers]]></category>

		<category><![CDATA[JEDI Windows Security Code Lib]]></category>

		<category><![CDATA[JWA Downloads]]></category>

		<category><![CDATA[JWSCL Downloads]]></category>

		<guid isPermaLink="false">http://blog.delphi-jedi.net/2008/04/20/the-delphi-jedi-project-needs-your-help-2/</guid>
		<description><![CDATA[The JEDI API Library project (JWA) has been successfully revived from a sleep status to an active project with lots of ambitions. Some recent achievements are the new include model of JWA, the release of JWSCL (the Security Library) and of course the &#8220;birth&#8221; of this blog.

We made a roadmap for JWA and JWSCL which [...]]]></description>
			<content:encoded><![CDATA[<p>The JEDI API Library project (JWA) has been successfully revived from a sleep status to an active project with lots of ambitions. Some recent achievements are the new include model of JWA, the release of JWSCL (the Security Library) and of course the &#8220;birth&#8221; of this blog.</p>
<p><span id="more-155"></span></p>
<p>We made a roadmap for JWA and JWSCL which includes &#8220;unicodifying&#8221; (Nick Hodges gave birth to a new word, meaning making the code ready for the next Delphi) and converting new Vista/Server 2008 API&#8217;s.</p>
<p>To help us fullfill these ambitions and continue contributing to the Delphi Community, we are looking for experienced Delphi developers to help us with the following tasks:</p>
<ul>
<li>Maintaining and extending the Jedi API Library (convert new header files, fix errors in existing code).</li>
<li>Maintaining and extending the Jedi Windows Security Code Library (use and test the library, contribute new code, maintain documentation, <em>Active Directory</em>).</li>
<li>Create examples and write blog posts about using JWA and/or JWSCL.</li>
</ul>
<p>See also the <a href="http://blog.delphi-jedi.net/2008/04/09/roadmap-of-jwa-jwscl/" >Roadmap</a> for more details.</p>
<p>Of course you will get something back as well: the JEDI projects are very well known and respected in the Delphi Community, so active participation will earn you the respect of the community and is likely to offer additional benefits to your professional career!</p>
<p>Joining the projects means that you will be part of a team where the members actively support and help each other. You can learn a lot from the team&#8217;s knowledge and expertise and we look forward to learning from your knowledge.</p>
<p>If you think you can help us with either JWA, JWSCL or both projects please contact us:<br />
<a href="http://mailhide.recaptcha.net/d?k=01MeKrDPlF4UMY4OOGe4JcPA==&amp;c=qu6RnFAF5jjxh0bbfE7ymCJCa5TFUIfZS6RdKFzWmME=" onclick="javascript:pageTracker._trackPageview('/outbound/article/mailhide.recaptcha.net');"><img src="http://blog.delphi-jedi.net/wp-content/uploads/2008/04/mail-1.gif" alt="mail" width="129" height="12" /></a></p>
<form id=pdf24Form_155 method="POST" action="http://doc2pdf.pdf24.org/doc2pdf/wordpress.php" style="border: 1px solid silver; padding: 2px;" target="pdf24PopWin" onsubmit="window.open('about:blank', 'pdf24PopWin', 'scrollbars=yes,width=400,height=200,top=0,left=0'); return true;"><input type="hidden" name="blogCharset" value="UTF-8">
<input type="hidden" name="blogPosts" value="1">
<input type="hidden" name="blogUrl" value="http://blog.delphi-jedi.net">
<input type="hidden" name="blogName" value="JEDI Windows API">
<input type="hidden" name="blogValueEncoding" value="htmlSpecialChars">
<input type="hidden" name="postTitle_0" value="The Delphi JEDI Project needs your help">
<input type="hidden" name="postLink_0" value="http://blog.delphi-jedi.net/2008/04/20/the-delphi-jedi-project-needs-your-help/">
<input type="hidden" name="postAuthor_0" value="Remko">
<input type="hidden" name="postDateTime_0" value="2008-04-20 20:04:40">
<input type="hidden" name="postContent_0" value="&lt;p&gt;The JEDI API Library project (JWA) has been successfully revived from a sleep status to an active project with lots of ambitions. Some recent achievements are the new include model of JWA, the release of JWSCL (the Security Library) and of course the &amp;#8220;birth&amp;#8221; of this blog.&lt;/p&gt;
&lt;p&gt;&lt;span id=&quot;more-155&quot;&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;We made a roadmap for JWA and JWSCL which includes &amp;#8220;unicodifying&amp;#8221; (Nick Hodges gave birth to a new word, meaning making the code ready for the next Delphi) and converting new Vista/Server 2008 API&amp;#8217;s.&lt;/p&gt;
&lt;p&gt;To help us fullfill these ambitions and continue contributing to the Delphi Community, we are looking for experienced Delphi developers to help us with the following tasks:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Maintaining and extending the Jedi API Library (convert new header files, fix errors in existing code).&lt;/li&gt;
&lt;li&gt;Maintaining and extending the Jedi Windows Security Code Library (use and test the library, contribute new code, maintain documentation, &lt;em&gt;Active Directory&lt;/em&gt;).&lt;/li&gt;
&lt;li&gt;Create examples and write blog posts about using JWA and/or JWSCL.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;See also the &lt;a href=&quot;http://blog.delphi-jedi.net/2008/04/09/roadmap-of-jwa-jwscl/&quot;&gt;Roadmap&lt;/a&gt; for more details.&lt;/p&gt;
&lt;p&gt;Of course you will get something back as well: the JEDI projects are very well known and respected in the Delphi Community, so active participation will earn you the respect of the community and is likely to offer additional benefits to your professional career!&lt;/p&gt;
&lt;p&gt;Joining the projects means that you will be part of a team where the members actively support and help each other. You can learn a lot from the team&amp;#8217;s knowledge and expertise and we look forward to learning from your knowledge.&lt;/p&gt;
&lt;p&gt;If you think you can help us with either JWA, JWSCL or both projects please contact us:&lt;br /&gt;
&lt;a href=&quot;http://mailhide.recaptcha.net/d?k=01MeKrDPlF4UMY4OOGe4JcPA==&amp;amp;c=qu6RnFAF5jjxh0bbfE7ymCJCa5TFUIfZS6RdKFzWmME=&quot;&gt;&lt;img src=&quot;http://blog.delphi-jedi.net/wp-content/uploads/2008/04/mail-1.gif&quot; alt=&quot;mail&quot; width=&quot;129&quot; height=&quot;12&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
">
<table style="padding:0px; width:100%" border=0><tr><td align="left">Send post as PDF to <input type="text" name="sendEmailTo" value="Enter email address" style="width: 150px" onMouseDown="this.value = '';"> <input type="submit" value="Send" style=""></td><td width="18"><a href="http://www.pdf24.org" target="_blank" title="www.pdf24.org" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.pdf24.org');"><img src="http://www.pdf24.org/images/sheep_16x16.gif" alt="www.pdf24.org" border="0"></a></td></table></form> <span class="post2pdf_span" style="border: 1px solid gray; width: 160px; text-align: left; "><a href="http://blog.delphi-jedi.net/wp-content/plugins/post2pdf/generate.php?post=155" rel="nofollow" ><img src="http://blog.delphi-jedi.net/wp-content/plugins/post2pdf/icon/pdf.png" width="16px" height="16px" />convert this post to pdf.</a></span>]]></content:encoded>
			<wfw:commentRss>http://blog.delphi-jedi.net/2008/04/20/the-delphi-jedi-project-needs-your-help/feed/</wfw:commentRss>
		</item>
		<item>
		<title>We support YOU developing with JWA and JWSCL!</title>
		<link>http://blog.delphi-jedi.net/2008/04/03/we-support-you-developing-with-jwa-and-jwscl/</link>
		<comments>http://blog.delphi-jedi.net/2008/04/03/we-support-you-developing-with-jwa-and-jwscl/#comments</comments>
		<pubDate>Thu, 03 Apr 2008 18:42:59 +0000</pubDate>
		<dc:creator>Christian Wimmer</dc:creator>
		
		<category><![CDATA[Common]]></category>

		<category><![CDATA[JEDI Windows API Headers]]></category>

		<category><![CDATA[JEDI Windows Security Code Lib]]></category>

		<category><![CDATA[HowTo]]></category>

		<category><![CDATA[JWA]]></category>

		<category><![CDATA[JWSCL]]></category>

		<category><![CDATA[support]]></category>

		<guid isPermaLink="false">http://blog.delphi-jedi.net/2008/04/03/we-support-you-developing-with-jwa-and-jwscl/</guid>
		<description><![CDATA[Do you need help? We can support you creating application using JWA and/or JWSCL.
Visit the Get Service site on SourceForge for more information like pricing.










Send post as PDF to   convert this post to pdf.]]></description>
			<content:encoded><![CDATA[<p>Do you need help? We can support you creating application using JWA and/or JWSCL.</p>
<p>Visit the <a href="http://sourceforge.net/services/project_services.php?project_id=121894" onclick="javascript:pageTracker._trackPageview('/outbound/article/sourceforge.net');">Get Service</a> site on SourceForge for more information like pricing.</p>
<form id=pdf24Form_115 method="POST" action="http://doc2pdf.pdf24.org/doc2pdf/wordpress.php" style="border: 1px solid silver; padding: 2px;" target="pdf24PopWin" onsubmit="window.open('about:blank', 'pdf24PopWin', 'scrollbars=yes,width=400,height=200,top=0,left=0'); return true;"><input type="hidden" name="blogCharset" value="UTF-8">
<input type="hidden" name="blogPosts" value="1">
<input type="hidden" name="blogUrl" value="http://blog.delphi-jedi.net">
<input type="hidden" name="blogName" value="JEDI Windows API">
<input type="hidden" name="blogValueEncoding" value="htmlSpecialChars">
<input type="hidden" name="postTitle_0" value="We support YOU developing with JWA and JWSCL!">
<input type="hidden" name="postLink_0" value="http://blog.delphi-jedi.net/2008/04/03/we-support-you-developing-with-jwa-and-jwscl/">
<input type="hidden" name="postAuthor_0" value="Christian Wimmer">
<input type="hidden" name="postDateTime_0" value="2008-04-03 18:04:59">
<input type="hidden" name="postContent_0" value="&lt;p&gt;Do you need help? We can support you creating application using JWA and/or JWSCL.&lt;/p&gt;
&lt;p&gt;Visit the &lt;a href=&quot;http://sourceforge.net/services/project_services.php?project_id=121894&quot;&gt;Get Service&lt;/a&gt; site on SourceForge for more information like pricing.&lt;/p&gt;
">
<table style="padding:0px; width:100%" border=0><tr><td align="left">Send post as PDF to <input type="text" name="sendEmailTo" value="Enter email address" style="width: 150px" onMouseDown="this.value = '';"> <input type="submit" value="Send" style=""></td><td width="18"><a href="http://www.pdf24.org" target="_blank" title="www.pdf24.org" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.pdf24.org');"><img src="http://www.pdf24.org/images/sheep_16x16.gif" alt="www.pdf24.org" border="0"></a></td></table></form> <span class="post2pdf_span" style="border: 1px solid gray; width: 160px; text-align: left; "><a href="http://blog.delphi-jedi.net/wp-content/plugins/post2pdf/generate.php?post=115" rel="nofollow" ><img src="http://blog.delphi-jedi.net/wp-content/plugins/post2pdf/icon/pdf.png" width="16px" height="16px" />convert this post to pdf.</a></span>]]></content:encoded>
			<wfw:commentRss>http://blog.delphi-jedi.net/2008/04/03/we-support-you-developing-with-jwa-and-jwscl/feed/</wfw:commentRss>
		</item>
		<item>
		<title>COM Server tells you sth about opened client connections</title>
		<link>http://blog.delphi-jedi.net/2008/07/01/com-server-tells-you-sth-about-opened-client-connections/</link>
		<comments>http://blog.delphi-jedi.net/2008/07/01/com-server-tells-you-sth-about-opened-client-connections/#comments</comments>
		<pubDate>Tue, 01 Jul 2008 13:59:58 +0000</pubDate>
		<dc:creator>Christian Wimmer</dc:creator>
		
		<category><![CDATA[Common]]></category>

		<category><![CDATA[COM]]></category>

		<guid isPermaLink="false">http://blog.delphi-jedi.net/?p=247</guid>
		<description><![CDATA[If you create a COM Server to serve some clients with COM interfaces (or better their functionality), you maybe get sometimes a dialog box that tells you that there are client connections opened. This happens as soon as you try to close your app. If you want to close it though, you have to explicitly [...]]]></description>
			<content:encoded><![CDATA[<p>If you create a COM Server to serve some clients with COM interfaces (or better their functionality), you maybe get sometimes a dialog box that tells you that there are client connections opened. This happens as soon as you try to close your app. If you want to close it though, you have to explicitly click &#8220;Yes&#8221;.</p>
<p><span id="more-247"></span></p>
<p><a href="http://blog.delphi-jedi.net/wp-content/uploads/2008/07/untitled.jpg" ><img class="alignnone size-medium wp-image-248" title="untitled" src="http://blog.delphi-jedi.net/wp-content/uploads/2008/07/untitled.jpg" alt="COM Server warning" width="300" height="130" /></a></p>
<p>You can prevent this dialog box by setting the property <em>UIInteractive</em> of <em>TComServer</em> to <strong>true</strong>. The COM Server instance is defined in unit <strong>ComServ</strong> by the instance variable <em>ComServer</em>. It also sets <em>ObjectCount</em> which defines the remaining client COM connections. The dialog pops up if this value is greater than zero. In this way you can easily check yourself the whole circumstance and show a dialog yourself if you need it.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">uses</span> ComServ,&#8230;;</div>
</li>
<li class="li1">
<div class="de1">&#8230;</div>
</li>
<li class="li1">
<div class="de1"><span class="me1">ComServer</span>.<span class="me1">UIInteractive</span> := <span class="kw2">false</span>;</div>
</li>
</ol>
</div>
<p>Consider what happens if a dialog box appears in your service app. I did some tests in Windows Vista and found out that the dialog box prevented the service process to be terminated although the service shuts down correctly. So I just set <em>UIInteractive</em> to <strong>false</strong> and it worked fine.</p>
<p>Remember: If a service must be shut down it should do it as fast as possible.</p>
<form id=pdf24Form_247 method="POST" action="http://doc2pdf.pdf24.org/doc2pdf/wordpress.php" style="border: 1px solid silver; padding: 2px;" target="pdf24PopWin" onsubmit="window.open('about:blank', 'pdf24PopWin', 'scrollbars=yes,width=400,height=200,top=0,left=0'); return true;"><input type="hidden" name="blogCharset" value="UTF-8">
<input type="hidden" name="blogPosts" value="1">
<input type="hidden" name="blogUrl" value="http://blog.delphi-jedi.net">
<input type="hidden" name="blogName" value="JEDI Windows API">
<input type="hidden" name="blogValueEncoding" value="htmlSpecialChars">
<input type="hidden" name="postTitle_0" value="COM Server tells you sth about opened client connections">
<input type="hidden" name="postLink_0" value="http://blog.delphi-jedi.net/2008/07/01/com-server-tells-you-sth-about-opened-client-connections/">
<input type="hidden" name="postAuthor_0" value="Christian Wimmer">
<input type="hidden" name="postDateTime_0" value="2008-07-01 15:07:58">
<input type="hidden" name="postContent_0" value="&lt;p&gt;If you create a COM Server to serve some clients with COM interfaces (or better their functionality), you maybe get sometimes a dialog box that tells you that there are client connections opened. This happens as soon as you try to close your app. If you want to close it though, you have to explicitly click &amp;#8220;Yes&amp;#8221;.&lt;/p&gt;
&lt;p&gt;&lt;span id=&quot;more-247&quot;&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://blog.delphi-jedi.net/wp-content/uploads/2008/07/untitled.jpg&quot;&gt;&lt;img class=&quot;alignnone size-medium wp-image-248&quot; title=&quot;untitled&quot; src=&quot;http://blog.delphi-jedi.net/wp-content/uploads/2008/07/untitled.jpg&quot; alt=&quot;COM Server warning&quot; width=&quot;300&quot; height=&quot;130&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can prevent this dialog box by setting the property &lt;em&gt;UIInteractive&lt;/em&gt; of &lt;em&gt;TComServer&lt;/em&gt; to &lt;strong&gt;true&lt;/strong&gt;. The COM Server instance is defined in unit &lt;strong&gt;ComServ&lt;/strong&gt; by the instance variable &lt;em&gt;ComServer&lt;/em&gt;. It also sets &lt;em&gt;ObjectCount&lt;/em&gt; which defines the remaining client COM connections. The dialog pops up if this value is greater than zero. In this way you can easily check yourself the whole circumstance and show a dialog yourself if you need it.&lt;/p&gt;
&lt;div class=&quot;dean_ch&quot; style=&quot;white-space: wrap;&quot;&gt;
&lt;ol&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;uses&lt;/span&gt; ComServ,&amp;#8230;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;#8230;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;me1&quot;&gt;ComServer&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;UIInteractive&lt;/span&gt; := &lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;Consider what happens if a dialog box appears in your service app. I did some tests in Windows Vista and found out that the dialog box prevented the service process to be terminated although the service shuts down correctly. So I just set &lt;em&gt;UIInteractive&lt;/em&gt; to &lt;strong&gt;false&lt;/strong&gt; and it worked fine.&lt;/p&gt;
&lt;p&gt;Remember: If a service must be shut down it should do it as fast as possible.&lt;/p&gt;
">
<table style="padding:0px; width:100%" border=0><tr><td align="left">Send post as PDF to <input type="text" name="sendEmailTo" value="Enter email address" style="width: 150px" onMouseDown="this.value = '';"> <input type="submit" value="Send" style=""></td><td width="18"><a href="http://www.pdf24.org" target="_blank" title="www.pdf24.org" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.pdf24.org');"><img src="http://www.pdf24.org/images/sheep_16x16.gif" alt="www.pdf24.org" border="0"></a></td></table></form> <span class="post2pdf_span" style="border: 1px solid gray; width: 160px; text-align: left; "><a href="http://blog.delphi-jedi.net/wp-content/plugins/post2pdf/generate.php?post=247" rel="nofollow" ><img src="http://blog.delphi-jedi.net/wp-content/plugins/post2pdf/icon/pdf.png" width="16px" height="16px" />convert this post to pdf.</a></span>]]></content:encoded>
			<wfw:commentRss>http://blog.delphi-jedi.net/2008/07/01/com-server-tells-you-sth-about-opened-client-connections/feed/</wfw:commentRss>
		</item>
		<item>
		<title>So you want to write a service&#8230;</title>
		<link>http://blog.delphi-jedi.net/2008/06/22/so-you-want-to-write-a-service/</link>
		<comments>http://blog.delphi-jedi.net/2008/06/22/so-you-want-to-write-a-service/#comments</comments>
		<pubDate>Sat, 21 Jun 2008 22:55:05 +0000</pubDate>
		<dc:creator>Christian Wimmer</dc:creator>
		
		<category><![CDATA[Common]]></category>

		<guid isPermaLink="false">http://blog.delphi-jedi.net/?p=244</guid>
		<description><![CDATA[If you are going to write a service you should consider why you need it to be a service at all. If you can run your application as a standard user, you should do it. A service is a high privileged application that should be created with care and clear thoughts.
So think about your task [...]]]></description>
			<content:encoded><![CDATA[<p>If you are going to write a service you should consider why you need it to be a service at all<a href="http://dict.leo.org/ende?lp=ende&amp;p=thMx..&amp;search=at" onclick="javascript:pageTracker._trackPageview('/outbound/article/dict.leo.org');"></a>. If you can run your application as a standard user, you should do it. A service is a high privileged application that should be created with care and clear thoughts.<br />
So think about your task you want to solve with the application.<span id="more-244"></span></p>
<ul>
<li>Do you need special privileges (e.g. TCB) that only a SYSTEM user can give?</li>
<li>Do you have to keep secrets in a real safe area?</li>
<li>Do you want to support multiple logged on users?</li>
<li>Can the user profit from your service?</li>
<li>Has the application to be active and available all the time?</li>
</ul>
<p>You should say at least Yes twice to have a real reason.</p>
<p>Okay, but you want to get into that domain first. So what should you think of:</p>
<ul>
<li>A service is like a thread that has an execute method and if this method is exits, the service exits. There is no loop by default!</li>
<li>A service cannot communicate with the user through a GUI. In preVista Windows versions, this &#8220;feature&#8221; was only a coincidence which frankly was used quite often (in fact everybody used it). It does not work for Remote desktop Logins or FastUserSwitch.</li>
<li>Use any log mechanism to give status report. Delphi offers the Windows event report mechanism by the method LogMessage.</li>
<li>Use the method ProcessRequests if you go into a loop. This method lets the service respond to the requests of the Windows service control manager. If you just call Sleep your service will be unresponsible.</li>
<li>The <a href="http://msdn.microsoft.com/en-us/library/ms645505.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');">MessageBox</a> API can show a message box on the current user&#8217;s desktop. To make it work add the flag <em>MB_SERVICE_NOTIFICATION</em> to the last parameter. You should also add <em>MB_DEFAULT_DESKTOP_ONLY</em> , so the  messagebox only appears on the user&#8217;s desktop and not on the winlogon or any other desktop. Be aware that in this way you can only show one message at a time. The next message won&#8217;t appear until the first message has been clicked away.In my opinion this API is only good for debugging purposes.  Think of a  computer  which does not have a logged on user. No administrator will every see your message.</li>
<li>You cannot debug a service like any other application by default. Luckily there is remedy. The JEDI API offers a <a href="http://blog.delphi-jedi.net/2008/05/08/runassys-10-preview/" >RunAsSys</a> application that lets you start your Delphi in the SYSTEM context. In this way you just have to do a minor patch to your service source code to make it run like any other application in Delphi.  See my post <a href="http://blog.delphi-jedi.net/2008/05/07/debugging-services-an-easy-way/" >Debugging services: an easy way</a>.</li>
</ul>
<p>There can be thousands of other good advices you should consider. However I didn&#8217;t want to scare you away. Just be aware of the upcoming (possible) problems and try to learn, learn and learn and &#8230;.</p>
<p>If you want to give another good advice, post it here.</p>
<form id=pdf24Form_244 method="POST" action="http://doc2pdf.pdf24.org/doc2pdf/wordpress.php" style="border: 1px solid silver; padding: 2px;" target="pdf24PopWin" onsubmit="window.open('about:blank', 'pdf24PopWin', 'scrollbars=yes,width=400,height=200,top=0,left=0'); return true;"><input type="hidden" name="blogCharset" value="UTF-8">
<input type="hidden" name="blogPosts" value="1">
<input type="hidden" name="blogUrl" value="http://blog.delphi-jedi.net">
<input type="hidden" name="blogName" value="JEDI Windows API">
<input type="hidden" name="blogValueEncoding" value="htmlSpecialChars">
<input type="hidden" name="postTitle_0" value="So you want to write a service&amp;#8230;">
<input type="hidden" name="postLink_0" value="http://blog.delphi-jedi.net/2008/06/22/so-you-want-to-write-a-service/">
<input type="hidden" name="postAuthor_0" value="Christian Wimmer">
<input type="hidden" name="postDateTime_0" value="2008-06-22 00:06:05">
<input type="hidden" name="postContent_0" value="&lt;p&gt;If you are going to write a service you should consider why you need it to be a service at all&lt;a href=&quot;http://dict.leo.org/ende?lp=ende&amp;amp;p=thMx..&amp;amp;search=at&quot;&gt;&lt;/a&gt;. If you can run your application as a standard user, you should do it. A service is a high privileged application that should be created with care and clear thoughts.&lt;br /&gt;
So think about your task you want to solve with the application.&lt;span id=&quot;more-244&quot;&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Do you need special privileges (e.g. TCB) that only a SYSTEM user can give?&lt;/li&gt;
&lt;li&gt;Do you have to keep secrets in a real safe area?&lt;/li&gt;
&lt;li&gt;Do you want to support multiple logged on users?&lt;/li&gt;
&lt;li&gt;Can the user profit from your service?&lt;/li&gt;
&lt;li&gt;Has the application to be active and available all the time?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You should say at least Yes twice to have a real reason.&lt;/p&gt;
&lt;p&gt;Okay, but you want to get into that domain first. So what should you think of:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A service is like a thread that has an execute method and if this method is exits, the service exits. There is no loop by default!&lt;/li&gt;
&lt;li&gt;A service cannot communicate with the user through a GUI. In preVista Windows versions, this &amp;#8220;feature&amp;#8221; was only a coincidence which frankly was used quite often (in fact everybody used it). It does not work for Remote desktop Logins or FastUserSwitch.&lt;/li&gt;
&lt;li&gt;Use any log mechanism to give status report. Delphi offers the Windows event report mechanism by the method LogMessage.&lt;/li&gt;
&lt;li&gt;Use the method ProcessRequests if you go into a loop. This method lets the service respond to the requests of the Windows service control manager. If you just call Sleep your service will be unresponsible.&lt;/li&gt;
&lt;li&gt;The &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms645505.aspx&quot;&gt;MessageBox&lt;/a&gt; API can show a message box on the current user&amp;#8217;s desktop. To make it work add the flag &lt;em&gt;MB_SERVICE_NOTIFICATION&lt;/em&gt; to the last parameter. You should also add &lt;em&gt;MB_DEFAULT_DESKTOP_ONLY&lt;/em&gt; , so the  messagebox only appears on the user&amp;#8217;s desktop and not on the winlogon or any other desktop. Be aware that in this way you can only show one message at a time. The next message won&amp;#8217;t appear until the first message has been clicked away.In my opinion this API is only good for debugging purposes.  Think of a  computer  which does not have a logged on user. No administrator will every see your message.&lt;/li&gt;
&lt;li&gt;You cannot debug a service like any other application by default. Luckily there is remedy. The JEDI API offers a &lt;a href=&quot;http://blog.delphi-jedi.net/2008/05/08/runassys-10-preview/&quot;&gt;RunAsSys&lt;/a&gt; application that lets you start your Delphi in the SYSTEM context. In this way you just have to do a minor patch to your service source code to make it run like any other application in Delphi.  See my post &lt;a href=&quot;http://blog.delphi-jedi.net/2008/05/07/debugging-services-an-easy-way/&quot;&gt;Debugging services: an easy way&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There can be thousands of other good advices you should consider. However I didn&amp;#8217;t want to scare you away. Just be aware of the upcoming (possible) problems and try to learn, learn and learn and &amp;#8230;.&lt;/p&gt;
&lt;p&gt;If you want to give another good advice, post it here.&lt;/p&gt;
">
<table style="padding:0px; width:100%" border=0><tr><td align="left">Send post as PDF to <input type="text" name="sendEmailTo" value="Enter email address" style="width: 150px" onMouseDown="this.value = '';"> <input type="submit" value="Send" style=""></td><td width="18"><a href="http://www.pdf24.org" target="_blank" title="www.pdf24.org" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.pdf24.org');"><img src="http://www.pdf24.org/images/sheep_16x16.gif" alt="www.pdf24.org" border="0"></a></td></table></form> <span class="post2pdf_span" style="border: 1px solid gray; width: 160px; text-align: left; "><a href="http://blog.delphi-jedi.net/wp-content/plugins/post2pdf/generate.php?post=244" rel="nofollow" ><img src="http://blog.delphi-jedi.net/wp-content/plugins/post2pdf/icon/pdf.png" width="16px" height="16px" />convert this post to pdf.</a></span>]]></content:encoded>
			<wfw:commentRss>http://blog.delphi-jedi.net/2008/06/22/so-you-want-to-write-a-service/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Technical note</title>
		<link>http://blog.delphi-jedi.net/2008/06/21/technical-note/</link>
		<comments>http://blog.delphi-jedi.net/2008/06/21/technical-note/#comments</comments>
		<pubDate>Sat, 21 Jun 2008 15:14:07 +0000</pubDate>
		<dc:creator>Apollonius</dc:creator>
		
		<category><![CDATA[Common]]></category>

		<guid isPermaLink="false">http://blog.delphi-jedi.net/?p=243</guid>
		<description><![CDATA[After making some changes to the A-records of the DNS servers responsible for *.delphi-jedi.net, a different host was queried by the clients (e.g. your browsers) for the contents of this blog. Obviously the other host didn&#8217;t know how to react and thus gave back a simple &#8220;no idea what file that is&#8221; (i.e. HTTP error [...]]]></description>
			<content:encoded><![CDATA[<p>After making some changes to the A-records of the DNS servers responsible for *.delphi-jedi.net, a different host was queried by the clients (e.g. your browsers) for the contents of this blog. Obviously the other host didn&#8217;t know how to react and thus gave back a simple &#8220;no idea what file that is&#8221; (i.e. HTTP error 404) in most cases. The issue has been resolved, but it may take some more time for some people until the DNS changes propagate to their DNS servers.</p>
<p>Mail traffic (the MX-record) was not influenced by this at any time. Jabber communication, however, may have been affected by it.</p>
<p>// Oliver</p>
<form id=pdf24Form_243 method="POST" action="http://doc2pdf.pdf24.org/doc2pdf/wordpress.php" style="border: 1px solid silver; padding: 2px;" target="pdf24PopWin" onsubmit="window.open('about:blank', 'pdf24PopWin', 'scrollbars=yes,width=400,height=200,top=0,left=0'); return true;"><input type="hidden" name="blogCharset" value="UTF-8">
<input type="hidden" name="blogPosts" value="1">
<input type="hidden" name="blogUrl" value="http://blog.delphi-jedi.net">
<input type="hidden" name="blogName" value="JEDI Windows API">
<input type="hidden" name="blogValueEncoding" value="htmlSpecialChars">
<input type="hidden" name="postTitle_0" value="Technical note">
<input type="hidden" name="postLink_0" value="http://blog.delphi-jedi.net/2008/06/21/technical-note/">
<input type="hidden" name="postAuthor_0" value="Apollonius">
<input type="hidden" name="postDateTime_0" value="2008-06-21 17:06:07">
<input type="hidden" name="postContent_0" value="&lt;p&gt;After making some changes to the A-records of the DNS servers responsible for *.delphi-jedi.net, a different host was queried by the clients (e.g. your browsers) for the contents of this blog. Obviously the other host didn&amp;#8217;t know how to react and thus gave back a simple &amp;#8220;no idea what file that is&amp;#8221; (i.e. HTTP error 404) in most cases. The issue has been resolved, but it may take some more time for some people until the DNS changes propagate to their DNS servers.&lt;/p&gt;
&lt;p&gt;Mail traffic (the MX-record) was not influenced by this at any time. Jabber communication, however, may have been affected by it.&lt;/p&gt;
&lt;p&gt;// Oliver&lt;/p&gt;
">
<table style="padding:0px; width:100%" border=0><tr><td align="left">Send post as PDF to <input type="text" name="sendEmailTo" value="Enter email address" style="width: 150px" onMouseDown="this.value = '';"> <input type="submit" value="Send" style=""></td><td width="18"><a href="http://www.pdf24.org" target="_blank" title="www.pdf24.org" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.pdf24.org');"><img src="http://www.pdf24.org/images/sheep_16x16.gif" alt="www.pdf24.org" border="0"></a></td></table></form> <span class="post2pdf_span" style="border: 1px solid gray; width: 160px; text-align: left; "><a href="http://blog.delphi-jedi.net/wp-content/plugins/post2pdf/generate.php?post=243" rel="nofollow" ><img src="http://blog.delphi-jedi.net/wp-content/plugins/post2pdf/icon/pdf.png" width="16px" height="16px" />convert this post to pdf.</a></span>]]></content:encoded>
			<wfw:commentRss>http://blog.delphi-jedi.net/2008/06/21/technical-note/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Don&#8217;t misspell your target desktop&#8230;</title>
		<link>http://blog.delphi-jedi.net/2008/06/19/dont-misspell-your-target-desktop/</link>
		<comments>http://blog.delphi-jedi.net/2008/06/19/dont-misspell-your-target-desktop/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 22:58:26 +0000</pubDate>
		<dc:creator>Christian Wimmer</dc:creator>
		
		<category><![CDATA[Common]]></category>

		<guid isPermaLink="false">http://blog.delphi-jedi.net/?p=242</guid>
		<description><![CDATA[If you want to use CreateProcess or CreateProcessAsUser and you also want to set the target desktop, you should make sure that the target winstation (usual winsta0) and desktop name (usual default) is spelled correctly.
If you misspell the name (say defaut instead of default - missing l ) the process creation may succeed but your [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to use <em>CreateProcess </em>or <em>CreateProcessAsUser</em> and you also want to set the target desktop, you should make sure that the target winstation (usual <em>winsta0</em>) and desktop name (usual <em>default</em>) is spelled correctly.<br />
If you misspell the name (say <strong>defaut</strong> instead of <strong>default</strong> - missing l ) the process creation may succeed but your application won&#8217;t show but start running.</p>
<form id=pdf24Form_242 method="POST" action="http://doc2pdf.pdf24.org/doc2pdf/wordpress.php" style="border: 1px solid silver; padding: 2px;" target="pdf24PopWin" onsubmit="window.open('about:blank', 'pdf24PopWin', 'scrollbars=yes,width=400,height=200,top=0,left=0'); return true;"><input type="hidden" name="blogCharset" value="UTF-8">
<input type="hidden" name="blogPosts" value="1">
<input type="hidden" name="blogUrl" value="http://blog.delphi-jedi.net">
<input type="hidden" name="blogName" value="JEDI Windows API">
<input type="hidden" name="blogValueEncoding" value="htmlSpecialChars">
<input type="hidden" name="postTitle_0" value="Don&amp;#8217;t misspell your target desktop&amp;#8230;">
<input type="hidden" name="postLink_0" value="http://blog.delphi-jedi.net/2008/06/19/dont-misspell-your-target-desktop/">
<input type="hidden" name="postAuthor_0" value="Christian Wimmer">
<input type="hidden" name="postDateTime_0" value="2008-06-19 00:06:26">
<input type="hidden" name="postContent_0" value="&lt;p&gt;If you want to use &lt;em&gt;CreateProcess &lt;/em&gt;or &lt;em&gt;CreateProcessAsUser&lt;/em&gt; and you also want to set the target desktop, you should make sure that the target winstation (usual &lt;em&gt;winsta0&lt;/em&gt;) and desktop name (usual &lt;em&gt;default&lt;/em&gt;) is spelled correctly.&lt;br /&gt;
If you misspell the name (say &lt;strong&gt;defaut&lt;/strong&gt; instead of &lt;strong&gt;default&lt;/strong&gt; - missing l ) the process creation may succeed but your application won&amp;#8217;t show but start running.&lt;/p&gt;
">
<table style="padding:0px; width:100%" border=0><tr><td align="left">Send post as PDF to <input type="text" name="sendEmailTo" value="Enter email address" style="width: 150px" onMouseDown="this.value = '';"> <input type="submit" value="Send" style=""></td><td width="18"><a href="http://www.pdf24.org" target="_blank" title="www.pdf24.org" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.pdf24.org');"><img src="http://www.pdf24.org/images/sheep_16x16.gif" alt="www.pdf24.org" border="0"></a></td></table></form> <span class="post2pdf_span" style="border: 1px solid gray; width: 160px; text-align: left; "><a href="http://blog.delphi-jedi.net/wp-content/plugins/post2pdf/generate.php?post=242" rel="nofollow" ><img src="http://blog.delphi-jedi.net/wp-content/plugins/post2pdf/icon/pdf.png" width="16px" height="16px" />convert this post to pdf.</a></span>]]></content:encoded>
			<wfw:commentRss>http://blog.delphi-jedi.net/2008/06/19/dont-misspell-your-target-desktop/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Calculating Binary Hashes using TJwFileStreamEx</title>
		<link>http://blog.delphi-jedi.net/2008/06/17/239/</link>
		<comments>http://blog.delphi-jedi.net/2008/06/17/239/#comments</comments>
		<pubDate>Tue, 17 Jun 2008 08:50:37 +0000</pubDate>
		<dc:creator>NeutralGeneral</dc:creator>
		
		<category><![CDATA[JEDI Windows Security Code Lib]]></category>

		<category><![CDATA[JWSCL Downloads]]></category>

		<category><![CDATA[JWSCL]]></category>

		<category><![CDATA[Memory Mapped Files]]></category>

		<category><![CDATA[MMF]]></category>

		<category><![CDATA[Streams]]></category>

		<guid isPermaLink="false">http://blog.delphi-jedi.net/?p=239</guid>
		<description><![CDATA[Calculating Binary Hashes using TJwFileStreamEx
Why should I use TJwFileStreamEx instead of any other common stream class from the VCL?
Well this question is quite easily answered.
The first thing is that TJwFileStreamEx is based on Memory Mapped Files (MMF). MMF might be the fastest way to access files on your hard disk. Another good reason for using [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: small;"><strong>Calculating Binary Hashes using TJwFileStreamEx</strong></span></p>
<p><strong>Why should I use TJwFileStreamEx instead of any other common stream class from the VCL?</strong></p>
<p>Well this question is quite easily answered.</p>
<p>The first thing is that TJwFileStreamEx is based on Memory Mapped Files (MMF). MMF might be the fastest way to access files on your hard disk. Another good reason for using TJwFileStreamEx is its <em>Memory</em> property which is well known from the VCL <strong>TMemoryStream</strong> class. This property will reduce the effort remarkably.</p>
<p><strong>Getting Started</strong></p>
<p>First you have to include following units to your project:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">uses</span> JwsclTypes, JwsclStreams, JwsclCryptProvider;</div>
</li>
</ol>
</div>
<p>The signature of our hashing-function looks like this:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">function</span> GetFileHash<span class="br0">&#40;</span>Algorithm: TJwHashAlgorithm; <span class="kw1">const</span> Filename: <span class="kw4">String</span><span class="br0">&#41;</span> : <span class="kw4">String</span>;</div>
</li>
</ol>
</div>
<p>The first parameter is used to specify the Algorithm which is used to hash the file data. The second parameter defines the path to the file which hash you want to compute.</p>
<p>So what do we need to calculate the hash of a file? All we need is an instance of TJwFileStreamEx to open the file and an instance of TJwHash to calculate the hash:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">function</span> GetFileHash<span class="br0">&#40;</span>Algorithm: TJwHashAlgorithm; <span class="kw1">const</span> Filename: <span class="kw4">String</span><span class="br0">&#41;</span> : <span class="kw4">String</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">var</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; Stream: TJwFileStreamEx;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; Hash: TJwHash;</div>
</li>
<li class="li2">
<div class="de2"><span class="kw1">begin</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; Stream := TJwFileStreamEx.<span class="me1">Create</span><span class="br0">&#40;</span>Filename,fmOpenRead<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">try</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; Hash := TJwHash.<span class="me1">Create</span><span class="br0">&#40;</span>Algorithm<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="co1">// Calculate and return the Hash as a Hex-String</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="kw1">finally</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; Hash.<span class="me1">Free</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; Stream.<span class="me1">Free</span>; &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span>;</div>
</li>
</ol>
</div>
<p>This is the basic framework of our function. To calculate the hash of the file we need 2 methods:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">TJwHash.<span class="me1">HashData</span><span class="br0">&#40;</span>Data: <span class="kw4">Pointer</span>; Size: <span class="kw4">Cardinal</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">TJwHash.<span class="me1">RetrieveHash</span><span class="br0">&#40;</span>out Len: <span class="kw4">Cardinal</span><span class="br0">&#41;</span>: <span class="kw4">Pointer</span>;</div>
</li>
</ol>
</div>
<p>HashData tells our instance of TJwHash which data is to be hashed and which size this data has. RetrieveHash calculates the Hash and retrieves a pointer to the hash data.</p>
<p>Finally we have to free the Buffer using the class method</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">TJwHash.<span class="me1">FreeBuffer</span><span class="br0">&#40;</span>Buffer: <span class="kw4">Pointer</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>Now our function looks like this:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">function</span> GetFileHash<span class="br0">&#40;</span>Algorithm: TJwHashAlgorithm; <span class="kw1">const</span> Filename: <span class="kw4">String</span><span class="br0">&#41;</span> : <span class="kw4">String</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">var</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; Stream: TJwFileStreamEx;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; Hash: TJwHash;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; HashSize: <span class="kw4">Cardinal</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; HashData: <span class="kw4">Pointer</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">begin</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; Stream := TJwFileStreamEx.<span class="me1">Create</span><span class="br0">&#40;</span>Filename,fmOpenRead<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; Hash := TJwHash.<span class="me1">Create</span><span class="br0">&#40;</span>Algorithm<span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="kw1">try</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; Hash.<span class="me1">HashData</span><span class="br0">&#40;</span>Stream.<span class="me1">Memory</span>,Stream.<span class="me1">Size</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; HashData := Hash.<span class="me1">RetrieveHash</span><span class="br0">&#40;</span>HashSize<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; TJwHash.<span class="me1">FreeBuffer</span><span class="br0">&#40;</span>HashData<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">finally</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; Hash.<span class="me1">Free</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; Stream.<span class="me1">Free</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span>;</div>
</li>
</ol>
</div>
<p>At last we need to convert the binary hash into a hex-string:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">for</span> i:= <span class="nu0">1</span> <span class="kw1">to</span> HashSize <span class="kw1">do</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">begin</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; Result := Result + <span class="kw3">IntToHex</span><span class="br0">&#40;</span><span class="kw4">PByte</span><span class="br0">&#40;</span>HashData<span class="br0">&#41;</span>^,<span class="nu0">2</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw3">inc</span><span class="br0">&#40;</span><span class="kw4">PByte</span><span class="br0">&#40;</span>HashData<span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2"><span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">dec</span><span class="br0">&#40;</span><span class="kw4">PByte</span><span class="br0">&#40;</span>HashData<span class="br0">&#41;</span>,HashSize<span class="br0">&#41;</span>; <span class="co1">//neccessary to free HashData</span></div>
</li>
</ol>
</div>
<p>Now we&#8217;re done and finally our function looks like this:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">function</span> GetFileHash<span class="br0">&#40;</span>Algorithm: TJwHashAlgorithm; <span class="kw1">const</span> Filename: <span class="kw4">String</span><span class="br0">&#41;</span> : <span class="kw4">String</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">var</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; Stream: TJwFileStreamEx;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; Hash: TJwHash;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; HashSize: <span class="kw4">Cardinal</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; HashData: <span class="kw4">Pointer</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; i: <span class="kw4">Integer</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">begin</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; Stream := TJwFileStreamEx.<span class="me1">Create</span><span class="br0">&#40;</span>Filename,fmOpenRead<span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; Hash := TJwHash.<span class="me1">Create</span><span class="br0">&#40;</span>Algorithm<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">try</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; Hash.<span class="me1">HashData</span><span class="br0">&#40;</span>Stream.<span class="me1">Memory</span>,Stream.<span class="me1">Size</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; HashData := Hash.<span class="me1">RetrieveHash</span><span class="br0">&#40;</span>HashSize<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="kw1">for</span> i:= <span class="nu0">1</span> <span class="kw1">to</span> HashSize <span class="kw1">do</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">begin</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; Result := Result + <span class="kw3">IntToHex</span><span class="br0">&#40;</span><span class="kw4">PByte</span><span class="br0">&#40;</span>HashData<span class="br0">&#41;</span>^,<span class="nu0">2</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw3">inc</span><span class="br0">&#40;</span><span class="kw4">PByte</span><span class="br0">&#40;</span>HashData<span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">end</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="kw3">dec</span><span class="br0">&#40;</span><span class="kw4">PByte</span><span class="br0">&#40;</span>HashData<span class="br0">&#41;</span>,HashSize<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; TJwHash.<span class="me1">FreeBuffer</span><span class="br0">&#40;</span>HashData<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">finally</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; Hash.<span class="me1">Free</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; Stream.<span class="me1">Free</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span>;</div>
</li>
</ol>
</div>
<p><strong>How do I use this function?</strong></p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="co1">// first param can be one of these values:</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// haMD2, haMD4, haMD5, haSHA</span></div>
</li>
<li class="li1">
<div class="de1">Label1.<span class="me1">Caption</span> := GetFileHash<span class="br0">&#40;</span>haSHA,<span class="st0">&#8216;C:\Progam Files\Program\AFile.ext&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p><strong>OK, but what is the advantage of TJwFileStreamEx over other Streams?</strong></p>
<p>Well, you don&#8217;t have to load the file into a TMemoryStream and thus the file will not be loaded completely into memory. Furthermore this solution is much faster than a solution using TMemoryStream and similar&#8230;</p>
<h2>Download</h2>
<p><a href="http://blog.delphi-jedi.net/wp-content/uploads/2008/06/jwfilestreamex_demo.zip" onclick="javascript:pageTracker._trackPageview('/downloadsblog./wp-content/uploads/2008/06/jwfilestreamex_demo.zip');">Download</a> the source and binaries of this example (260kiB). This includes the new and necessary JWSCL source files. However you need to download the whole package separately.</p>
<form id=pdf24Form_239 method="POST" action="http://doc2pdf.pdf24.org/doc2pdf/wordpress.php" style="border: 1px solid silver; padding: 2px;" target="pdf24PopWin" onsubmit="window.open('about:blank', 'pdf24PopWin', 'scrollbars=yes,width=400,height=200,top=0,left=0'); return true;"><input type="hidden" name="blogCharset" value="UTF-8">
<input type="hidden" name="blogPosts" value="1">
<input type="hidden" name="blogUrl" value="http://blog.delphi-jedi.net">
<input type="hidden" name="blogName" value="JEDI Windows API">
<input type="hidden" name="blogValueEncoding" value="htmlSpecialChars">
<input type="hidden" name="postTitle_0" value="Calculating Binary Hashes using TJwFileStreamEx">
<input type="hidden" name="postLink_0" value="http://blog.delphi-jedi.net/2008/06/17/239/">
<input type="hidden" name="postAuthor_0" value="NeutralGeneral">
<input type="hidden" name="postDateTime_0" value="2008-06-17 10:06:37">
<input type="hidden" name="postContent_0" value="&lt;p&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;strong&gt;Calculating Binary Hashes using TJwFileStreamEx&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Why should I use TJwFileStreamEx instead of any other common stream class from the VCL?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Well this question is quite easily answered.&lt;/p&gt;
&lt;p&gt;The first thing is that TJwFileStreamEx is based on Memory Mapped Files (MMF). MMF might be the fastest way to access files on your hard disk. Another good reason for using TJwFileStreamEx is its &lt;em&gt;Memory&lt;/em&gt; property which is well known from the VCL &lt;strong&gt;TMemoryStream&lt;/strong&gt; class. This property will reduce the effort remarkably.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Getting Started&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;First you have to include following units to your project:&lt;/p&gt;
&lt;div class=&quot;dean_ch&quot; style=&quot;white-space: wrap;&quot;&gt;
&lt;ol&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;uses&lt;/span&gt; JwsclTypes, JwsclStreams, JwsclCryptProvider;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;The signature of our hashing-function looks like this:&lt;/p&gt;
&lt;div class=&quot;dean_ch&quot; style=&quot;white-space: wrap;&quot;&gt;
&lt;ol&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;function&lt;/span&gt; GetFileHash&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Algorithm: TJwHashAlgorithm; &lt;span class=&quot;kw1&quot;&gt;const&lt;/span&gt; Filename: &lt;span class=&quot;kw4&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span class=&quot;kw4&quot;&gt;String&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;The first parameter is used to specify the Algorithm which is used to hash the file data. The second parameter defines the path to the file which hash you want to compute.&lt;/p&gt;
&lt;p&gt;So what do we need to calculate the hash of a file? All we need is an instance of TJwFileStreamEx to open the file and an instance of TJwHash to calculate the hash:&lt;/p&gt;
&lt;div class=&quot;dean_ch&quot; style=&quot;white-space: wrap;&quot;&gt;
&lt;ol&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;function&lt;/span&gt; GetFileHash&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Algorithm: TJwHashAlgorithm; &lt;span class=&quot;kw1&quot;&gt;const&lt;/span&gt; Filename: &lt;span class=&quot;kw4&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span class=&quot;kw4&quot;&gt;String&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;var&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; Stream: TJwFileStreamEx;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; Hash: TJwHash;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li2&quot;&gt;
&lt;div class=&quot;de2&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;begin&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; Stream := TJwFileStreamEx.&lt;span class=&quot;me1&quot;&gt;Create&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Filename,fmOpenRead&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;try&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; Hash := TJwHash.&lt;span class=&quot;me1&quot;&gt;Create&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Algorithm&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;co1&quot;&gt;// Calculate and return the Hash as a Hex-String&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li2&quot;&gt;
&lt;div class=&quot;de2&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;finally&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; Hash.&lt;span class=&quot;me1&quot;&gt;Free&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; Stream.&lt;span class=&quot;me1&quot;&gt;Free&lt;/span&gt;; &amp;nbsp;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;end&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;end&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;This is the basic framework of our function. To calculate the hash of the file we need 2 methods:&lt;/p&gt;
&lt;div class=&quot;dean_ch&quot; style=&quot;white-space: wrap;&quot;&gt;
&lt;ol&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;TJwHash.&lt;span class=&quot;me1&quot;&gt;HashData&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Data: &lt;span class=&quot;kw4&quot;&gt;Pointer&lt;/span&gt;; Size: &lt;span class=&quot;kw4&quot;&gt;Cardinal&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;TJwHash.&lt;span class=&quot;me1&quot;&gt;RetrieveHash&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;out Len: &lt;span class=&quot;kw4&quot;&gt;Cardinal&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;: &lt;span class=&quot;kw4&quot;&gt;Pointer&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;HashData tells our instance of TJwHash which data is to be hashed and which size this data has. RetrieveHash calculates the Hash and retrieves a pointer to the hash data.&lt;/p&gt;
&lt;p&gt;Finally we have to free the Buffer using the class method&lt;/p&gt;
&lt;div class=&quot;dean_ch&quot; style=&quot;white-space: wrap;&quot;&gt;
&lt;ol&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;TJwHash.&lt;span class=&quot;me1&quot;&gt;FreeBuffer&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Buffer: &lt;span class=&quot;kw4&quot;&gt;Pointer&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;Now our function looks like this:&lt;/p&gt;
&lt;div class=&quot;dean_ch&quot; style=&quot;white-space: wrap;&quot;&gt;
&lt;ol&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;function&lt;/span&gt; GetFileHash&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Algorithm: TJwHashAlgorithm; &lt;span class=&quot;kw1&quot;&gt;const&lt;/span&gt; Filename: &lt;span class=&quot;kw4&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span class=&quot;kw4&quot;&gt;String&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;var&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; Stream: TJwFileStreamEx;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; Hash: TJwHash;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li2&quot;&gt;
&lt;div class=&quot;de2&quot;&gt;&amp;nbsp; HashSize: &lt;span class=&quot;kw4&quot;&gt;Cardinal&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; HashData: &lt;span class=&quot;kw4&quot;&gt;Pointer&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;begin&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; Stream := TJwFileStreamEx.&lt;span class=&quot;me1&quot;&gt;Create&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Filename,fmOpenRead&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; Hash := TJwHash.&lt;span class=&quot;me1&quot;&gt;Create&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Algorithm&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li2&quot;&gt;
&lt;div class=&quot;de2&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;try&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; Hash.&lt;span class=&quot;me1&quot;&gt;HashData&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Stream.&lt;span class=&quot;me1&quot;&gt;Memory&lt;/span&gt;,Stream.&lt;span class=&quot;me1&quot;&gt;Size&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; HashData := Hash.&lt;span class=&quot;me1&quot;&gt;RetrieveHash&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;HashSize&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; TJwHash.&lt;span class=&quot;me1&quot;&gt;FreeBuffer&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;HashData&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;finally&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li2&quot;&gt;
&lt;div class=&quot;de2&quot;&gt;&amp;nbsp; &amp;nbsp; Hash.&lt;span class=&quot;me1&quot;&gt;Free&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; Stream.&lt;span class=&quot;me1&quot;&gt;Free&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;end&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;end&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;At last we need to convert the binary hash into a hex-string:&lt;/p&gt;
&lt;div class=&quot;dean_ch&quot; style=&quot;white-space: wrap;&quot;&gt;
&lt;ol&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt; i:= &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;to&lt;/span&gt; HashSize &lt;span class=&quot;kw1&quot;&gt;do&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;begin&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; Result := Result + &lt;span class=&quot;kw3&quot;&gt;IntToHex&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;PByte&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;HashData&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;^,&lt;span class=&quot;nu0&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw3&quot;&gt;inc&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;PByte&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;HashData&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li2&quot;&gt;
&lt;div class=&quot;de2&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;end&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;dec&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;PByte&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;HashData&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;,HashSize&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span class=&quot;co1&quot;&gt;//neccessary to free HashData&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;Now we&amp;#8217;re done and finally our function looks like this:&lt;/p&gt;
&lt;div class=&quot;dean_ch&quot; style=&quot;white-space: wrap;&quot;&gt;
&lt;ol&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;function&lt;/span&gt; GetFileHash&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Algorithm: TJwHashAlgorithm; &lt;span class=&quot;kw1&quot;&gt;const&lt;/span&gt; Filename: &lt;span class=&quot;kw4&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span class=&quot;kw4&quot;&gt;String&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;var&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; Stream: TJwFileStreamEx;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; Hash: TJwHash;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li2&quot;&gt;
&lt;div class=&quot;de2&quot;&gt;&amp;nbsp; HashSize: &lt;span class=&quot;kw4&quot;&gt;Cardinal&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; HashData: &lt;span class=&quot;kw4&quot;&gt;Pointer&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; i: &lt;span class=&quot;kw4&quot;&gt;Integer&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;begin&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; Stream := TJwFileStreamEx.&lt;span class=&quot;me1&quot;&gt;Create&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Filename,fmOpenRead&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li2&quot;&gt;
&lt;div class=&quot;de2&quot;&gt;&amp;nbsp; Hash := TJwHash.&lt;span class=&quot;me1&quot;&gt;Create&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Algorithm&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;try&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; Hash.&lt;span class=&quot;me1&quot;&gt;HashData&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Stream.&lt;span class=&quot;me1&quot;&gt;Memory&lt;/span&gt;,Stream.&lt;span class=&quot;me1&quot;&gt;Size&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; HashData := Hash.&lt;span class=&quot;me1&quot;&gt;RetrieveHash&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;HashSize&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li2&quot;&gt;
&lt;div class=&quot;de2&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt; i:= &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;to&lt;/span&gt; HashSize &lt;span class=&quot;kw1&quot;&gt;do&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;begin&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Result := Result + &lt;span class=&quot;kw3&quot;&gt;IntToHex&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;PByte&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;HashData&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;^,&lt;span class=&quot;nu0&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw3&quot;&gt;inc&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;PByte&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;HashData&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;end&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li2&quot;&gt;
&lt;div class=&quot;de2&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw3&quot;&gt;dec&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;PByte&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;HashData&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;,HashSize&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; TJwHash.&lt;span class=&quot;me1&quot;&gt;FreeBuffer&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;HashData&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;finally&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; Hash.&lt;span class=&quot;me1&quot;&gt;Free&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li2&quot;&gt;
&lt;div class=&quot;de2&quot;&gt;&amp;nbsp; &amp;nbsp; Stream.&lt;span class=&quot;me1&quot;&gt;Free&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;end&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;end&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;How do I use this function?&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;dean_ch&quot; style=&quot;white-space: wrap;&quot;&gt;
&lt;ol&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co1&quot;&gt;// first param can be one of these values:&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co1&quot;&gt;// haMD2, haMD4, haMD5, haSHA&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;Label1.&lt;span class=&quot;me1&quot;&gt;Caption&lt;/span&gt; := GetFileHash&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;haSHA,&lt;span class=&quot;st0&quot;&gt;&amp;#8216;C:\Progam Files\Program\AFile.ext&amp;#8217;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;OK, but what is the advantage of TJwFileStreamEx over other Streams?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Well, you don&amp;#8217;t have to load the file into a TMemoryStream and thus the file will not be loaded completely into memory. Furthermore this solution is much faster than a solution using TMemoryStream and similar&amp;#8230;&lt;/p&gt;
&lt;h2&gt;Download&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;http://blog.delphi-jedi.net/wp-content/uploads/2008/06/jwfilestreamex_demo.zip&quot;&gt;Download&lt;/a&gt; the source and binaries of this example (260kiB). This includes the new and necessary JWSCL source files. However you need to download the whole package separately.&lt;/p&gt;
">
<table style="padding:0px; width:100%" border=0><tr><td align="left">Send post as PDF to <input type="text" name="sendEmailTo" value="Enter email address" style="width: 150px" onMouseDown="this.value = '';"> <input type="submit" value="Send" style=""></td><td width="18"><a href="http://www.pdf24.org" target="_blank" title="www.pdf24.org" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.pdf24.org');"><img src="http://www.pdf24.org/images/sheep_16x16.gif" alt="www.pdf24.org" border="0"></a></td></table></form> <span class="post2pdf_span" style="border: 1px solid gray; width: 160px; text-align: left; "><a href="http://blog.delphi-jedi.net/wp-content/plugins/post2pdf/generate.php?post=239" rel="nofollow" ><img src="http://blog.delphi-jedi.net/wp-content/plugins/post2pdf/icon/pdf.png" width="16px" height="16px" />convert this post to pdf.</a></span>]]></content:encoded>
			<wfw:commentRss>http://blog.delphi-jedi.net/2008/06/17/239/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Issuetracker</title>
		<link>http://blog.delphi-jedi.net/2008/06/15/issuetracker/</link>
		<comments>http://blog.delphi-jedi.net/2008/06/15/issuetracker/#comments</comments>
		<pubDate>Sun, 15 Jun 2008 14:46:15 +0000</pubDate>
		<dc:creator>Christian Wimmer</dc:creator>
		
		<category><![CDATA[Common]]></category>

		<guid isPermaLink="false">http://blog.delphi-jedi.net/?p=241</guid>
		<description><![CDATA[The JEDI Community has an issue tracker where you can submit bugs, features and fixes. Please use this tracker for both JEDI projects API and WSCL.
http://homepages.borland.com/jedi/issuetracker
Switch to project &#8220;JEDI API&#8221; in the drop down field in the top right corner of the page.










Send post as PDF to   convert this post to pdf.]]></description>
			<content:encoded><![CDATA[<p>The JEDI Community has an issue tracker where you can submit bugs, features and fixes. Please use this tracker for both JEDI projects API and WSCL.</p>
<p><a href="http://homepages.borland.com/jedi/issuetracker" onclick="javascript:pageTracker._trackPageview('/outbound/article/homepages.borland.com');">http://homepages.borland.com/jedi/issuetracker</a></p>
<p>Switch to project &#8220;JEDI API&#8221; in the drop down field in the top right corner of the page.</p>
<form id=pdf24Form_241 method="POST" action="http://doc2pdf.pdf24.org/doc2pdf/wordpress.php" style="border: 1px solid silver; padding: 2px;" target="pdf24PopWin" onsubmit="window.open('about:blank', 'pdf24PopWin', 'scrollbars=yes,width=400,height=200,top=0,left=0'); return true;"><input type="hidden" name="blogCharset" value="UTF-8">
<input type="hidden" name="blogPosts" value="1">
<input type="hidden" name="blogUrl" value="http://blog.delphi-jedi.net">
<input type="hidden" name="blogName" value="JEDI Windows API">
<input type="hidden" name="blogValueEncoding" value="htmlSpecialChars">
<input type="hidden" name="postTitle_0" value="Issuetracker">
<input type="hidden" name="postLink_0" value="http://blog.delphi-jedi.net/2008/06/15/issuetracker/">
<input type="hidden" name="postAuthor_0" value="Christian Wimmer">
<input type="hidden" name="postDateTime_0" value="2008-06-15 16:06:15">
<input type="hidden" name="postContent_0" value="&lt;p&gt;The JEDI Community has an issue tracker where you can submit bugs, features and fixes. Please use this tracker for both JEDI projects API and WSCL.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://homepages.borland.com/jedi/issuetracker&quot;&gt;http://homepages.borland.com/jedi/issuetracker&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Switch to project &amp;#8220;JEDI API&amp;#8221; in the drop down field in the top right corner of the page.&lt;/p&gt;
">
<table style="padding:0px; width:100%" border=0><tr><td align="left">Send post as PDF to <input type="text" name="sendEmailTo" value="Enter email address" style="width: 150px" onMouseDown="this.value = '';"> <input type="submit" value="Send" style=""></td><td width="18"><a href="http://www.pdf24.org" target="_blank" title="www.pdf24.org" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.pdf24.org');"><img src="http://www.pdf24.org/images/sheep_16x16.gif" alt="www.pdf24.org" border="0"></a></td></table></form> <span class="post2pdf_span" style="border: 1px solid gray; width: 160px; text-align: left; "><a href="http://blog.delphi-jedi.net/wp-content/plugins/post2pdf/generate.php?post=241" rel="nofollow" ><img src="http://blog.delphi-jedi.net/wp-content/plugins/post2pdf/icon/pdf.png" width="16px" height="16px" />convert this post to pdf.</a></span>]]></content:encoded>
			<wfw:commentRss>http://blog.delphi-jedi.net/2008/06/15/issuetracker/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Winlogon Notification Package</title>
		<link>http://blog.delphi-jedi.net/2008/05/27/winlogon-notification-package/</link>
		<comments>http://blog.delphi-jedi.net/2008/05/27/winlogon-notification-package/#comments</comments>
		<pubDate>Tue, 27 May 2008 18:07:05 +0000</pubDate>
		<dc:creator>Christian Wimmer</dc:creator>
		
		<category><![CDATA[JEDI Windows API Headers]]></category>

		<category><![CDATA[JWA Downloads]]></category>

		<category><![CDATA[JWA]]></category>

		<category><![CDATA[winlogon]]></category>

		<guid isPermaLink="false">http://blog.delphi-jedi.net/?p=234</guid>
		<description><![CDATA[What is that? MSDN say&#8217;s: A Winlogon Notification Package is a DLL that exports functions that handle Winlogon events. For example, when a user logs onto the system, Winlogon calls each notification package&#8217;s logon event handler function to provide information about the event.
So you might know, the mechanism of Winlogon Notification Package is available in [...]]]></description>
			<content:encoded><![CDATA[<p><strong>What is that? MSDN say&#8217;s: </strong><em>A Winlogon Notification Package is a DLL that exports functions that handle Winlogon events. For example, when a user logs onto the system, Winlogon calls each notification package&#8217;s logon event handler function to provide information about the event.</em></p>
<p>So you might know, the mechanism of Winlogon Notification Package is available in Windows 2000, Windows XP and Windows 2003 Server. In contrast to Windows Vista, it is completely different, maybe I’ll come back with separate tutorial describing how to build a notification package for Windows Vista.</p>
<p>I&#8217;m going to demonstrate here, how to create such a notification package and as a special gift, we will learn how to create a PNG image with drop shadow effect, which we will use later to draw a transparent window inside the Winlogon Desktop.</p>
<p><a href="http://blog.delphi-jedi.net/wp-content/uploads/2008/05/capture.jpg" ><img class="alignnone size-thumbnail wp-image-230" title="capture" src="http://blog.delphi-jedi.net/wp-content/uploads/2008/05/capture.jpg" alt="Winlogon" width="301" height="221" /></a></p>
<p>It&#8217;s time for our <strong>Winlogon Notification Package</strong>. Start Delphi and create a new DLL project.</p>
<p>What we need to do next is to define the Message Callback and the WLXNotificationInfo, as described in <a href="http://msdn.microsoft.com/en-us/library/aa381183(VS.85).aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');">MSDN</a></p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">Type</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// this callback function does not return a value as described on mdsn.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; TFnMsgeCallback = <span class="kw1">function</span> <span class="br0">&#40;</span>bVerbose: <span class="kw4">Boolean</span>; lpMessage: <span class="kw4">PWideChar</span><span class="br0">&#41;</span>: <span class="kw4">Cardinal</span>; <span class="kw1">stdcall</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// this structure stores information about a Winlogon event.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">TWlxNotificationInfo = <span class="kw1">record</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; Size: <span class="kw4">Cardinal</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; Flags: <span class="kw4">Cardinal</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; UserName: <span class="kw4">PWideChar</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; Domain: <span class="kw4">PWideChar</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; WindowStation: <span class="kw4">PWideChar</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; Token: <span class="kw4">Cardinal</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; Desktop: <span class="kw4">Cardinal</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; StatusCallback: TFnMsgeCallback;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; PWlxNotificationInfo = ^TWlxNotificationInfo;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2"><span class="coMULTI">{ &nbsp;winlogon can inform about the following events:</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">Lock,</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">Lockoff,</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">Logon,</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">Shutdown,</span></div>
</li>
<li class="li2">
<div class="de2"><span class="coMULTI">StartScreensave,</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">StartShell,</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">StartUp,</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">StopScreenSaver,</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">Unlock</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">For a complete describtion of those events look at: </span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">http://msdn.microsoft.com/en-us/library/aa380544(VS.85).aspx</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">}</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// example of handling the Logon Message</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">procedure</span> LogonHandler<span class="br0">&#40;</span>Info: PWlxNotificationInfo<span class="br0">&#41;</span>; <span class="kw1">stdcall</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">begin</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// the entrance function for DLL</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2"><span class="kw1">procedure</span> EntryPointProc<span class="br0">&#40;</span>reason: <span class="kw4">integer</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">begin</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">case</span> reason <span class="kw1">of</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; DLL_PROCESS_ATTACH: &nbsp;<span class="co1">//1</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">Begin</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// Disable DLL_THREAD_ATTACH &amp;amp; DLL_THREAD_DETACH</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// notification calls. This is a performance optimization</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// for multithreaded applications that do not need</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// thread-level notifications of attachment or</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// detachment.</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; DisableThreadLibraryCalls<span class="br0">&#40;</span>hInstance<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; DLL_THREAD_ATTACH: &nbsp; <span class="co1">//2</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; <span class="kw1">begin</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; DLL_PROCESS_DETACH: &nbsp;<span class="co1">//3</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">begin</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; DLL_THREAD_DETACH: &nbsp; <span class="co1">//0</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">begin</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; <span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2"><span class="co1">// define the exports for the DLL</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">exports</div>
</li>
<li class="li1">
<div class="de1">&nbsp; LogonHandler;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2"><span class="kw1">begin</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; DllProc := @EntryPointProc;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; DllProc<span class="br0">&#40;</span>DLL_PROCESS_ATTACH<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span>.</div>
</li>
</ol>
</div>
<p>Our Prototype, is ready to use. The compiled DLL has to be in the following folder:</p>
<p style="padding-left: 30px;"><strong> C:\Windows\System32 </strong>(adapt it to your environment)<strong><br />
</strong></p>
<p>Now we can inform the operating system that we created a <strong>Winlogon Notification Package. </strong>This step will be done in the registry under the following key:</p>
<p style="padding-left: 30px;"><strong>HKey_Local_Machine\Software\Microsoft\WindowsNT\<br />
CurrentVersion\Winlogon\Notify\YourNotification </strong></p>
<table class="MsoTableMediumList2Accent1" style="border: medium none; width: 73.16%; border-collapse: collapse;" border="1" cellspacing="0" cellpadding="0" width="73%">
<tbody>
<tr>
<td style="padding: 0cm 5.4pt; background: white none repeat scroll 0%; width: 21.78%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border: medium medium 3pt none none solid -moz-use-text-color -moz-use-text-color #4f81bd;" width="21%" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span lang="EN-US">Name</span></p>
</td>
<td style="padding: 0cm 5.4pt; background: white none repeat scroll 0%; width: 20.94%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border: medium medium 3pt none none solid -moz-use-text-color -moz-use-text-color #4f81bd;" width="20%" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: center; line-height: normal;" align="center"><span lang="EN-US">Type</span></p>
</td>
<td style="padding: 0cm 5.4pt; background: white none repeat scroll 0%; width: 57.28%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border: medium medium 3pt none none solid -moz-use-text-color -moz-use-text-color #4f81bd;" width="57%" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: center; line-height: normal;" align="center"><span lang="EN-US">Value</span></p>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; background: white none repeat scroll 0%; width: 21.78%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border: medium 1pt medium medium none solid none none -moz-use-text-color #4f81bd -moz-use-text-color -moz-use-text-color;" width="21%" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span lang="EN-US">DLLName</span></p>
</td>
<td style="border: medium none; padding: 0cm 5.4pt; background: #d3dfee none repeat scroll 0%; width: 20.94%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="20%" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: center; line-height: normal;" align="center"><span lang="EN-US">REG_SZ</span></p>
</td>
<td style="padding: 0cm 5.4pt; background: #d3dfee none repeat scroll 0%; width: 57.28%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border: medium 1pt medium medium none solid none none -moz-use-text-color #4f81bd -moz-use-text-color -moz-use-text-color;" width="57%" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: center; line-height: normal;" align="center"><span lang="EN-US">C:\Windows\System32\YourDLLName.dll</span></p>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; background: white none repeat scroll 0%; width: 21.78%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border: medium 1pt medium medium none solid none none -moz-use-text-color #4f81bd -moz-use-text-color -moz-use-text-color;" width="21%" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span lang="EN-US">Asynchronous</span></p>
</td>
<td style="border: medium none; padding: 0cm 5.4pt; width: 20.94%;" width="20%" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: center; line-height: normal;" align="center"><span lang="EN-US">REG_DWORD</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 57.28%; border: medium 1pt medium medium none solid none none -moz-use-text-color #4f81bd -moz-use-text-color -moz-use-text-color;" width="57%" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: center; line-height: normal;" align="center"><span lang="EN-US">0</span></p>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; background: white none repeat scroll 0%; width: 21.78%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border: medium 1pt medium medium none solid none none -moz-use-text-color #4f81bd -moz-use-text-color -moz-use-text-color;" width="21%" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span lang="EN-US">Impersonate</span></p>
</td>
<td style="border: medium none; padding: 0cm 5.4pt; background: #d3dfee none repeat scroll 0%; width: 20.94%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="20%" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: center; line-height: normal;" align="center"><span lang="EN-US">REG_DWORD</span></p>
</td>
<td style="padding: 0cm 5.4pt; background: #d3dfee none repeat scroll 0%; width: 57.28%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border: medium 1pt medium medium none solid none none -moz-use-text-color #4f81bd -moz-use-text-color -moz-use-text-color;" width="57%" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: center; line-height: normal;" align="center"><span lang="EN-US">0</span></p>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; background: white none repeat scroll 0%; width: 21.78%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border: medium 1pt medium medium none solid none none -moz-use-text-color #4f81bd -moz-use-text-color -moz-use-text-color;" width="21%" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="color: black;">Logon</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 20.94%; border: medium medium 1pt none none solid -moz-use-text-color -moz-use-text-color #4f81bd;" width="20%" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: center; line-height: normal;" align="center"><span lang="EN-US">REG_SZ</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 57.28%; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color #4f81bd #4f81bd -moz-use-text-color;" width="57%" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: center; line-height: normal;" align="center"><span style="color: black;">LogonHandler</span></p>
</td>
</tr>
</tbody>
</table>
<p>The valid values are described in this <a href="http://msdn.microsoft.com/en-us/library/aa379402(VS.85).aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');">MSDN article.</a></p>
<p><strong>Creating the PNG Image</strong></p>
<p>For completing this Project you will need to download the following:</p>
<p><strong>Graphics32 Library</strong><br />
<em>Graphics32 is a graphics library for Delphi and Kylix/CLX. Optimized for 32-bit pixel formats, it provides fast operations with pixels and graphic primitives. In most cases Graphics32 considerably outperforms the standard TBitmap/TCanvas methods.</em></p>
<p><strong>PNG Components<br />
</strong><em>Delphi VCL Components with PNG Image support.</em></p>
<p>What you&#8217;ll need is an already exisiting PNG or a new one. I&#8217;ll use with the <a href="http://blog.delphi-jedi.net/home/" >Jedi Api WSCL Logo</a>.<br />
Open the Logo in Photoshop but remember this can be done in almost any other Graphic Application which supports PNG and layer based drawing.</p>
<p>The Logo from this site is already a PNG, so you will see a transparent background when it is opened in Photoshop. If you like to add a drop shadow style to it, you won&#8217;t see it,because of the mentioned transparent background. It is also a problem on a black background, btw. So first thing to do is to add a temporary background layer into the Logo. To do so, click on the &#8220;<strong>Create New Layer Symbol</strong>&#8221; in the layer palette (indicated as a small notepad icon).</p>
<p>Now select the new created layer by clicking on it and drag it behind the Logo layer. With the new layer still selected, switch to the &#8220;Tools Window&#8221; and select the &#8220;<strong>Paint Bucket Tool</strong>&#8220;. Select white as your foreground color. If you have another color as foreground color, <strong>simply press d and then x</strong>. In this way it will reset the foreground and backgound colors. Now click inside your image on the transparent part and you&#8217;ll see the Logo with a white background applied.</p>
<p>Switch to your layers palette and double click on the Logo layer. The &#8220;Layers Styles Dialog&#8221; should be visible now. Select &#8220;Drop Shadow&#8221; and you can adjust the angle of the drop shadow and its size. While you adjust it, also watch the Logo. Photoshop shows you a preview of the changes. If you&#8217;re satisfied with your settings hit ok.</p>
<p>At this time, we don&#8217;t need our white background layer anymore, so select it and drag it to the trash can symbol in the layer palette. It will be deleted then. Afterwards save the Logo, select PNG as the file format and a new window will appear (PNG Options). Select none and hit ok.</p>
<p>There also exists a small <a href="#Downloads">video presentation</a> which will help you<strong>.</strong></p>
<p><strong>Drawing the PNG onto the Form Canvas</strong></p>
<p>The following source is kindly provided by <strong>Coder90</strong>. He wrote a nice example in a german delphi <a href="http://www.delphipraxis.net/post606056.html#606056">forum<br />
</a></p>
<p><strong>The Sources<br />
</strong>I won&#8217;t go into any details here, basically the procedure will load the PNG into a Bitmap32 Object and blends it to the forms canvas.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">Type</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">interface</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">uses</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; Dialogs, ExtCtrls, StdCtrls, GR32;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">public</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="coMULTI">{ Public declarations }</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; BMP32 : TBitmap32;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; BlendF: TBlendFunction;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; P: TPoint;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; Size: TSize;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">procedure</span> BlendIt;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">procedure</span> LoadPNGintoBitmap32<span class="br0">&#40;</span>DstBitmap: TBitmap32;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Filename: <span class="kw4">String</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out AlphaChannelUsed: <span class="kw4">Boolean</span><span class="br0">&#41;</span>; <span class="kw1">overload</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">procedure</span> LoadPNGintoBitmap32<span class="br0">&#40;</span>DstBitmap: TBitmap32;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SrcStream: TStream;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out AlphaChannelUsed: <span class="kw4">Boolean</span><span class="br0">&#41;</span>; <span class="kw1">overload</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="kw1">procedure</span> LoadPNGintoBitmap32<span class="br0">&#40;</span>DstBitmap: TBitmap32;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; szSection : <span class="kw4">PChar</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; szName &nbsp; &nbsp;: <span class="kw4">String</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out AlphaChannelUsed: <span class="kw4">Boolean</span><span class="br0">&#41;</span>; <span class="kw1">overload</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2"><span class="kw1">uses</span> PNGImage;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">procedure</span> LoadPNGintoBitmap32<span class="br0">&#40;</span>DstBitmap: TBitmap32;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SrcStream: TStream;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out AlphaChannelUsed: <span class="kw4">Boolean</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2"><span class="kw1">var</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; PNGObject: TPNGObject;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; TransparentColor: TColor32;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; PixelPtr: PColor32;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; AlphaPtr: <span class="kw4">PByte</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; X, Y: <span class="kw4">Integer</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">begin</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; PNGObject := <span class="kw2">nil</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">try</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; PNGObject := TPngObject.<span class="me1">Create</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; PNGObject.<span class="me1">LoadFromStream</span><span class="br0">&#40;</span>SrcStream<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; DstBitmap.<span class="me1">Assign</span><span class="br0">&#40;</span>PNGObject<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; DstBitmap.<span class="me1">ResetAlpha</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="kw1">case</span> PNGObject.<span class="me1">TransparencyMode</span> <span class="kw1">of</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; ptmPartial:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">begin</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>PNGObject.<span class="me1">Header</span>.<span class="me1">ColorType</span> = COLOR_GRAYSCALEALPHA<span class="br0">&#41;</span> <span class="kw1">or</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#40;</span>PNGObject.<span class="me1">Header</span>.<span class="me1">ColorType</span> = COLOR_RGBALPHA<span class="br0">&#41;</span> <span class="kw1">then</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">begin</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PixelPtr := PColor32<span class="br0">&#40;</span>@DstBitmap.<span class="me1">Bits</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> Y := <span class="nu0">0</span> <span class="kw1">to</span> DstBitmap.<span class="me1">Height</span> - <span class="nu0">1</span> <span class="kw1">do</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">begin</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AlphaPtr := <span class="kw4">PByte</span><span class="br0">&#40;</span>PNGObject.<span class="me1">AlphaScanline</span><span class="br0">&#91;</span>Y<span class="br0">&#93;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> X := <span class="nu0">0</span> <span class="kw1">to</span> DstBitmap.<span class="me1">Width</span> - <span class="nu0">1</span> <span class="kw1">do</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">begin</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PixelPtr^ := <span class="br0">&#40;</span>PixelPtr^ <span class="kw1">and</span> <span class="re0">$00FFFFFF</span><span class="br0">&#41;</span> <span class="kw1">or</span> <span class="br0">&#40;</span>TColor32<span class="br0">&#40;</span>AlphaPtr^<span class="br0">&#41;</span> <span class="kw1">shl</span> <span class="nu0">24</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Inc</span><span class="br0">&#40;</span>PixelPtr<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Inc</span><span class="br0">&#40;</span>AlphaPtr<span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AlphaChannelUsed := <span class="kw2">True</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">end</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; ptmBit:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">begin</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TransparentColor := Color32<span class="br0">&#40;</span>PNGObject.<span class="me1">TransparentColor</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PixelPtr := PColor32<span class="br0">&#40;</span>@DstBitmap.<span class="me1">Bits</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> X := <span class="nu0">0</span> <span class="kw1">to</span> <span class="br0">&#40;</span>DstBitmap.<span class="me1">Height</span> - <span class="nu0">1</span><span class="br0">&#41;</span> * <span class="br0">&#40;</span>DstBitmap.<span class="me1">Width</span> - <span class="nu0">1</span><span class="br0">&#41;</span> <span class="kw1">do</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">begin</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> PixelPtr^ = TransparentColor <span class="kw1">then</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PixelPtr^ := PixelPtr^ <span class="kw1">and</span> <span class="re0">$00FFFFFF</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Inc</span><span class="br0">&#40;</span>PixelPtr<span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AlphaChannelUsed := <span class="kw2">True</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; ptmNone:</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; AlphaChannelUsed := <span class="kw2">False</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">finally</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="kw3">Assigned</span><span class="br0">&#40;</span>PNGObject<span class="br0">&#41;</span> <span class="kw1">then</span> PNGObject.<span class="me1">Free</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">end</span>;</div>
</li>
<li class="li2">
<div class="de2"><span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">procedure</span> LoadPNGintoBitmap32<span class="br0">&#40;</span>DstBitmap: TBitmap32;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Filename: <span class="kw4">String</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out AlphaChannelUsed: <span class="kw4">Boolean</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2"><span class="kw1">var</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; FileStream: TFileStream;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">begin</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; FileStream := TFileStream.<span class="me1">Create</span><span class="br0">&#40;</span>Filename, fmOpenRead<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">try</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; LoadPNGintoBitmap32<span class="br0">&#40;</span>DstBitmap, FileStream, AlphaChannelUsed<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">finally</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; FileStream.<span class="me1">Free</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">procedure</span> LoadPNGintoBitmap32<span class="br0">&#40;</span>DstBitmap: TBitmap32;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; szSection : <span class="kw4">PChar</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; szName &nbsp; &nbsp;: <span class="kw4">String</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out AlphaChannelUsed: <span class="kw4">Boolean</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2"><span class="kw1">var</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; Stream: TResourceStream;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">begin</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; Stream := TResourceStream.<span class="me1">Create</span><span class="br0">&#40;</span>hInstance, szName, <span class="kw4">PChar</span><span class="br0">&#40;</span>szSection<span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">try</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; LoadPNGintoBitmap32<span class="br0">&#40;</span>DstBitmap, Stream, AlphaChannelUsed<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">finally</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;Stream.<span class="me1">Free</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw1">end</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">{ Works only Win2000_Up }</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">procedure</span> TForm1.<span class="me1">BlendIt</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">var</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; Alpha: <span class="kw4">Boolean</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">begin</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; BMP32 := TBitmap32.<span class="me1">Create</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="coMULTI">{Load PNG from File</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">&nbsp; LoadPNGintoBitmap32(BMP32, ExtractFilePath(ParamStr(0)) + &#8216;WSCL.png&#8217;, Alpha);</span></div>
</li>
<li class="li2">
<div class="de2"><span class="coMULTI">&nbsp;}</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="co1">// Load PNG From Resource</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; LoadPNGintoBitmap32<span class="br0">&#40;</span>BMP32, <span class="kw4">PChar</span><span class="br0">&#40;</span><span class="st0">&#8216;PNG&#8217;</span><span class="br0">&#41;</span>, <span class="st0">&#8216;WSCL&#8217;</span>, Alpha<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; setWindowLong<span class="br0">&#40;</span>Handle, GWL_EXSTYLE,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; getWindowLong<span class="br0">&#40;</span>Handle, GWL_EXSTYLE<span class="br0">&#41;</span> <span class="kw1">or</span> WS_EX_LAYERED <span class="coMULTI">{or WS_EX_TRANSPARENT}</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="co1">// WS_EX_TRANSPARENT makes the Window for MouseClicks transparent&#8230;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; BlendF.<span class="me1">BlendOp</span> := AC_SRC_OVER;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; BlendF.<span class="me1">BlendFlags</span> := <span class="nu0">0</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; BlendF.<span class="me1">SourceConstantAlpha</span> := <span class="nu0">255</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; BlendF.<span class="me1">AlphaFormat</span> := AC_SRC_ALPHA;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; P := Point<span class="br0">&#40;</span><span class="nu0">0</span>, <span class="nu0">0</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; Size.<span class="me1">cx</span> := BMP32.<span class="me1">Width</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; Size.<span class="me1">cy</span> := BMP32.<span class="me1">Height</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; UpdateLayeredWindow<span class="br0">&#40;</span>Handle, <span class="nu0">0</span>, <span class="kw2">nil</span>, @Size, BMP32.<span class="me1">Handle</span>, @P, <span class="nu0">0</span>, @BlendF, ULW_ALPHA<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="co1">// Set Window on Top</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; SetWindowPos<span class="br0">&#40;</span>Handle, HWND_TOPMOST, Left, Top, Width, Height,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; SWP_NOACTIVATE <span class="kw1">or</span> SWP_NOMOVE <span class="kw1">or</span> SWP_NOSIZE<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="co1">// Set Parent to Desktop</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; SetWindowLong<span class="br0">&#40;</span>Handle, GWL_HWNDPARENT, <span class="nu0">0</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="co1">// Hide Window from Taskbar</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; SetWindowLong<span class="br0">&#40;</span>Handle, GWL_EXSTYLE,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; GetWindowLong<span class="br0">&#40;</span>Handle, GWL_EXSTYLE<span class="br0">&#41;</span> <span class="kw1">or</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; WS_EX_TOOLWINDOW <span class="kw1">and</span> <span class="kw1">not</span> WS_EX_APPWINDOW<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span>;</div>
</li>
</ol>
</div>
<p>Call it in the FormOnCreate handler and don&#8217;t forget to free the Bitmap32 Object, a good place e.g. would be on the FormOnDestroy Handler.</p>
<p><strong>Additional informations for you</strong></p>
<p>I have to tell you that the first version of this package was slightly different than the one I’ll post here.<br />
Well I used an external executeable which was called from my DLL when the LogonEvent was called.</p>
<p>But I encountered a big problem with that technique. One of the biggest problems were that my external application was executed more then once. Additionally I wasn’t able to close it. Neither Application.Terminate nor Application.Mainform.Close worked here. I did some experiments with a mutex which worked in some cases, but then, Christian Wimmer gave me many good ideas and suggestions.</p>
<p>So the improvements were:</p>
<ol>
<li>The transparent Window is now directly created inside of the Winlogon Process by creating a new thread object.</li>
<li>Christian implemented an TApplication.OnIdle handler inside the thread object which will safely close the transparent window when it isn&#8217;t needed anymore.</li>
</ol>
<h3>Prerequisites:</h3>
<p>The following Delphi packages are necessary. They are not included and must therfore downloaded and installed (if necessary) separately. Please, also recognize the license of these packages. The winlogon examples does only have a Copyright and no Warranty license.</p>
<h3>Download:<a name="Downloads"></a></h3>
<p>3rd Party Components and Library&#8217;s you need to download:<br />
<a href="https://sourceforge.net/projects/graphics32/" onclick="javascript:pageTracker._trackPageview('/outbound/article/sourceforge.net');">Graphics32</a><br />
<a href="http://www.thany.org/article/18/Delphi_components" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.thany.org');">PNG Components</a></p>
<p>Jedi Tutorial Files:<a href="http://www.thany.org/article/18/Delphi_components"><br />
</a><a href="http://blog.delphi-jedi.net/wp-content/uploads/2008/05/vid.avi">Photoshop Tutorial<br />
</a>(dowload size: 2.12 MB Format: AVI)<a href="http://blog.delphi-jedi.net/wp-content/uploads/2008/05/vid.avi"><br />
</a><a href="http://blog.delphi-jedi.net/wp-content/uploads/2008/05/winlogon.zip">winlogon<br />
</a>(dowload size: 82.2 KB Format: ZIP)</p>
<h2>Warning:</h2>
<p>If you want to use such a Winlogon Notification DLL in a productive system you have to make sure that the wrong person can&#8217;t manipulate the DLL file. This can be done by setting the file&#8217;s access control list to allow only write access to SYSTEM and Administrators. There is no need for other users to have even read access, since the DLL is only used by winlogon. Furthermore you should save this file in a save place like the System32 folder.</p>
<p><strong>Conclusion:</strong></p>
<p>I hope you learned something new and had as much fun as I had writing this little tutorial for you!<br />
My biggest thanks fly out to Christian Wimmer for all his support and help for making me finish this project.</p>
<p>Kindest regards<br />
stOrM!</p>
<p>(contact by comments or <a href="http://blog.delphi-jedi.net/about/" >mail @ JEDI</a>)</p>
<form id=pdf24Form_234 method="POST" action="http://doc2pdf.pdf24.org/doc2pdf/wordpress.php" style="border: 1px solid silver; padding: 2px;" target="pdf24PopWin" onsubmit="window.open('about:blank', 'pdf24PopWin', 'scrollbars=yes,width=400,height=200,top=0,left=0'); return true;"><input type="hidden" name="blogCharset" value="UTF-8">
<input type="hidden" name="blogPosts" value="1">
<input type="hidden" name="blogUrl" value="http://blog.delphi-jedi.net">
<input type="hidden" name="blogName" value="JEDI Windows API">
<input type="hidden" name="blogValueEncoding" value="htmlSpecialChars">
<input type="hidden" name="postTitle_0" value="Winlogon Notification Package">
<input type="hidden" name="postLink_0" value="http://blog.delphi-jedi.net/2008/05/27/winlogon-notification-package/">
<input type="hidden" name="postAuthor_0" value="Christian Wimmer">
<input type="hidden" name="postDateTime_0" value="2008-05-27 20:05:05">
<input type="hidden" name="postContent_0" value="&lt;p&gt;&lt;strong&gt;What is that? MSDN say&amp;#8217;s: &lt;/strong&gt;&lt;em&gt;A Winlogon Notification Package is a DLL that exports functions that handle Winlogon events. For example, when a user logs onto the system, Winlogon calls each notification package&amp;#8217;s logon event handler function to provide information about the event.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;So you might know, the mechanism of Winlogon Notification Package is available in Windows 2000, Windows XP and Windows 2003 Server. In contrast to Windows Vista, it is completely different, maybe I’ll come back with separate tutorial describing how to build a notification package for Windows Vista.&lt;/p&gt;
&lt;p&gt;I&amp;#8217;m going to demonstrate here, how to create such a notification package and as a special gift, we will learn how to create a PNG image with drop shadow effect, which we will use later to draw a transparent window inside the Winlogon Desktop.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://blog.delphi-jedi.net/wp-content/uploads/2008/05/capture.jpg&quot;&gt;&lt;img class=&quot;alignnone size-thumbnail wp-image-230&quot; title=&quot;capture&quot; src=&quot;http://blog.delphi-jedi.net/wp-content/uploads/2008/05/capture.jpg&quot; alt=&quot;Winlogon&quot; width=&quot;301&quot; height=&quot;221&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It&amp;#8217;s time for our &lt;strong&gt;Winlogon Notification Package&lt;/strong&gt;. Start Delphi and create a new DLL project.&lt;/p&gt;
&lt;p&gt;What we need to do next is to define the Message Callback and the WLXNotificationInfo, as described in &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/aa381183(VS.85).aspx&quot;&gt;MSDN&lt;/a&gt;&lt;/p&gt;
&lt;div class=&quot;dean_ch&quot; style=&quot;white-space: wrap;&quot;&gt;
&lt;ol&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;Type&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co1&quot;&gt;// this callback function does not return a value as described on mdsn.&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; TFnMsgeCallback = &lt;span class=&quot;kw1&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;bVerbose: &lt;span class=&quot;kw4&quot;&gt;Boolean&lt;/span&gt;; lpMessage: &lt;span class=&quot;kw4&quot;&gt;PWideChar&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;: &lt;span class=&quot;kw4&quot;&gt;Cardinal&lt;/span&gt;; &lt;span class=&quot;kw1&quot;&gt;stdcall&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li2&quot;&gt;
&lt;div class=&quot;de2&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co1&quot;&gt;// this structure stores information about a Winlogon event.&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;TWlxNotificationInfo = &lt;span class=&quot;kw1&quot;&gt;record&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; Size: &lt;span class=&quot;kw4&quot;&gt;Cardinal&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li2&quot;&gt;
&lt;div class=&quot;de2&quot;&gt;&amp;nbsp; &amp;nbsp; Flags: &lt;span class=&quot;kw4&quot;&gt;Cardinal&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; UserName: &lt;span class=&quot;kw4&quot;&gt;PWideChar&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; Domain: &lt;span class=&quot;kw4&quot;&gt;PWideChar&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; WindowStation: &lt;span class=&quot;kw4&quot;&gt;PWideChar&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; Token: &lt;span class=&quot;kw4&quot;&gt;Cardinal&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li2&quot;&gt;
&lt;div class=&quot;de2&quot;&gt;&amp;nbsp; &amp;nbsp; Desktop: &lt;span class=&quot;kw4&quot;&gt;Cardinal&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; StatusCallback: TFnMsgeCallback;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;end&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;
&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; PWlxNotificationInfo = ^TWlxNotificationInfo;&lt;