<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>From Zero To One</title>
	<atom:link href="http://www.cromis.net/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cromis.net/blog</link>
	<description>A blog about Delphi programming and all things technical</description>
	<lastBuildDate>Mon, 09 Apr 2012 08:38:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Cromis Library updated</title>
		<link>http://www.cromis.net/blog/2012/04/cromis-library-updated/</link>
		<comments>http://www.cromis.net/blog/2012/04/cromis-library-updated/#comments</comments>
		<pubDate>Mon, 09 Apr 2012 08:36:10 +0000</pubDate>
		<dc:creator>Iztok Kacin</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.cromis.net/blog/?p=876</guid>
		<description><![CDATA[A fairly big update was just commited. The main focus is on 64 bit compatibility. Cromis IMC added: IMC stands for inter machine communication. Just as my IPC which is inter process oriented, this aims at easy, message oriented communication between machines. Forget about TCP/IP, Indy, Synapse, ICS or any other technology. You want to [...]]]></description>
			<content:encoded><![CDATA[<p>A fairly big update was just commited. The main focus is on 64 bit compatibility.</p>
<ol>
<li style="text-align: justify;"><span style="text-decoration: underline;"><strong>Cromis IMC added</strong></span>: IMC stands for inter machine communication. Just as my IPC which is inter process oriented, this aims at easy, message oriented communication between machines. Forget about TCP/IP, Indy, Synapse, ICS or any other technology. You want to send a message with data from one machine to the other and not worry about how to technically do that. IMC offers just that. Its fast its easy to use and abstracts the communication layer from you. Another good thing is that it uses exactly the same message carrier as IPC does. This basically means all the code you used in IPC for preparing the messages will work here. You can also chain data from IPC to IMC. The code uses Indy as TCP layer as that guarantees that it will work on any new delphi version. For now it is Indy 10 only but if there will be demand I can make it Indy 9 compatible.</li>
<li style="text-align: justify;"><span style="text-decoration: underline;"><strong>Cromis IPC:</strong></span><br />
<h4>Change Log</h4>
<ul>
<li>1.3.1
<ul>
<li>Added error description for the client</li>
</ul>
</li>
<li>1.3.0
<ul>
<li>64 bit compiler compatible</li>
</ul>
</li>
<li>1.2.2
<ul>
<li>Improved wait for ERROR_IO_PENDING</li>
<li>Usage of CommTimeouts</li>
</ul>
</li>
</ul>
</li>
<li style="text-align: justify;"><span style="text-decoration: underline;"><strong>Cromis Threading:</strong></span><br />
<h4>Change Log</h4>
<ul>
<li>1.5.0
<ul>
<li>64 bit compiler compatible</li>
</ul>
</li>
<li>1.4.3
<ul>
<li>Added StopAllTasks for TTaskPool</li>
</ul>
</li>
<li>1.4.2 (breaking change)
<ul>
<li>TTaskQueue is not only available as ITaskQueue interface</li>
</ul>
</li>
</ul>
</li>
<li style="text-align: justify;"><span style="text-decoration: underline;"><strong>Cron Scheduler:</strong></span><br />
<h4>Change Log</h4>
<ul>
<li>2.1.0
<ul>
<li>64 bit compiler compatible</li>
</ul>
</li>
</ul>
</li>
<li style="text-align: justify;"><span style="text-decoration: underline;"><strong>Cron Scheduler:</strong></span><br />
<h4>Change Log</h4>
<ul>
<li>1.1.0
<ul>
<li>64 bit compiler compatible</li>
<li>Fixed thread termination bug</li>
</ul>
</li>
</ul>
</li>
</ol>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cromis.net/blog/2012/04/cromis-library-updated/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Cromis.Threading</title>
		<link>http://www.cromis.net/blog/2012/02/cromis-threading/</link>
		<comments>http://www.cromis.net/blog/2012/02/cromis-threading/#comments</comments>
		<pubDate>Wed, 22 Feb 2012 19:17:29 +0000</pubDate>
		<dc:creator>Iztok Kacin</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.cromis.net/blog/?p=867</guid>
		<description><![CDATA[I have received quite a few mails recently, from people telling me, how I made their life easier using my code. I am really glad some of you find my code useful and easy enough to use. I made it public in case someone finds it useful. I also made demo applications for most parts [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I have received quite a few mails recently, from people telling me, how I made their life easier using my code. I am really glad some of you find my code useful and easy enough to use. I made it public in case someone finds it useful.</p>
<p style="text-align: justify;">I also made demo applications for most parts of the Cromis library, but one unit has almost no documentation and a lot of hidden content. This is the Cromis.Threading unit. Part of why this is so, is because this unit was made as a helper unit for Cromis.IPC. It contains the task (thread) pool that is used by Cromis.IPC. I needed my own lightweight implementation of a task pool so I wrote one. Then with time some other functionality regarding threading came into this unit. Mostly because I needed it here or there. But the side effects  of this are that this functionality is not documented and probably not so easy to use for someone who is not very familiar with the code. The e-mails I got recently just prove that. So I decided I will quickly write a few examples of how to use the code and show all of the functions that this unit provides.</p>
<p><span style="text-decoration: underline;"><strong>TTaskPool</strong></span></p>
<p>This is the most obvious class that gives you control over a pool of tasks (threads). You start using it like this</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">procedure</span> TfMain<span style="color: #000066;">.</span><span style="color: #006600;">btnStartClick</span><span style="color: #000066;">&#40;</span>Sender<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">TObject</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">var</span>
  Task<span style="color: #000066;">:</span> ITask<span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  FTaskPool<span style="color: #000066;">.</span><span style="color: #006600;">DynamicSize</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> cbDynamicPoolSize<span style="color: #000066;">.</span><span style="color: #006600;">Checked</span><span style="color: #000066;">;</span>
  FTaskPool<span style="color: #000066;">.</span><span style="color: #006600;">MinPoolSize</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000066;">StrToInt</span><span style="color: #000066;">&#40;</span>ePoolSize<span style="color: #000066;">.</span><span style="color: #006600;">Text</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  FTaskPool<span style="color: #000066;">.</span><span style="color: #006600;">OnTaskMessage</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> OnTaskMessage<span style="color: #000066;">;</span>
  FTaskPool<span style="color: #000066;">.</span><span style="color: #000066;">Initialize</span><span style="color: #000066;">;</span>
&nbsp;
  tmPoolStatus<span style="color: #000066;">.</span><span style="color: #006600;">Enabled</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">False</span><span style="color: #000066;">;</span>
  btnStart<span style="color: #000066;">.</span><span style="color: #006600;">Enabled</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">False</span><span style="color: #000066;">;</span>
  btnStop<span style="color: #000066;">.</span><span style="color: #006600;">Enabled</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">True</span><span style="color: #000066;">;</span>
  FTerminate <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">False</span><span style="color: #000066;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #000000; font-weight: bold;">not</span> FTerminate <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #000000; font-weight: bold;">begin</span>
    Task <span style="color: #000066;">:</span><span style="color: #000066;">=</span> FTaskPool<span style="color: #000066;">.</span><span style="color: #006600;">AcquireTask</span><span style="color: #000066;">&#40;</span>OnTaskExecute<span style="color: #000066;">,</span> <span style="color: #ff0000;">'RandomTask'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    Task<span style="color: #000066;">.</span><span style="color: #006600;">Values</span><span style="color: #000066;">.</span><span style="color: #006600;">Ensure</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'RandomNumber'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">.</span><span style="color: #006600;">AsInteger</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000066;">Random</span><span style="color: #000066;">&#40;</span>tbThreadTimeout<span style="color: #000066;">.</span><span style="color: #006600;">Position</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    Task<span style="color: #000066;">.</span><span style="color: #006600;">Run</span><span style="color: #000066;">;</span>
&nbsp;
    pbPoolSize<span style="color: #000066;">.</span><span style="color: #006600;">Position</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> FTaskPool<span style="color: #000066;">.</span><span style="color: #006600;">PoolSize</span> <span style="color: #000066;">-</span> FTaskPool<span style="color: #000066;">.</span><span style="color: #006600;">FreeTasks</span><span style="color: #000066;">;</span>
    stFreeThreadsValue<span style="color: #000066;">.</span><span style="color: #006600;">Caption</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000066;">IntToStr</span><span style="color: #000066;">&#40;</span>FTaskPool<span style="color: #000066;">.</span><span style="color: #006600;">FreeTasks</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    stPoolSizeValue<span style="color: #000066;">.</span><span style="color: #006600;">Caption</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000066;">IntToStr</span><span style="color: #000066;">&#40;</span>FTaskPool<span style="color: #000066;">.</span><span style="color: #006600;">PoolSize</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    <span style="color: #000066;">Sleep</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">Random</span><span style="color: #000066;">&#40;</span>tbCreationTimeout<span style="color: #000066;">.</span><span style="color: #006600;">Position</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    Application<span style="color: #000066;">.</span><span style="color: #006600;">ProcessMessages</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></pre></div></div>

<p>You have two important properties here that I will explain:</p>
<p><span style="text-decoration: underline;">DynamicSize</span>:</p>
<p>This boolean property controls if the size of the pool is dynamic. Let me explain. If you start with MinPoolSize of 20 and DynamicSize is FALSE then when all 20 threads are used, the pool will assign a new thread for each request it needs. So it will adjust to the peak load of the pool. But it will then stay at that peak number of threads. If your peak is at 60 it will stay there even if the load will then drop. But if DynamicSize is TRUE it will destroy unneeded threads until you again have the 20 (MinPoolSize) of threads. In other words it will dynamically adjust to the load. Each may have its uses.</p>
<p>MinPoolSize:</p>
<p>This one is simple. It is the number of threads you start with. You cannot have less then MinPoolSize of threads in the pool.</p>
<p>Ok now lets look at other parts of the workings of the pool. First is when the each task is executed:</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">procedure</span> TfMain<span style="color: #000066;">.</span><span style="color: #006600;">OnTaskExecute</span><span style="color: #000066;">&#40;</span><span style="color: #000000; font-weight: bold;">const</span> Task<span style="color: #000066;">:</span> ITask<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">var</span>
  Interval<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Integer</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  Interval <span style="color: #000066;">:</span><span style="color: #000066;">=</span> Task<span style="color: #000066;">.</span><span style="color: #006600;">Values</span><span style="color: #000066;">.</span><span style="color: #006600;">Get</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'RandomNumber'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">.</span><span style="color: #006600;">AsInteger</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">try</span>
    Task<span style="color: #000066;">.</span><span style="color: #006600;">Message</span><span style="color: #000066;">.</span><span style="color: #006600;">Ensure</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Result'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">.</span><span style="color: #006600;">AsInteger</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> Interval<span style="color: #000066;">;</span>
    <span style="color: #000066;">Sleep</span><span style="color: #000066;">&#40;</span>Interval<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">finally</span>
    Task<span style="color: #000066;">.</span><span style="color: #006600;">SendMessageAsync</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></pre></div></div>

<p>And the second is processing the messages that tasks send back:</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">procedure</span> TfMain<span style="color: #000066;">.</span><span style="color: #006600;">OnTaskMessage</span><span style="color: #000066;">&#40;</span><span style="color: #000000; font-weight: bold;">const</span> Msg<span style="color: #000066;">:</span> ITaskMessage<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">var</span>
  Interval<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Integer</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  <span style="color: #000066;">Inc</span><span style="color: #000066;">&#40;</span>FTaskCounter<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  Interval <span style="color: #000066;">:</span><span style="color: #000066;">=</span> Msg<span style="color: #000066;">.</span><span style="color: #006600;">Values</span><span style="color: #000066;">.</span><span style="color: #006600;">Get</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Result'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">.</span><span style="color: #006600;">AsInteger</span><span style="color: #000066;">;</span>
  stThreadsFinishedValue<span style="color: #000066;">.</span><span style="color: #006600;">Caption</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000066;">IntToStr</span><span style="color: #000066;">&#40;</span>FTaskCounter<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></pre></div></div>

<p>As you can see all is very straightforward. Before the task is run, you fill in the values of the task and then run it. You write the code for each task and each task can send back messages to the main thread. You can do that in two ways:</p>
<p>Task.SendMessageAsync;<br />
Task.SendMessageSync;</p>
<p>Each one speaks for itself.</p>
<p>Let me be clear here. This is a simple implementation of the task pool build for my internal needs. Some find it usefull and that is great. But it is in no way comparable to the OmniThreadLibrary.</p>
<p><span style="text-decoration: underline;"><strong>TThreadSafeQueue</strong></span></p>
<p>This is a simple implementation of the thread safe Queue, that uses locking. It is very spartan and fast.  Gabr wrote about it doing tests, some time ago:</p>
<p><a href="http://www.thedelphigeek.com/2011/05/lock-free-vs-locking.html">http://www.thedelphigeek.com/2011/05/lock-free-vs-locking.html</a><br />
<a href="http://www.thedelphigeek.com/2011/06/lock-free-vs-locking-rematch.html">http://www.thedelphigeek.com/2011/06/lock-free-vs-locking-rematch.html</a></p>
<p>The usage is very straightforward so no need to write about that.</p>
<p><span style="text-decoration: underline;"><strong>TLockFreeStack</strong></span></p>
<p>This class is a simple wrapper around the windows API and it enables the use of lock free stack.</p>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;"><strong>ITaskQueue</strong></span></p>
<p>This is a task queue that enables you to queue tasks even if the are run in multiple threads. This will ensure that your tasks will be executed in order that you want. The usage is very simple:</p>
<p>You create it like this:</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;">  FTaskQueue <span style="color: #000066;">:</span><span style="color: #000066;">=</span> AcquireTaskQueue<span style="color: #000066;">;</span></pre></div></div>

<p>Then you enqueue</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;">  FTaskQueue<span style="color: #000066;">.</span><span style="color: #006600;">EnqueueTask</span><span style="color: #000066;">.</span><span style="color: #006600;">WaitFor</span><span style="color: #000066;">;</span></pre></div></div>

<p>and dequeue</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;">  FTaskQueue<span style="color: #000066;">.</span><span style="color: #006600;">DequeueTask</span><span style="color: #000066;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.cromis.net/blog/2012/02/cromis-threading/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to make a very small windows service executable</title>
		<link>http://www.cromis.net/blog/2011/04/how-to-make-a-very-small-windows-service-executable/</link>
		<comments>http://www.cromis.net/blog/2011/04/how-to-make-a-very-small-windows-service-executable/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 15:51:19 +0000</pubDate>
		<dc:creator>Iztok Kacin</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.cromis.net/blog/?p=849</guid>
		<description><![CDATA[I a recent stack overflow question, a user asked how to make a Delphi generated NT Service executable smaller. There was some debate, if Delphi was appropriate to do this and if the executable size it generates was to big. Let me answer those two question as I see them: The size is not to [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I a recent stack overflow <a title="Tiny NT Service executable" href="http://stackoverflow.com/questions/5561919/create-a-small-and-concise-windows-service-using-delphi">question</a>, a user asked how to make a Delphi generated NT Service executable smaller. There was some debate, if Delphi was appropriate to do this and if the executable size it generates was to big. Let me answer those two question as I see them:</p>
<ol>
<li style="text-align: justify;">The size is not to big. In today desktop environment a megabyte, or few of them don&#8217;t matter. The difference between 50K and 1MB executable just doesn&#8217;t matter. There is enough RAM and hard drive space, that very few situations need a smaller executable.</li>
<li>And in cases when you need that, you can get to that in Delphi. You don&#8217;t need C/C++. Sure you can make the same result there, but why? Even if you only use API calls, you can still reuse some of the low level code you have written in Delphi. And that is a good enough reason to do it in your known IDE and language. You already know your tool and can save a lot of time not writing support code you already have written.</li>
</ol>
<p>Ok, so I dusted off a very old example I made years back and recompiled it with the Delphi 2006 and Delphi XE compiler. (I have those currently at hand). The result are:</p>
<ul>
<li>Delphi 2006: 526 KB</li>
<li>Delphi XE: 1018 KB</li>
</ul>
<p>These are the result of opening a new service application and just clicking build. No settings were adjusted. Then I cleaned that old example a little removed the unneeded code and made sure it works (I tested the service). The results were the following:</p>
<ul>
<li>Delphi 2006: 22 KB</li>
<li>Delphi XE: 32 KB</li>
</ul>
<p style="text-align: justify;"><del>Here I striped XE version of RTTI as suggested on stack overflow</del> (actually as there is only procedural code the RTTI has no effect whatsoever on the code as noticed by Cris). I left the Delphi 2006 intact. The code I used is posted bellow. It is basically a service skeleton made of two parts. One is the part that installs and controls the service. And the other is the service code itself that spawns a new &#8220;service control manager&#8221; attached process and then just waits until it is told to stop. It also reports the status to SCM.</p>
<p style="text-align: justify;">And now the challenge. How small can you make a static linked, single c/c++ executable service. It would be fun to know. I will play more with this latter trying different compiler settings and other tricks to see it I can squeeze a byte or two out of my current size <img src='http://www.cromis.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>A word of advice. Do not just copy and paste the sample service skeleton. It is just a prototype to show what can be done. It is in no way complete and does not have good error coverage. If enough people finds it important I can finish the code and polish it, but otherwise it is not worth the time.</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">{
  NT Service  model based completely on API calls. Version 0.1
  Inspired by NT service skeleton from Aphex
  Adapted by Runner
}</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">program</span> PureAPIService<span style="color: #000066;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic;">{$APPTYPE CONSOLE}</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">uses</span>
  Windows<span style="color: #000066;">,</span>
  WinSvc<span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">const</span>
  ServiceName     <span style="color: #000066;">=</span> <span style="color: #ff0000;">'PureAPIService'</span><span style="color: #000066;">;</span>
  DisplayName     <span style="color: #000066;">=</span> <span style="color: #ff0000;">'Pure Windows API Service'</span><span style="color: #000066;">;</span>
  NUM_OF_SERVICES <span style="color: #000066;">=</span> <span style="color: #0000ff;">2</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span>
  ServiceStatus <span style="color: #000066;">:</span> TServiceStatus<span style="color: #000066;">;</span>
  StatusHandle  <span style="color: #000066;">:</span> SERVICE_STATUS_HANDLE<span style="color: #000066;">;</span>
  ServiceTable  <span style="color: #000066;">:</span> <span style="color: #000000; font-weight: bold;">array</span> <span style="color: #000066;">&#91;</span><span style="color: #0000ff;">0</span><span style="color: #000066;">..</span><span style="color: #006600;">NUM_OF_SERVICES</span><span style="color: #000066;">&#93;</span> <span style="color: #000000; font-weight: bold;">of</span> TServiceTableEntry<span style="color: #000066;">;</span>
  Stopped       <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Boolean</span><span style="color: #000066;">;</span>
  Paused        <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Boolean</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span>
  ghSvcStopEvent<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Cardinal</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> OnServiceCreate<span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  <span style="color: #808080; font-style: italic;">// do your stuff here;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> AfterUninstall<span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  <span style="color: #808080; font-style: italic;">// do your stuff here;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> ReportSvcStatus<span style="color: #000066;">&#40;</span>dwCurrentState<span style="color: #000066;">,</span> dwWin32ExitCode<span style="color: #000066;">,</span> dwWaitHint<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">DWORD</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  <span style="color: #808080; font-style: italic;">// fill in the SERVICE_STATUS structure.</span>
  ServiceStatus<span style="color: #000066;">.</span><span style="color: #006600;">dwCurrentState</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> dwCurrentState<span style="color: #000066;">;</span>
  ServiceStatus<span style="color: #000066;">.</span><span style="color: #006600;">dwWin32ExitCode</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> dwWin32ExitCode<span style="color: #000066;">;</span>
  ServiceStatus<span style="color: #000066;">.</span><span style="color: #006600;">dwWaitHint</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> dwWaitHint<span style="color: #000066;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">case</span> dwCurrentState <span style="color: #000000; font-weight: bold;">of</span>
    SERVICE_START_PENDING<span style="color: #000066;">:</span> ServiceStatus<span style="color: #000066;">.</span><span style="color: #006600;">dwControlsAccepted</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">;</span>
    <span style="color: #000000; font-weight: bold;">else</span>
      ServiceStatus<span style="color: #000066;">.</span><span style="color: #006600;">dwControlsAccepted</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> SERVICE_ACCEPT_STOP<span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #000066;">&#40;</span>dwCurrentState <span style="color: #000066;">=</span> SERVICE_RUNNING<span style="color: #000066;">&#41;</span> <span style="color: #000000; font-weight: bold;">or</span> <span style="color: #000066;">&#40;</span>dwCurrentState <span style="color: #000066;">=</span> SERVICE_STOPPED<span style="color: #000066;">&#41;</span> <span style="color: #000000; font-weight: bold;">of</span>
    <span style="color: #000000; font-weight: bold;">True</span><span style="color: #000066;">:</span> ServiceStatus<span style="color: #000066;">.</span><span style="color: #006600;">dwCheckPoint</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">;</span>
    <span style="color: #000000; font-weight: bold;">False</span><span style="color: #000066;">:</span> ServiceStatus<span style="color: #000066;">.</span><span style="color: #006600;">dwCheckPoint</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">1</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;">// Report the status of the service to the SCM.</span>
  SetServiceStatus<span style="color: #000066;">&#40;</span>StatusHandle<span style="color: #000066;">,</span> ServiceStatus<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> MainProc<span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  <span style="color: #808080; font-style: italic;">// we have to do something or service will stop</span>
  ghSvcStopEvent <span style="color: #000066;">:</span><span style="color: #000066;">=</span> CreateEvent<span style="color: #000066;">&#40;</span><span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">,</span> <span style="color: #000000; font-weight: bold;">True</span><span style="color: #000066;">,</span> <span style="color: #000000; font-weight: bold;">False</span><span style="color: #000066;">,</span> <span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">if</span> ghSvcStopEvent <span style="color: #000066;">=</span> <span style="color: #0000ff;">0</span> <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #000000; font-weight: bold;">begin</span>
    ReportSvcStatus<span style="color: #000066;">&#40;</span>SERVICE_STOPPED<span style="color: #000066;">,</span> NO_ERROR<span style="color: #000066;">,</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    <span style="color: #000066;">Exit</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;">// Report running status when initialization is complete.</span>
  ReportSvcStatus<span style="color: #000066;">&#40;</span> SERVICE_RUNNING<span style="color: #000066;">,</span> NO_ERROR<span style="color: #000066;">,</span> <span style="color: #0000ff;">0</span> <span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;">// Perform work until service stops.</span>
  <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #000000; font-weight: bold;">True</span> <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #000000; font-weight: bold;">begin</span>
    <span style="color: #808080; font-style: italic;">// Check whether to stop the service.</span>
    WaitForSingleObject<span style="color: #000066;">&#40;</span>ghSvcStopEvent<span style="color: #000066;">,</span> INFINITE<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    ReportSvcStatus<span style="color: #000066;">&#40;</span>SERVICE_STOPPED<span style="color: #000066;">,</span> NO_ERROR<span style="color: #000066;">,</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    <span style="color: #000066;">Exit</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> ServiceCtrlHandler<span style="color: #000066;">&#40;</span>Control<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">DWORD</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span> <span style="color: #000000; font-weight: bold;">stdcall</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  <span style="color: #000000; font-weight: bold;">case</span> Control <span style="color: #000000; font-weight: bold;">of</span>
    SERVICE_CONTROL_STOP<span style="color: #000066;">:</span>
      <span style="color: #000000; font-weight: bold;">begin</span>
        Stopped <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">True</span><span style="color: #000066;">;</span>
        SetEvent<span style="color: #000066;">&#40;</span>ghSvcStopEvent<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
        ServiceStatus<span style="color: #000066;">.</span><span style="color: #006600;">dwCurrentState</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> SERVICE_STOP_PENDING<span style="color: #000066;">;</span>
        SetServiceStatus<span style="color: #000066;">&#40;</span>StatusHandle<span style="color: #000066;">,</span> ServiceStatus<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
      <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
    SERVICE_CONTROL_PAUSE<span style="color: #000066;">:</span>
      <span style="color: #000000; font-weight: bold;">begin</span>
        Paused <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">True</span><span style="color: #000066;">;</span>
        ServiceStatus<span style="color: #000066;">.</span><span style="color: #006600;">dwcurrentstate</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> SERVICE_PAUSED<span style="color: #000066;">;</span>
        SetServiceStatus<span style="color: #000066;">&#40;</span>StatusHandle<span style="color: #000066;">,</span> ServiceStatus<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
      <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
    SERVICE_CONTROL_CONTINUE<span style="color: #000066;">:</span>
      <span style="color: #000000; font-weight: bold;">begin</span>
        Paused <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">False</span><span style="color: #000066;">;</span>
        ServiceStatus<span style="color: #000066;">.</span><span style="color: #006600;">dwCurrentState</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> SERVICE_RUNNING<span style="color: #000066;">;</span>
        SetServiceStatus<span style="color: #000066;">&#40;</span>StatusHandle<span style="color: #000066;">,</span> ServiceStatus<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
      <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
    SERVICE_CONTROL_INTERROGATE<span style="color: #000066;">:</span> SetServiceStatus<span style="color: #000066;">&#40;</span>StatusHandle<span style="color: #000066;">,</span> ServiceStatus<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    SERVICE_CONTROL_SHUTDOWN<span style="color: #000066;">:</span> Stopped <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">True</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> RegisterService<span style="color: #000066;">&#40;</span>dwArgc<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">DWORD</span><span style="color: #000066;">;</span> <span style="color: #000000; font-weight: bold;">var</span> lpszArgv<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">PChar</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span> <span style="color: #000000; font-weight: bold;">stdcall</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  ServiceStatus<span style="color: #000066;">.</span><span style="color: #006600;">dwServiceType</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> SERVICE_WIN32_OWN_PROCESS<span style="color: #000066;">;</span>
  ServiceStatus<span style="color: #000066;">.</span><span style="color: #006600;">dwCurrentState</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> SERVICE_START_PENDING<span style="color: #000066;">;</span>
  ServiceStatus<span style="color: #000066;">.</span><span style="color: #006600;">dwControlsAccepted</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> SERVICE_ACCEPT_STOP <span style="color: #000000; font-weight: bold;">or</span> SERVICE_ACCEPT_PAUSE_CONTINUE<span style="color: #000066;">;</span>
  ServiceStatus<span style="color: #000066;">.</span><span style="color: #006600;">dwServiceSpecificExitCode</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">;</span>
  ServiceStatus<span style="color: #000066;">.</span><span style="color: #006600;">dwWin32ExitCode</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">;</span>
  ServiceStatus<span style="color: #000066;">.</span><span style="color: #006600;">dwCheckPoint</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">;</span>
  ServiceStatus<span style="color: #000066;">.</span><span style="color: #006600;">dwWaitHint</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">;</span>
&nbsp;
  StatusHandle <span style="color: #000066;">:</span><span style="color: #000066;">=</span> RegisterServiceCtrlHandler<span style="color: #000066;">&#40;</span>ServiceName<span style="color: #000066;">,</span> <span style="color: #000066;">@</span>ServiceCtrlHandler<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">if</span> StatusHandle &lt;&gt; <span style="color: #0000ff;">0</span> <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #000000; font-weight: bold;">begin</span>
    ReportSvcStatus<span style="color: #000066;">&#40;</span>SERVICE_RUNNING<span style="color: #000066;">,</span> NO_ERROR<span style="color: #000066;">,</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    <span style="color: #000000; font-weight: bold;">try</span>
      Stopped <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">False</span><span style="color: #000066;">;</span>
      Paused  <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">False</span><span style="color: #000066;">;</span>
      MainProc<span style="color: #000066;">;</span>
    <span style="color: #000000; font-weight: bold;">finally</span>
      ReportSvcStatus<span style="color: #000066;">&#40;</span>SERVICE_STOPPED<span style="color: #000066;">,</span> NO_ERROR<span style="color: #000066;">,</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> UninstallService<span style="color: #000066;">&#40;</span><span style="color: #000000; font-weight: bold;">const</span> ServiceName<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">PChar</span><span style="color: #000066;">;</span> <span style="color: #000000; font-weight: bold;">const</span> Silent<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Boolean</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">const</span>
  cRemoveMsg <span style="color: #000066;">=</span> <span style="color: #ff0000;">'Your service was removed sucesfuly!'</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">var</span>
  SCManager<span style="color: #000066;">:</span> SC_HANDLE<span style="color: #000066;">;</span>
  Service<span style="color: #000066;">:</span> SC_HANDLE<span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  SCManager <span style="color: #000066;">:</span><span style="color: #000066;">=</span> OpenSCManager<span style="color: #000066;">&#40;</span><span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">,</span> <span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">,</span> SC_MANAGER_ALL_ACCESS<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">if</span> SCManager <span style="color: #000066;">=</span> <span style="color: #0000ff;">0</span> <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #000066;">Exit</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">try</span>
    Service <span style="color: #000066;">:</span><span style="color: #000066;">=</span> OpenService<span style="color: #000066;">&#40;</span>SCManager<span style="color: #000066;">,</span> ServiceName<span style="color: #000066;">,</span> SERVICE_ALL_ACCESS<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    ControlService<span style="color: #000066;">&#40;</span>Service<span style="color: #000066;">,</span> SERVICE_CONTROL_STOP<span style="color: #000066;">,</span> ServiceStatus<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    DeleteService<span style="color: #000066;">&#40;</span>Service<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    CloseServiceHandle<span style="color: #000066;">&#40;</span>Service<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">not</span> Silent <span style="color: #000000; font-weight: bold;">then</span>
      MessageBox<span style="color: #000066;">&#40;</span><span style="color: #0000ff;">0</span><span style="color: #000066;">,</span> cRemoveMsg<span style="color: #000066;">,</span> ServiceName<span style="color: #000066;">,</span> MB_ICONINFORMATION <span style="color: #000000; font-weight: bold;">or</span> MB_OK <span style="color: #000000; font-weight: bold;">or</span> MB_TASKMODAL <span style="color: #000000; font-weight: bold;">or</span> MB_TOPMOST<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">finally</span>
    CloseServiceHandle<span style="color: #000066;">&#40;</span>SCManager<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    AfterUninstall<span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> InstallService<span style="color: #000066;">&#40;</span><span style="color: #000000; font-weight: bold;">const</span> ServiceName<span style="color: #000066;">,</span> DisplayName<span style="color: #000066;">,</span> LoadOrder<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">PChar</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">const</span> FileName<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span> <span style="color: #000000; font-weight: bold;">const</span> Silent<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Boolean</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">const</span>
  cInstallMsg <span style="color: #000066;">=</span> <span style="color: #ff0000;">'Your service was Installed sucesfuly!'</span><span style="color: #000066;">;</span>
  cSCMError <span style="color: #000066;">=</span> <span style="color: #ff0000;">'Error trying to open SC Manager'</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">var</span>
  SCMHandle  <span style="color: #000066;">:</span> SC_HANDLE<span style="color: #000066;">;</span>
  SvHandle   <span style="color: #000066;">:</span> SC_HANDLE<span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  SCMHandle <span style="color: #000066;">:</span><span style="color: #000066;">=</span> OpenSCManager<span style="color: #000066;">&#40;</span><span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">,</span> <span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">,</span> SC_MANAGER_ALL_ACCESS<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">if</span> SCMHandle <span style="color: #000066;">=</span> <span style="color: #0000ff;">0</span> <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #000000; font-weight: bold;">begin</span>
    MessageBox<span style="color: #000066;">&#40;</span><span style="color: #0000ff;">0</span><span style="color: #000066;">,</span> cSCMError<span style="color: #000066;">,</span> ServiceName<span style="color: #000066;">,</span> MB_ICONERROR <span style="color: #000000; font-weight: bold;">or</span> MB_OK <span style="color: #000000; font-weight: bold;">or</span> MB_TASKMODAL <span style="color: #000000; font-weight: bold;">or</span> MB_TOPMOST<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    <span style="color: #000066;">Exit</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">try</span>
    SvHandle <span style="color: #000066;">:</span><span style="color: #000066;">=</span> CreateService<span style="color: #000066;">&#40;</span>SCMHandle<span style="color: #000066;">,</span>
                              ServiceName<span style="color: #000066;">,</span>
                              DisplayName<span style="color: #000066;">,</span>
                              SERVICE_ALL_ACCESS<span style="color: #000066;">,</span>
                              SERVICE_WIN32_OWN_PROCESS<span style="color: #000066;">,</span>
                              SERVICE_AUTO_START<span style="color: #000066;">,</span>
                              SERVICE_ERROR_IGNORE<span style="color: #000066;">,</span>
                              <span style="color: #000066; font-weight: bold;">pchar</span><span style="color: #000066;">&#40;</span>FileName<span style="color: #000066;">&#41;</span><span style="color: #000066;">,</span>
                              LoadOrder<span style="color: #000066;">,</span>
                              <span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">,</span>
                              <span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">,</span>
                              <span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">,</span>
                              <span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    CloseServiceHandle<span style="color: #000066;">&#40;</span>SvHandle<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">not</span> Silent <span style="color: #000000; font-weight: bold;">then</span>
      MessageBox<span style="color: #000066;">&#40;</span><span style="color: #0000ff;">0</span><span style="color: #000066;">,</span> cInstallMsg<span style="color: #000066;">,</span> ServiceName<span style="color: #000066;">,</span> MB_ICONINFORMATION <span style="color: #000000; font-weight: bold;">or</span> MB_OK <span style="color: #000000; font-weight: bold;">or</span> MB_TASKMODAL <span style="color: #000000; font-weight: bold;">or</span> MB_TOPMOST<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">finally</span>
    CloseServiceHandle<span style="color: #000066;">&#40;</span>SCMHandle<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> WriteHelpContent<span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  <span style="color: #000066;">WriteLn</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'To install your service please type  /install'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  <span style="color: #000066;">WriteLn</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'To uninstall your service please type  /remove'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  <span style="color: #000066;">WriteLn</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'For help please type  /? or /h'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">begin</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000066;">&#40;</span><span style="color: #000066;">ParamStr</span><span style="color: #000066;">&#40;</span><span style="color: #0000ff;">1</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">=</span> <span style="color: #ff0000;">'/h'</span><span style="color: #000066;">&#41;</span> <span style="color: #000000; font-weight: bold;">or</span> <span style="color: #000066;">&#40;</span><span style="color: #000066;">ParamStr</span><span style="color: #000066;">&#40;</span><span style="color: #0000ff;">1</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">=</span> <span style="color: #ff0000;">'/?'</span><span style="color: #000066;">&#41;</span> <span style="color: #000000; font-weight: bold;">then</span>
    WriteHelpContent
  <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000066;">ParamStr</span><span style="color: #000066;">&#40;</span><span style="color: #0000ff;">1</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">=</span> <span style="color: #ff0000;">'/install'</span> <span style="color: #000000; font-weight: bold;">then</span>
    InstallService<span style="color: #000066;">&#40;</span>ServiceName<span style="color: #000066;">,</span> DisplayName<span style="color: #000066;">,</span> <span style="color: #ff0000;">'System Reserved'</span><span style="color: #000066;">,</span> <span style="color: #000066;">ParamStr</span><span style="color: #000066;">&#40;</span><span style="color: #0000ff;">0</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">,</span> <span style="color: #000066;">ParamStr</span><span style="color: #000066;">&#40;</span><span style="color: #0000ff;">2</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">=</span> <span style="color: #ff0000;">'/s'</span><span style="color: #000066;">&#41;</span>
  <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000066;">ParamStr</span><span style="color: #000066;">&#40;</span><span style="color: #0000ff;">1</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">=</span> <span style="color: #ff0000;">'/remove'</span> <span style="color: #000000; font-weight: bold;">then</span>
    UninstallService<span style="color: #000066;">&#40;</span>ServiceName<span style="color: #000066;">,</span> <span style="color: #000066;">ParamStr</span><span style="color: #000066;">&#40;</span><span style="color: #0000ff;">2</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">=</span> <span style="color: #ff0000;">'/s'</span><span style="color: #000066;">&#41;</span>
  <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000066;">ParamCount</span> <span style="color: #000066;">=</span> <span style="color: #0000ff;">0</span> <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #000000; font-weight: bold;">begin</span>
    OnServiceCreate<span style="color: #000066;">;</span>
&nbsp;
    ServiceTable<span style="color: #000066;">&#91;</span><span style="color: #0000ff;">0</span><span style="color: #000066;">&#93;</span><span style="color: #000066;">.</span><span style="color: #006600;">lpServiceName</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ServiceName<span style="color: #000066;">;</span>
    ServiceTable<span style="color: #000066;">&#91;</span><span style="color: #0000ff;">0</span><span style="color: #000066;">&#93;</span><span style="color: #000066;">.</span><span style="color: #006600;">lpServiceProc</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000066;">@</span>RegisterService<span style="color: #000066;">;</span>
    ServiceTable<span style="color: #000066;">&#91;</span><span style="color: #0000ff;">1</span><span style="color: #000066;">&#93;</span><span style="color: #000066;">.</span><span style="color: #006600;">lpServiceName</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">;</span>
    ServiceTable<span style="color: #000066;">&#91;</span><span style="color: #0000ff;">1</span><span style="color: #000066;">&#93;</span><span style="color: #000066;">.</span><span style="color: #006600;">lpServiceProc</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">;</span>
&nbsp;
    StartServiceCtrlDispatcher<span style="color: #000066;">&#40;</span>ServiceTable<span style="color: #000066;">&#91;</span><span style="color: #0000ff;">0</span><span style="color: #000066;">&#93;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">end</span>
  <span style="color: #000000; font-weight: bold;">else</span>
    <span style="color: #000066;">WriteLn</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Wrong argument!'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">.</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.cromis.net/blog/2011/04/how-to-make-a-very-small-windows-service-executable/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Contact on the blog</title>
		<link>http://www.cromis.net/blog/2011/03/contant-on-the-blog/</link>
		<comments>http://www.cromis.net/blog/2011/03/contant-on-the-blog/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 21:52:17 +0000</pubDate>
		<dc:creator>Iztok Kacin</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.cromis.net/blog/?p=844</guid>
		<description><![CDATA[If you tried to contact me via the contact page in the last few days, I was not reachable. The reason is, that I changed my gmail account password and forgot to change it in wordpress SMTP plugin. So if you did not receive a response, please try again and sorry for the inconvenience.]]></description>
			<content:encoded><![CDATA[<p>If you tried to contact me via the contact page in the last few days, I was not reachable. The reason is, that I changed my gmail account password and forgot to change it in wordpress SMTP plugin. So if you did not receive a response, please try again and sorry for the inconvenience.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cromis.net/blog/2011/03/contant-on-the-blog/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>New version of SimpleStorage and other updates</title>
		<link>http://www.cromis.net/blog/2011/03/new-version-of-simplestorage-and-other-updates/</link>
		<comments>http://www.cromis.net/blog/2011/03/new-version-of-simplestorage-and-other-updates/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 19:33:56 +0000</pubDate>
		<dc:creator>Iztok Kacin</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.cromis.net/blog/?p=807</guid>
		<description><![CDATA[Quite a lot of new code got piled up so without further ado here are the news. (You can get all new releases from the download page) SimpleStorage This a new major release (1.7.3) of SimpleStorage. And sadly also a breaking one. At least if you were writing your own filters and adapters. There was [...]]]></description>
			<content:encoded><![CDATA[<p>Quite a lot of new code got piled up so without further ado here are the news.</p>
<p>(You can get all new releases from the download page)</p>
<h3><span style="font-weight: normal;"><span></p>
<h3 style="font-size: 1.17em;">SimpleStorage</h3>
<p></span></span></h3>
<p style="text-align: justify;">This a new major release (1.7.3) of SimpleStorage. And sadly also a breaking one. At least if you were writing your own filters and adapters. There was no other way around if I wanted to write a good and clean code. All changes that were made revolve around filters and adapters. Here is the list of important changes</p>
<ul>
<li>Filters were extended to the document level. This means you can now compress and encrypt XML nodes or whole document in a transparent manner.</li>
<li>Chaining was introduced to filters. This means you can now encrypt and compress a document in a single step or if you like, in a single line of code <img src='http://www.cromis.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li>Encryption and compression are now integral part of SimpleStorage and no third party components are needed anymore.</li>
<li>Adapters and Filter now use cleaner approach, so no more strings as identifiers, to specify which filter or adapter you want.</li>
</ul>
<p>Let me give you some examples:</p>
<p>Compressing and the encrypting a whole document.</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;">NormalXML<span style="color: #000066;">.</span><span style="color: #006600;">Filter</span><span style="color: #000066;">&#40;</span>ZLIB<span style="color: #000066;">&#41;</span><span style="color: #000066;">.</span><span style="color: #006600;">Filter</span><span style="color: #000066;">&#40;</span>XTEA<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'MyStrongKey'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">.</span><span style="color: #006600;">SaveToFile</span><span style="color: #000066;">&#40;</span>FilteredXMLFileTwo<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></pre></div></div>

<p>The same but using a document fiter chain interface.</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;">DocumentFilterChain <span style="color: #000066;">:</span><span style="color: #000066;">=</span> CreateDocumentFilterChain<span style="color: #000066;">;</span>
DocumentFilterChain<span style="color: #000066;">.</span><span style="color: #006600;">AddFilter</span><span style="color: #000066;">&#40;</span>CompressedStorage<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
DocumentFilterChain<span style="color: #000066;">.</span><span style="color: #006600;">AddFilter</span><span style="color: #000066;">&#40;</span>EncryptedStorage<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'MyStrongKey'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
NormalXML <span style="color: #000066;">:</span><span style="color: #000066;">=</span> DocumentFilterChain<span style="color: #000066;">.</span><span style="color: #006600;">LoadFromFile</span><span style="color: #000066;">&#40;</span>FilteredXMLFileOne<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
NormalXML<span style="color: #000066;">.</span><span style="color: #006600;">SaveToFile</span><span style="color: #000066;">&#40;</span>NormalXMLFileOne<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></pre></div></div>

<p>Compressing using the compressed storage interface.</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;">CompressedStorage<span style="color: #000066;">.</span><span style="color: #006600;">SaveToFile</span><span style="color: #000066;">&#40;</span>DecompressedXML<span style="color: #000066;">,</span> CompressedXMLFileOne<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></pre></div></div>

<p>Compressing using the build in ZLIB filter.</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;">DecompressedXML<span style="color: #000066;">.</span><span style="color: #006600;">Filter</span><span style="color: #000066;">&#40;</span>ZLIB<span style="color: #000066;">&#41;</span><span style="color: #000066;">.</span><span style="color: #006600;">SaveToFile</span><span style="color: #000066;">&#40;</span>CompressedXMLFileTwo<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></pre></div></div>

<p>Do you see how simple it is to compress and encrypt a XML document. The other change is in the adapter code. There are no more strings to specify which adapter to use. It looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;">  SS<span style="color: #000066;">.</span><span style="color: #006600;">Ensure</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'MemTable'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">.</span><span style="color: #006600;">Adapter</span><span style="color: #000066;">&#40;</span>DataSet<span style="color: #000066;">&#41;</span><span style="color: #000066;">.</span><span style="color: #006600;">Load</span><span style="color: #000066;">&#40;</span>ClientDS<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></pre></div></div>

<p>and</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;">  SS<span style="color: #000066;">.</span><span style="color: #006600;">Get</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'MemTable'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">.</span><span style="color: #006600;">Adapter</span><span style="color: #000066;">&#40;</span>DataSet<span style="color: #000066;">&#41;</span><span style="color: #000066;">.</span><span style="color: #006600;">Save</span><span style="color: #000066;">&#40;</span>ClientDS<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></pre></div></div>

<p style="text-align: justify;">There are other smaller changes, but this are the major ones. Just a warning here. If you were writing adapters or filters (your own) then this is a breaking release and you will have to update your code to the new specifications. The examples that come withe the library are clear enough that it should be a breeze. For normal user nothing changes and the code will stay the same. I also left the old version of SimpleStorage available for download if people don&#8217;t want to upgrade right away.</p>
<p style="text-align: justify;">Also I would like to announce that I will begin writing basic documentation for SimpleStorage.</p>
<h3>ISAPIServer</h3>
<p style="text-align: justify;">This is a new component in the library. It is a standalone ISAPI server capable of processing Delphi ISAPI modules. You don&#8217;t need Apache or IIS. And it is build in the way, that you can use your favorite HTTP library to use it. It comes with already made bindings for Indy, but it would be equally simple to do bindings for Synapse or ICS. This is possible because it is designed in a very modular way. If any of you are interested in that, you can contact me and I can help with it. I am posting the whole ISAPI request code for Indy as an example:</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">procedure</span> TfMain<span style="color: #000066;">.</span><span style="color: #006600;">HTTPServerCommandGet</span><span style="color: #000066;">&#40;</span><span style="color: #008000; font-style: italic;">{$IFDEF Indy9}</span>
                                        AThread<span style="color: #000066;">:</span> TIdPeerThread<span style="color: #000066;">;</span>
                                      <span style="color: #008000; font-style: italic;">{$ELSE}</span>
                                        AContext<span style="color: #000066;">:</span> TIdContext<span style="color: #000066;">;</span>
                                      <span style="color: #008000; font-style: italic;">{$ENDIF}</span>
                                      ARequestInfo<span style="color: #000066;">:</span> TIdHTTPRequestInfo<span style="color: #000066;">;</span>
                                      AResponseInfo<span style="color: #000066;">:</span> TIdHTTPResponseInfo<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">var</span>
  ECB<span style="color: #000066;">:</span> TECBData<span style="color: #000066;">;</span>
  Port<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span>
  TempStr<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span>
  PathStr<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span>
  RootDir<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span>
  DDLFileName<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  TempStr <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000066;">Copy</span><span style="color: #000066;">&#40;</span>ARequestInfo<span style="color: #000066;">.</span><span style="color: #006600;">Document</span><span style="color: #000066;">,</span> <span style="color: #0000ff;">2</span><span style="color: #000066;">,</span> <span style="color: #000066;">Length</span><span style="color: #000066;">&#40;</span>ARequestInfo<span style="color: #000066;">.</span><span style="color: #006600;">Document</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  RootDir <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000066;">IncludeTrailingPathDelimiter</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">ExtractFilePath</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">ParamStr</span><span style="color: #000066;">&#40;</span><span style="color: #0000ff;">0</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  PathStr <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #ff0000;">'/'</span> <span style="color: #000066;">+</span> StrAfter<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'/'</span><span style="color: #000066;">,</span> TempStr<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  DDLFileName <span style="color: #000066;">:</span><span style="color: #000066;">=</span> StrBefore<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'/'</span><span style="color: #000066;">,</span> TempStr<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
&nbsp;
  <span style="color: #008000; font-style: italic;">{$IFDEF Indy9}</span>
    Port <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000066;">IntToStr</span><span style="color: #000066;">&#40;</span>AThread<span style="color: #000066;">.</span><span style="color: #006600;">Connection</span><span style="color: #000066;">.</span><span style="color: #006600;">Socket</span><span style="color: #000066;">.</span><span style="color: #006600;">Binding</span><span style="color: #000066;">.</span><span style="color: #006600;">Port</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  <span style="color: #008000; font-style: italic;">{$ELSE}</span>
    Port <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000066;">IntToStr</span><span style="color: #000066;">&#40;</span>AContext<span style="color: #000066;">.</span><span style="color: #006600;">Binding</span><span style="color: #000066;">.</span><span style="color: #006600;">Port</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  <span style="color: #008000; font-style: italic;">{$ENDIF}</span>
&nbsp;
  ECB <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ECBDataList<span style="color: #000066;">.</span><span style="color: #006600;">AcquireNewECB</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">try</span>
    FillECBFromRequest<span style="color: #000066;">&#40;</span>ECB<span style="color: #000066;">,</span> HTTPServer<span style="color: #000066;">.</span><span style="color: #006600;">KeepAlive</span><span style="color: #000066;">,</span> ARequestInfo<span style="color: #000066;">,</span> RootDir<span style="color: #000066;">,</span> DDLFileName<span style="color: #000066;">,</span> Port<span style="color: #000066;">,</span> PathStr<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    <span style="color: #000000; font-weight: bold;">try</span>
      FISAPIServer<span style="color: #000066;">.</span><span style="color: #006600;">Execute</span><span style="color: #000066;">&#40;</span>DDLFileName<span style="color: #000066;">,</span> ECB<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    <span style="color: #000000; font-weight: bold;">finally</span>
      FillResponseFromECB<span style="color: #000066;">&#40;</span>ECB<span style="color: #000066;">,</span> AResponseInfo<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">finally</span>
    ECBDataList<span style="color: #000066;">.</span><span style="color: #006600;">DeleteECB</span><span style="color: #000066;">&#40;</span>ECB<span style="color: #000066;">.</span><span style="color: #006600;">ECB</span><span style="color: #000066;">.</span><span style="color: #006600;">ConnID</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></pre></div></div>

<h3>RoboMailer</h3>
<p style="text-align: justify;">This is also a new component. It is intended as a simplified mass mailer component. It can also be used to send a single mail easily with no worries on how to set everything up correctly. It comes with a demo application, which can send mass mails. You can personify each mail with the data you provide.  Maybe it will be of use to somebody. It uses ICS as an engine.</p>
<h3>Threading unit</h3>
<p style="text-align: justify;">This unit got two interesting additions. First one is a lock free stack based on the windows API. No home made code here, just a wrapper around windows API. And the second one is a thread safe queue. It uses critical sections but tries to lock as little as possible. I have done some tests and it is very fast. In fact it is almost as fast as a lock free one, but the code is much much simpler. There is very little difference in speed in fact it is negligible in real world problems.</p>
<p>ChangleLog:</p>
<ul>
<li>1.4.0
<ul>
<li>Added TLockFreeStack based on Windows SLISTS</li>
<li>Added TThreadSafeQueue based on linked lists</li>
</ul>
</li>
<li>1.3.7
<ul>
<li>Added ShutdownTimeout (INFINITE by default)</li>
<li>Wait for all tasks to finish then shutting down the task pool</li>
</ul>
</li>
</ul>
<h3>CRON Scheduler</h3>
<p><span style="font-weight: normal;">Change Log:</span></p>
<ul>
<li>2.0.3
<ul>
<li>added HasValue function for TChronEntry</li>
</ul>
</li>
</ul>
<div id="_mcePaste">
<h3 style="font-size: 1.17em;">SimpleLog</h3>
</div>
<p><span style="font-weight: normal;">Change Log:</span></p>
<ul>
<li>1.2.0
<ul>
<li>Use the new rewritten Cromis.Exceptions</li>
<li>Log file limit is now working correctly</li>
</ul>
</li>
</ul>
<div id="_mcePaste">
<h3 style="font-size: 1.17em;">XTEA</h3>
</div>
<div id="_mcePaste">
<p><span style="font-weight: normal;">Change Log:</span></p>
<ul>
<li>1.1.0
<ul>
<li>Added overloaded procedures for stream and file encryption / decryption</li>
</ul>
</li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.cromis.net/blog/2011/03/new-version-of-simplestorage-and-other-updates/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
