<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>The Wiert Corner - Jeroen Pluimers' irregular stream of Wiert stuff</title>
	<atom:link href="http://wiert.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://wiert.wordpress.com</link>
	<description>on .NET, C#, Delphi, databases, and personal interests</description>
	<lastBuildDate>Sun, 08 Nov 2009 22:23:18 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='wiert.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/b304a1e247cd5ff89f194446f9a3ff12?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>The Wiert Corner - Jeroen Pluimers' irregular stream of Wiert stuff</title>
		<link>http://wiert.wordpress.com</link>
	</image>
			<item>
		<title>IIS Error 404 2 1260</title>
		<link>http://wiert.wordpress.com/2009/11/09/iis-error-404-2-1260/</link>
		<comments>http://wiert.wordpress.com/2009/11/09/iis-error-404-2-1260/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 22:23:18 +0000</pubDate>
		<dc:creator>jpluimers</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[SOAP/WebServices]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://wiert.wordpress.com/?p=952</guid>
		<description><![CDATA[This just had this happen on a Windows 2003 server with a client&#8217;s client.
Any .asmx page would return a 404 error like this IIS log line shows:
2009-11-06 09:46:05 127.0.0.1 GET /MyVirtualDirectory/MyWebService.asmx &#8211; 80 &#8211; 127.0.0.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+SV1;+.NET+CLR+1.1.4322;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.4506.2152;+.NET+CLR+3.5.30729) 404 2 1260
Searching for &#8220;iis 404 2 1260 asp.net&#8221; found this top from Marc Valk, that solved the issue: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wiert.wordpress.com&blog=7443331&post=952&subd=wiert&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This just had this happen on a Windows 2003 server with a client&#8217;s client.</p>
<p>Any .asmx page would return a 404 error like this IIS log line shows:</p>
<blockquote><p>2009-11-06 09:46:05 127.0.0.1 GET /MyVirtualDirectory/MyWebService.asmx &#8211; 80 &#8211; 127.0.0.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+SV1;+.NET+CLR+1.1.4322;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.4506.2152;+.NET+CLR+3.5.30729) 404 2 1260</p></blockquote>
<p>Searching for &#8220;<a href="http://www.google.nl/search?q=iis+404+2+1260+asp.net" target="_blank">iis 404 2 1260 asp.net</a>&#8221; found this top from <a href="http://www.marcvalk.net/" target="_blank">Marc Valk</a>, that <a href="http://www.marcvalk.net/2009/07/iis-error-404-2-1260/" target="_blank">solved the issue</a>: ASP.NET v2.0.5727 was prohibited to run.<br />
Which means that none of the ASP.NET bound extensions would work: they all returned 404 errors.</p>
<p>(Note: if you are wondering where your IIS log files are, <a href="http://www.smartertools.com/Portal/KB/a154/how-to-where-are-my-iis-log-files-stored.aspx" target="_blank">this post shows you</a>).</p>
<p>&#8211;jeroen</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wiert.wordpress.com/952/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wiert.wordpress.com/952/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wiert.wordpress.com/952/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wiert.wordpress.com/952/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wiert.wordpress.com/952/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wiert.wordpress.com/952/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wiert.wordpress.com/952/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wiert.wordpress.com/952/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wiert.wordpress.com/952/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wiert.wordpress.com/952/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wiert.wordpress.com&blog=7443331&post=952&subd=wiert&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://wiert.wordpress.com/2009/11/09/iis-error-404-2-1260/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11dc84116344a9ac90d0c2d01c1d4297?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jpluimers</media:title>
		</media:content>
	</item>
		<item>
		<title>XP embedded &#8211; .NET Framework 3.0</title>
		<link>http://wiert.wordpress.com/2009/10/27/xp-embedded-net-framework-3-0/</link>
		<comments>http://wiert.wordpress.com/2009/10/27/xp-embedded-net-framework-3-0/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 15:22:24 +0000</pubDate>
		<dc:creator>jpluimers</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[XP-embedded]]></category>

		<guid isPermaLink="false">http://wiert.wordpress.com/?p=945</guid>
		<description><![CDATA[The &#8220;out of the box&#8221; .NET 3.0 component in Windows XP Embedded drags way too many required components (like the System Restore Core) into your image.
So most people build their own .NET 3.0 component.
If you get errors like this when you make your own, then you didn&#8217;t get your dependencies right.
These are the dependencies for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wiert.wordpress.com&blog=7443331&post=945&subd=wiert&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The &#8220;out of the box&#8221; .NET 3.0 component in Windows XP Embedded drags <a href="http://blogs.msdn.com/embedded/archive/2007/03/23/deploying-net-framework-3-0-desktop-distribution-package-on-windows-xp-embedded-sp2-runtime.aspx" target="_blank">way too many required components</a> (like the System Restore Core) into your image.</p>
<p>So most people build their own .NET 3.0 component.</p>
<p>If you get errors like this when you make your own, then you didn&#8217;t get your dependencies right.</p>
<p>These are the dependencies for the .NET 3.0 framework:</p>
<ul>
<li>.NET Framework 2.0</li>
<li>ASP.NET 2.0</li>
</ul>
<p>These are the error messages you get when you forget the ASP.NET 2.0 dependency:</p>
<ul>
<li><a href="http://www.google.com/search?q=&quot;windows+communication+foundation&quot;+1603" target="_blank">ERROR_INSTALL_FAILURE 1603 Fatal error during installation</a></li>
</ul>
<p>Of course I always get all my dependencies right <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> <br />(yeah right, not this time)</p>
<p>&#8211;jeroen</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wiert.wordpress.com/945/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wiert.wordpress.com/945/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wiert.wordpress.com/945/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wiert.wordpress.com/945/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wiert.wordpress.com/945/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wiert.wordpress.com/945/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wiert.wordpress.com/945/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wiert.wordpress.com/945/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wiert.wordpress.com/945/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wiert.wordpress.com/945/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wiert.wordpress.com&blog=7443331&post=945&subd=wiert&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://wiert.wordpress.com/2009/10/27/xp-embedded-net-framework-3-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11dc84116344a9ac90d0c2d01c1d4297?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jpluimers</media:title>
		</media:content>
	</item>
		<item>
		<title>Delphi &#8211; for &#8230; in on enumerated data types</title>
		<link>http://wiert.wordpress.com/2009/10/27/delphi-for-in-on-enumerated-data-types/</link>
		<comments>http://wiert.wordpress.com/2009/10/27/delphi-for-in-on-enumerated-data-types/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 05:00:52 +0000</pubDate>
		<dc:creator>jpluimers</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://wiert.wordpress.com/?p=938</guid>
		<description><![CDATA[I like enumerated type a lot.
The allow you to perfectly describe what the members of such a type actually mean, much more readable than a bunch of integer constants!
Given an enumerated type like TTraphicLightColors

type
  TTraphicLightColors = (Red, Orange, Green);

I always wondered why  - since the for ... in statement was added to the structured [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wiert.wordpress.com&blog=7443331&post=938&subd=wiert&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I like <a href="http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/simpletypes_xml.html" target="_blank">enumerated type</a> a lot.<br />
The allow you to perfectly describe what the members of such a type actually mean, much more readable than a bunch of integer constants!</p>
<p>Given an enumerated type like TTraphicLightColors</p>
<pre class="brush: delphi;">
type
  TTraphicLightColors = (Red, Orange, Green);
</pre>
<p>I always wondered why  - since the <code style="font-size:1.1em;"><a href="http://wiert.wordpress.com/2009/05/07/delphi-class-helper-to-add-for-%E2%80%A6-in-support-for-tcomponentcomponentscomponentcount/" target="_blank">for ... in</a></code> statement was added to the <a href="http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/declarationsandstatements_xml.html#537472756374757265642053746174656D656E7473" target="_blank">structured statements</a> part of the Delphi language &#8211; it is not possible to use a for &#8230; in statement like the this:</p>
<pre class="brush: delphi;">&lt;/span&gt;
&lt;pre&gt;var
  TraphicLightColor: TTraphicLightColors;
begin
  try
    for TraphicLightColor in TraphicLightColor do
      ShowValueAsTraphicLightColor(Ord(Value));
    // [DCC Error] EnumerationEnumeratorDemoProcedures.dpr(63): E2430 for-in statement cannot operate on collection type 'TTraphicLightColors'
end;
</pre>
<p>Somehow, for &#8230; in <a href="http://docs.embarcadero.com/products/rad_studio/radstudio2007/RS2007_helpupdates/HUpdate4/EN/html/devcommon/cm_not_enumerable_xml.html" target="_blank">expects a collection type</a>.<br />
A request for <a href="http://qc.codegear.com/wc/qcmain.aspx?d=59795" target="_blank">the <strong>for &#8230; in do on enumerated types</strong> compiler feature is in QC</a>, but it is closed with reason &#8220;Won&#8217;t do&#8221;.</p>
<p>Back in Delphi 2007, I tried working around this by writing a type implementing the <a href="http://wiert.wordpress.com/2009/05/07/delphi-class-helper-to-add-for-%E2%80%A6-in-support-for-tcomponentcomponentscomponentcount/" target="_blank">GetEnumerator pattern</a> myself, but got <a href="http://qc.embarcadero.com/wc/qcmain.aspx?d=65594" target="_blank">Internal Errors</a> when compiling anything but the most basic sample.</p>
<p>Until today, where I found how I could get that most basic sample to work!<br />
It is an example on how you could implement this: it is research, so you decide if you find the result practical enough to use yourself.</p>
<p><span id="more-938"></span></p>
<p>Lets start with the REnumerationEnumerator record and the TEnumerationEnumerator enumerator class that it generates:</p>
<pre class="brush: delphi;">
unit EnumerationEnumerator;

interface

uses
  TypInfo;

type
  TEnumerationEnumerator = class
  private
    FMinValue: Integer;
    FMaxValue: Integer;
    FValue: Integer;
  public
    constructor Create(aEnumeratorTypeInfo: PTypeInfo);
    function GetCurrent: Integer;
    function MoveNext: Boolean;
    property Current: Integer read GetCurrent;
  end;

  REnumerationEnumerator = record
  private
    EnumeratorTypeInfo: PTypeInfo;
  public
    constructor Create(aEnumeratorTypeInfo: PTypeInfo);
    class function From(aEnumeratorTypeInfo: PTypeInfo): REnumerationEnumerator; static;
    function GetEnumerator: TEnumerationEnumerator;
  end;

implementation

{ REnumerationEnumerator }

constructor REnumerationEnumerator.Create(aEnumeratorTypeInfo: PTypeInfo);
begin
  Assert(aEnumeratorTypeInfo^.Kind = tkEnumeration);
  EnumeratorTypeInfo := aEnumeratorTypeInfo;
end;

{ REnumerationEnumerator }

class function REnumerationEnumerator.From(aEnumeratorTypeInfo: PTypeInfo): REnumerationEnumerator;
begin
  Result := REnumerationEnumerator.Create(aEnumeratorTypeInfo);
end;

function REnumerationEnumerator.GetEnumerator: TEnumerationEnumerator;
begin
  Result := TEnumerationEnumerator.Create(EnumeratorTypeInfo);
end;

{ TEnumerationEnumerator }

constructor TEnumerationEnumerator.Create(aEnumeratorTypeInfo: PTypeInfo);
var
  EnumeratorTypeInfo: PTypeInfo;
  EnumerationTypeData: PTypeData;
begin
  Assert(aEnumeratorTypeInfo^.Kind = tkEnumeration);
  EnumeratorTypeInfo := aEnumeratorTypeInfo;
  EnumerationTypeData := GetTypeData(EnumeratorTypeInfo);
  FMinValue := EnumerationTypeData.MinValue;
  FMaxValue := EnumerationTypeData.MaxValue;
  FValue := FMinValue-1;
end;

function TEnumerationEnumerator.GetCurrent: Integer;
begin
  Result := FValue;
end;

function TEnumerationEnumerator.MoveNext: Boolean;
begin
  Result := FValue &lt; FMaxValue;
  if Result then
    Inc(FValue);
end;

end.
</pre>
<p>Note it contains both a <strong>Create</strong> constructor and <strong>From</strong> static class function.<br />
This is by intent, I will explain this shortly.</p>
<p>The above unit gets great result when you call it in the main body of a simple console application like this:</p>
<pre class="brush: delphi;">
program EnumerationEnumeratorDemo;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  TypInfo,
  EnumerationEnumerator in 'EnumerationEnumerator.pas',
  TraphicLightColorsUnit in 'TraphicLightColorsUnit.pas';

procedure ShowValueAsTraphicLightColor(Value: Integer);
var
  TraphicLightColorsTypeInfo: PTypeInfo;
begin
  TraphicLightColorsTypeInfo := TypeInfo(TTraphicLightColors);
  Writeln(Value, ' ', GetEnumName(TraphicLightColorsTypeInfo, Value));
end;

var
  Value: Integer;
  TraphicLightColor: TTraphicLightColors;
  TraphicLightColorsTypeInfo: PTypeInfo;
begin
  try
    Writeln('For in - create constructor - only works in your main program:');
    TraphicLightColorsTypeInfo := TypeInfo(TTraphicLightColors);
    for Value in REnumerationEnumerator.Create(TraphicLightColorsTypeInfo) do
    begin
      // TraphicLightColor := TTraphicLightColors(Value);
      ShowValueAsTraphicLightColor(Value);
    end;

    Writeln('For to:');
    for TraphicLightColor := Low(TTraphicLightColors) to High(TTraphicLightColors) do
    begin
      Value := Ord(TraphicLightColor);
      ShowValueAsTraphicLightColor(Value);
    end;

    Write('Press &lt;Enter&gt;');
    Readln;
  except
    on E:Exception do
      Writeln(E.Classname, ': ', E.Message);
  end;
end.
</pre>
<p>You get output like this:</p>
<blockquote><p>For in &#8211; create constructor &#8211; only works in your main program:<br />
0 Red<br />
1 Orange<br />
2 Green<br />
For to:<br />
0 Red<br />
1 Orange<br />
2 Green<br />
Press</p></blockquote>
<p>Until you start using that code in a procedure or function, then you consistently get Internal Error messages from the compiler.<br />
The exact Internal Error is always of type F2084, but the subtype depends on the version of Delphi you have installed:</p>
<pre class="brush: delphi;">
procedure ForIn_InternalCompilerError;
var
  Value: Integer;
  TraphicLightColorsTypeInfo: PTypeInfo;
begin
  TraphicLightColorsTypeInfo := TypeInfo(TTraphicLightColors);
  for Value in REnumerationEnumerator.Create(TraphicLightColorsTypeInfo) do
    ShowValueAsTraphicLightColor(Value);
end;
// Delphi 2007:
// [DCC Error] EnumerationEnumeratorDemoProcedures.dpr(49): F2084 Internal Error: C14125
// Delphi 2009:
// [DCC Error] EnumerationEnumeratorDemoProcedures.dpr(49): F2084 Internal Error: C15170
// Delphi 2010:
// [DCC Error] EnumerationEnumeratorDemoProcedures.dpr(49): F2084 Internal Error: C15700
</pre>
<p>Bummer. It actually caused me too loose interest in using for &#8230; in with enumerated types for a while.<br />
Until today, when I needed a static class function returning an instance of another type.<br />
Then I realized that there is not much difference between a constructor, and such function.</p>
<p>So in addition to the Create constructor, I added a From function like this:</p>
<pre class="brush: delphi;">
    constructor Create(aEnumeratorTypeInfo: PTypeInfo);
    class function From(aEnumeratorTypeInfo: PTypeInfo): REnumerationEnumerator; static;
</pre>
<p>Lo and behold, this code now compiles fine:</p>
<pre class="brush: delphi;">
procedure ForIn;
var
  Value: Integer;
  TraphicLightColorsTypeInfo: PTypeInfo;
begin
  TraphicLightColorsTypeInfo := TypeInfo(TTraphicLightColors);
  for Value in REnumerationEnumerator.From(TraphicLightColorsTypeInfo) do
    ShowValueAsTraphicLightColor(Value);
end;
</pre>
<p>This finally creates a work around the  <a href="http://qc.embarcadero.com/wc/qcmain.aspx?d=65594" target="_blank">Internal Errors mentioned in QC65594</a>.</p>
<p>I&#8217;m still a bit puzzled why this works with a static class function, but not with a constructor.<br />
If anyone has a clue about that, please drop a note below.</p>
<p>&#8211;jeroen</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wiert.wordpress.com/938/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wiert.wordpress.com/938/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wiert.wordpress.com/938/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wiert.wordpress.com/938/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wiert.wordpress.com/938/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wiert.wordpress.com/938/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wiert.wordpress.com/938/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wiert.wordpress.com/938/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wiert.wordpress.com/938/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wiert.wordpress.com/938/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wiert.wordpress.com&blog=7443331&post=938&subd=wiert&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://wiert.wordpress.com/2009/10/27/delphi-for-in-on-enumerated-data-types/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11dc84116344a9ac90d0c2d01c1d4297?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jpluimers</media:title>
		</media:content>
	</item>
		<item>
		<title>Delphi operator overloading: table of operators, names, and some notes on usage and &#8216;glitches&#8217;</title>
		<link>http://wiert.wordpress.com/2009/10/19/delphi-operator-overloading-table-of-operators-names-and-some-notes-on-usage-and-glitches/</link>
		<comments>http://wiert.wordpress.com/2009/10/19/delphi-operator-overloading-table-of-operators-names-and-some-notes-on-usage-and-glitches/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 11:38:15 +0000</pubDate>
		<dc:creator>jpluimers</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Event]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://wiert.wordpress.com/?p=933</guid>
		<description><![CDATA[Operator overloading is a very nice feature of the Delphi language.
However. the Delphi documentation on Operator overloading is not completely right.
Below is my table of what I found out so far, and some notes.
It is part of my &#8220;Nullable types in Delphi&#8221; session that I gave on some conferences.
The downloads for that session contain more [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wiert.wordpress.com&blog=7443331&post=933&subd=wiert&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Operator overloading is a very nice feature of the Delphi language.<br />
However. the Delphi documentation on Operator overloading is not completely right.</p>
<p>Below is my table of what I found out so far, and some notes.</p>
<p>It is part of my &#8220;Nullable types in Delphi&#8221; session that I gave on <a href="http://wiert.wordpress.com/conferences-seminars-and-other-public-appearances/" target="_blank">some conferences</a>.<br />
The <a href="http://www.xs4all.nl/~jp/blog-dl/2009/DelphiLive.2009/DelphiLive.2009.Nullable-types-in-Delphi-Win32.Delphi-classic.published.zip" target="_blank">downloads for that session</a> contain more detailed information.</p>
<p>This is just an abstract to get you going and a try to answer this <a href="http://stackoverflow.com/questions/1587777/what-kinds-of-operator-overloads-does-delphi-support" target="_blank">operator overloading question on Stackoverflow</a>.<br />
Download the full presentation to get more in depth information.</p>
<p>Let me know if you need more information.</p>
<h1 style="font-size:2em;">Notes</h1>
<h2 style="font-size:1.5em;">Operator overloading</h2>
<h3>Add your own “behaviour” to operators</h3>
<ul>
<li>Win32: Works only for records, not classes!</li>
<li>An operator and the operand(s)<br />
are being implemented worden by a “class operator”;<br />
this is a kind of class method with name and argumen(s)</li>
</ul>
<p>Example:</p>
<ul>
<li>Multiplication X : = A * B;</li>
<li>Operator: *</li>
<li>Name: Multiply</li>
<li>Operands: 2 -&gt; two parameters</li>
</ul>
<pre class="brush: delphi;">
type
  TMyRecord = record
    class operator Multiply(A, B: TMyRecord): TMyRecord;
  end;
</pre>
<h3>Documentation is not correct!</h3>
<ul>
<li><a href="http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/operatoroverloads_xml.html" target="_blank">http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/operatoroverloads_xml.html</a></li>
<li><a href="http://docwiki.embarcadero.com/RADStudio/en/Operator_Overloading" target="_blank">http://docwiki.embarcadero.com/RADStudio/en/Operator_Overloading</a></li>
<li>Win32 only records; .NET classes and records</li>
<li>BitwiseNot does not exist (use LogicalNot)</li>
<li>At least 1 operand must be of the same type as your record data type</li>
<li>Result type may be anything</li>
</ul>
<h3>Watch the result type of comparison operators!</h3>
<p>Tips:</p>
<ul>
<li>Some operators should be overloaded pair-wise<br />
= and &lt;&gt;<br />
shl and shr<br />
&lt; and &gt;=<br />
&gt; and &lt;=<br />
dec and inc<br />
+ and -<br />
/ and *<br />
div and mod</li>
<li>Prefer Explicit over Implicit operators
<ul>
<li>Beware of the built-in type coercion (implicit operators)</li>
<li>e.g
<ul>
<li> Byte to Integer;</li>
<li> Integer to Double;</li>
<li>Variants from/to anything!</li>
</ul>
</li>
</ul>
</li>
</ul>
<h1>Table of operators</h1>
<table border="0">
<col width="71"></col>
<col width="24"></col>
<col width="108"></col>
<col width="137"></col>
<col width="80"></col>
<col width="85"></col>
<tbody>
<tr>
<td width="71" height="17"><strong>operator</strong></td>
<td width="24"><strong>#</strong></td>
<td width="108"><strong>usage</strong></td>
<td width="137"><strong>name</strong></td>
<td width="80"><strong>cagetory</strong></td>
<td width="85"><strong>*</strong></td>
</tr>
<tr>
<td height="17">and</td>
<td>2</td>
<td>R := A and B;</td>
<td>BitwiseAnd</td>
<td>bit</td>
<td></td>
</tr>
<tr>
<td height="17">not</td>
<td>1</td>
<td>R := not A;</td>
<td>//BitwiseNot</td>
<td>bit</td>
<td>glitch: does not exist!</td>
</tr>
<tr>
<td height="17">or</td>
<td>2</td>
<td>R := A or B;</td>
<td>BitwiseOr</td>
<td>bit</td>
<td></td>
</tr>
<tr>
<td height="17">xor</td>
<td>2</td>
<td>R := A xor B;</td>
<td>BitwiseXor</td>
<td>bit</td>
<td></td>
</tr>
<tr>
<td height="17">() cast</td>
<td>1</td>
<td>R := TValue(A);</td>
<td>Explicit</td>
<td>conversion</td>
<td></td>
</tr>
<tr>
<td height="17">:=</td>
<td>1</td>
<td>R := A;</td>
<td>Implicit</td>
<td>conversion</td>
<td></td>
</tr>
<tr>
<td height="17"><strong>operator</strong></td>
<td><strong>#</strong></td>
<td><strong>usage</strong></td>
<td><strong>name</strong></td>
<td><strong>category</strong></td>
<td><strong>*</strong></td>
</tr>
<tr>
<td height="17">round</td>
<td>1</td>
<td>R := Round(A);</td>
<td>Round</td>
<td>function</td>
<td></td>
</tr>
<tr>
<td height="17">trunc</td>
<td>1</td>
<td>R := Trunc(A);</td>
<td>Trunc</td>
<td>function</td>
<td></td>
</tr>
<tr>
<td height="17">and</td>
<td>2</td>
<td>R := A and B;</td>
<td>LogicalAnd</td>
<td>logical</td>
<td></td>
</tr>
<tr>
<td height="17">not</td>
<td>1</td>
<td>R := not A;</td>
<td>LogicalNot</td>
<td>logical</td>
<td></td>
</tr>
<tr>
<td height="17">or</td>
<td>2</td>
<td>R := A or B;</td>
<td>LogicalOr</td>
<td>logical</td>
<td></td>
</tr>
<tr>
<td height="17">xor</td>
<td>2</td>
<td>R := A xor B;</td>
<td>LogicalXor</td>
<td>logical</td>
<td></td>
</tr>
<tr>
<td height="17"><strong>operator</strong></td>
<td><strong>#</strong></td>
<td><strong>usage</strong></td>
<td><strong>name</strong></td>
<td><strong>category</strong></td>
<td><strong>*</strong></td>
</tr>
<tr>
<td height="17">+</td>
<td>2</td>
<td>R := A + B;</td>
<td>Add</td>
<td>binary</td>
<td></td>
</tr>
<tr>
<td height="17">/</td>
<td>2</td>
<td>R := A / B;</td>
<td>Divide</td>
<td>binary</td>
<td></td>
</tr>
<tr>
<td height="17">div</td>
<td>2</td>
<td>R := A div B;</td>
<td>IntDivide</td>
<td>binary</td>
<td></td>
</tr>
<tr>
<td height="17">mod</td>
<td>2</td>
<td>R := A mod B;</td>
<td>Modulus</td>
<td>binary</td>
<td></td>
</tr>
<tr>
<td height="17">*</td>
<td>2</td>
<td>R := A * B;</td>
<td>Multiply</td>
<td>binary</td>
<td></td>
</tr>
<tr>
<td height="17">-</td>
<td>2</td>
<td>R := A &#8211; B;</td>
<td>Subtract</td>
<td>binary</td>
<td></td>
</tr>
<tr>
<td height="17"><strong>operator</strong></td>
<td><strong>#</strong></td>
<td><strong>usage</strong></td>
<td><strong>name</strong></td>
<td><strong>category</strong></td>
<td><strong>*</strong></td>
</tr>
<tr>
<td height="17">shl</td>
<td>2</td>
<td>R := A shl B;</td>
<td>LeftShift</td>
<td>binary</td>
<td>name is confusing</td>
</tr>
<tr>
<td height="17">shr</td>
<td>2</td>
<td>R := A shr B;</td>
<td>RightShift</td>
<td>binary</td>
<td>name is confusing</td>
</tr>
<tr>
<td height="17">-</td>
<td>1</td>
<td>R := -A;</td>
<td>Negative</td>
<td>binary</td>
<td></td>
</tr>
<tr>
<td height="17">+</td>
<td>1</td>
<td>R := +A;</td>
<td>Positive</td>
<td>binary</td>
<td></td>
</tr>
<tr>
<td height="17">dec</td>
<td>1</td>
<td>Dec(A);</td>
<td>Dec</td>
<td>self</td>
<td></td>
</tr>
<tr>
<td height="17">inc</td>
<td>1</td>
<td>Inc(A);</td>
<td>Inc</td>
<td>self</td>
<td></td>
</tr>
<tr>
<td height="17"><strong>operator</strong></td>
<td><strong>#</strong></td>
<td><strong>usage</strong></td>
<td><strong>name</strong></td>
<td><strong>category</strong></td>
<td><strong>*</strong></td>
</tr>
<tr>
<td height="17">=</td>
<td>2</td>
<td>R := A = B;</td>
<td>Equal</td>
<td>comparison</td>
<td></td>
</tr>
<tr>
<td height="17">&gt;</td>
<td>2</td>
<td>R := A &gt; B;</td>
<td>GreaterThan</td>
<td>comparison</td>
<td></td>
</tr>
<tr>
<td height="17">&gt;=</td>
<td>2</td>
<td>R := A &gt;= B;</td>
<td>GreaterThanOrEqual</td>
<td>comparison</td>
<td></td>
</tr>
<tr>
<td height="17">&lt;</td>
<td>2</td>
<td>R := A &lt; B;</td>
<td>LessThan</td>
<td>comparison</td>
<td></td>
</tr>
<tr>
<td height="17">&lt;=</td>
<td>2</td>
<td>R := A &lt;= B;</td>
<td>LessThanOrEqual</td>
<td>comparison</td>
<td></td>
</tr>
<tr>
<td height="17">&lt;&gt;</td>
<td>2</td>
<td>R := A &lt;&gt; B;</td>
<td>NotEqual</td>
<td>comparison</td>
<td></td>
</tr>
</tbody>
</table>
<p>&#8211;jeroen</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wiert.wordpress.com/933/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wiert.wordpress.com/933/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wiert.wordpress.com/933/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wiert.wordpress.com/933/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wiert.wordpress.com/933/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wiert.wordpress.com/933/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wiert.wordpress.com/933/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wiert.wordpress.com/933/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wiert.wordpress.com/933/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wiert.wordpress.com/933/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wiert.wordpress.com&blog=7443331&post=933&subd=wiert&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://wiert.wordpress.com/2009/10/19/delphi-operator-overloading-table-of-operators-names-and-some-notes-on-usage-and-glitches/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11dc84116344a9ac90d0c2d01c1d4297?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jpluimers</media:title>
		</media:content>
	</item>
		<item>
		<title>Delphi &#8211; list of posts about hidden registry entries</title>
		<link>http://wiert.wordpress.com/2009/10/15/delphi-list-of-posts-about-hidden-registry-entries/</link>
		<comments>http://wiert.wordpress.com/2009/10/15/delphi-list-of-posts-about-hidden-registry-entries/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 19:56:08 +0000</pubDate>
		<dc:creator>jpluimers</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://wiert.wordpress.com/?p=914</guid>
		<description><![CDATA[There are quite a few registry tricks that you can perform to influence the Delphi IDE.
If you have any registry settings to share, please let me know by posting a comment below, or filling out the contact form.
This summary will be enhanced over time:

20091015 &#8211; Chris Bensen &#8211; Delphi Tips and Tricks &#8211; Additional Files
20090509 &#8211; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wiert.wordpress.com&blog=7443331&post=914&subd=wiert&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>There are quite a few registry tricks that you can perform to influence the Delphi IDE.</p>
<p>If you have any registry settings to share, please let me know by posting a comment below, or filling out the <a href="http://wiert.wordpress.com/contact-form/" target="_blank">contact form</a>.</p>
<p>This summary will be enhanced over time:</p>
<ul>
<li>20091015 &#8211; <a href="http://chrisbensen.blogspot.com/" target="_blank">Chris Bensen</a> &#8211; <a href="http://chrisbensen.blogspot.com/2009/10/delphi-tips-and-tricks-additional-files.html" target="_blank">Delphi Tips and Tricks &#8211; Additional Files</a></li>
<li>20090509 &#8211; René Rikkers - <a href="http://blogs.embarcadero.com/nickhodges/2009/05/27/39241" target="_blank">Delphi 2009 broken after installing Update 2</a></li>
<li><a href="http://blogs.embarcadero.com/nickhodges/2009/05/27/39241" target="_blank"></a>20080912 - <a href="http://blogs.embarcadero.com/matthiaseissing/" target="_blank">Matthias Eissing</a> - <a href="http://blogs.embarcadero.com/matthiaseissing/2008/09/12/38509" target="_blank">C++ Builder 2007 und der Remote Debugger</a></li>
<li><a href="http://blogs.embarcadero.com/matthiaseissing/2008/09/12/38509" target="_blank"></a>20071017 &#8211; <a href="http://chrisbensen.blogspot.com/" target="_blank">Chris Bensen</a> &#8211; <a href="http://chrisbensen.blogspot.com/2007/10/delphi-and-cbuilder-ide-memory-usage.html" target="_blank">Delphi and C++ Builder IDE Memory Usage Tip</a></li>
<li>20070928 - <a href="http://blogs.embarcadero.com/sergiocardoso/" target="_blank">Sergio Cardoso</a> - <a href="http://blogs.embarcadero.com/sergiocardoso/2007/09/28/are-you-nuts/" target="_blank">Are you nuts?</a></li>
<li><a href="http://blogs.embarcadero.com/sergiocardoso/2007/09/28/are-you-nuts/" target="_blank"></a>20070920 - <a href="http://blogs.embarcadero.com/dclegg/" target="_blank">David Clegg</a> - <a href="http://blogs.embarcadero.com/dclegg/2007/09/20/5" target="_blank">Maximizing your RAD Studio 2007 experience</a></li>
<li><a href="http://blogs.embarcadero.com/nickhodges/2009/05/27/39241" target="_blank"></a>20070509 - <a href="http://blog.fredrikhaglund.se/blog/" target="_blank">Fredrik Haglund</a> - <a href="http://blog.fredrikhaglund.se/blog/2007/05/09/small-questions/" target="_blank">How do I get my application with Paradox tables to work on Windows Vista?</a></li>
<li><a href="http://blog.fredrikhaglund.se/blog/2007/05/09/small-questions/" target="_blank"></a>20070313 &#8211; <a href="http://blogs.embarcadero.com/chrishesik/" target="_blank">Chris Hesik</a> &#8211; <a href="http://blogs.embarcadero.com/chrishesik/2007/03/13/32958" target="_blank">Source has been modified. Rebuild?</a></li>
<li>20061019 - <a href="http://www.stevetrefethen.com/blog/" target="_blank">Steve Trefethen</a> - <a href="http://www.stevetrefethen.com/blog/IE7IsNowAvailableGetYourBDSRegFileHere.aspx" target="_blank">IE7 is now available get your BDS reg file here</a></li>
<li>20060110 &#8211; <a href="http://blogs.embarcadero.com/medington/" target="_blank">Mark Edington</a> &#8211; <a href="http://blogs.embarcadero.com/medington/delphi-startup-times-and-the-kitchen-sink" target="_blank">Delphi Startup Times and the Kitchen Sink</a></li>
<li>20051219 - <a href="http://blogs.embarcadero.com/adammarkowitz/" target="_blank">Adam Markowitz</a> - <a href="http://blogs.embarcadero.com/adammarkowitz/2005/12/19/22610" target="_blank">Displaying macros in Code Completion (C++Builder2006)</a></li>
<li>20051209 &#8211; <a href="http://blogs.embarcadero.com/adammarkowitz/" target="_blank">Adam Markowitz</a> &#8211; <a href="http://blogs.embarcadero.com/adammarkowitz/2005/12/09/22423" target="_blank">Hidden feature, anyone?! (Delphi2006)</a></li>
<li>20051208 - <a href="http://blogs.embarcadero.com/chrishesik/" target="_blank">Chris Hesik</a> - <a href="http://blogs.embarcadero.com/chrishesik/2005/12/08/22398" target="_blank">BDS 2006 Debugger and .NET 2.0 compatibility</a></li>
<li>20040929 &#8211; <a href="http://blogs.embarcadero.com/corbindunn/" target="_blank">Corbin Dunn</a> &#8211; <a href="http://blogs.embarcadero.com/corbindunn/2004/09/29/1483" target="_blank">Delphi 8 Tips, Tricks and Speed Improvements</a></li>
<li>20040923 - <a href="http://blogs.embarcadero.com/abauer" target="_blank">Allen Bauer</a> - <a href="http://blogs.embarcadero.com/abauer/2004/09/23/1449" target="_blank">Newsgroups leakage&#8230;</a></li>
<li>20041228 &#8211; <a href="http://blogs.embarcadero.com/danielp" target="_blank">Daniel Polistchuck</a> &#8211; <a href="http://blogs.embarcadero.com/danielp/2004/12/28/2281" target="_blank">Delphi 2005 and Janeva 6.5</a></li>
<li>20040313 - <a href="http://blogs.embarcadero.com/abauer/" target="_blank">Allen Bauer</a> - <a href="http://blogs.embarcadero.com/abauer/2004/03/13/304" target="_blank">Revenge of the Automated IDE Incident reporting</a></li>
<li>20040217 &#8211; <a href="http://blogs.embarcadero.com/abauer/" target="_blank">Allen Bauer</a> &#8211; <a href="http://blogs.embarcadero.com/abauer/2004/02/17/296" target="_blank">Delphi 7 packages for using the Delphi 8 Win32 compiler</a></li>
<li>20031029 &#8211; <a href="http://blogs.embarcadero.com/abauer/" target="_blank">Allen Bauer</a> &#8211; <a href="http://blogs.embarcadero.com/abauer/2003/10/29/275" target="_blank">Editor pair highlighting</a></li>
</ul>
<p>Have fun with them!</p>
<p>&#8211;jeroen</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wiert.wordpress.com/914/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wiert.wordpress.com/914/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wiert.wordpress.com/914/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wiert.wordpress.com/914/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wiert.wordpress.com/914/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wiert.wordpress.com/914/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wiert.wordpress.com/914/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wiert.wordpress.com/914/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wiert.wordpress.com/914/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wiert.wordpress.com/914/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wiert.wordpress.com&blog=7443331&post=914&subd=wiert&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://wiert.wordpress.com/2009/10/15/delphi-list-of-posts-about-hidden-registry-entries/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11dc84116344a9ac90d0c2d01c1d4297?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jpluimers</media:title>
		</media:content>
	</item>
		<item>
		<title>Delphi &#8211; finding the VERxxx define for a particular Delphi version</title>
		<link>http://wiert.wordpress.com/2009/10/15/delphi-finding-the-verxxx-define-for-a-particular-delphi-version/</link>
		<comments>http://wiert.wordpress.com/2009/10/15/delphi-finding-the-verxxx-define-for-a-particular-delphi-version/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 15:25:56 +0000</pubDate>
		<dc:creator>jpluimers</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://wiert.wordpress.com/?p=912</guid>
		<description><![CDATA[Finding the correct VERxxx conditional define for a particular Delphi version is asked by a lot of people.
Even the first link in the above search, does not contain the full list!
But: JCL comes to the rescue
The JCL file JEDI.INC usually (read: like 99.999% of the time) is up to that  with that information soon.
Currently, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wiert.wordpress.com&blog=7443331&post=912&subd=wiert&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Finding the correct <a href="http://www.google.de/search?q=delphi+verxxx" target="_blank">VERxxx</a> conditional define for a particular Delphi version is <a href="http://melander.dk/delphi/dragdrop/" target="_blank">asked</a> <a href="https://forums.codegear.com/message.jspa?messageID=78071" target="_blank">by</a> <a href="http://www.wpcubed.com/forum/viewtopic.php?p=14079&amp;sid=93d6c0ca7164a054363e78a3d34ebf9e" target="_blank">a</a> <a href="https://forums.embarcadero.com/thread.jspa?messageID=54812" target="_blank">lot</a> <a href="http://stackoverflow.com/questions/1103706/how-to-detect-specific-delphi-builds" target="_blank">of</a> <a href="http://stackoverflow.com/questions/1369191/what-is-the-compiler-version-for-delphi-2010" target="_blank">people</a>.</p>
<p>Even the first link in the above search, does not contain the full list!<br />
But: <a href="http://jcl.delphi-jedi.org/" target="_blank">JCL</a> comes to the rescue</p>
<p>The JCL file JEDI.INC usually (read: like 99.999% of the time) is up to that  with that information soon.<br />
Currently, it contains all the defines starting with Delphi 1, up to Delphi 2010.</p>
<p>You can always browse the to JEDI.INC with this <a href="http://jcl.svn.sourceforge.net/viewvc/jcl/trunk/jcl/source/include/jedi.inc?view=markup" target="_blank">link to the sourceforge trunk</a>.</p>
<p>In fact that file contains a lot more useful defines.<br />
Actually, having the JCL and/or JVCL at hand is a very good practice: it is filled with high quality code that solves a lot of everyday problems.</p>
<p>Note:</p>
<blockquote><p><em><a href="http://www.deltics.co.nz/blog/?p=371" target="_blank">VER190</a> (by some people <a href="http://www.experts-exchange.com/Programming/Editors_IDEs/Delphi/Q_24023925.html" target="_blank">attributed to the wrong Delphi version</a>) is only used by Delphi 2007 for .NET (Delphi 2007 for Win32 used VER185 by itself and shares VER180 with Delphi 2006 for Win32).</em></p>
<p><em>The number 13 (in between <a href="http://community.devexpress.com/forums/t/77985.aspx" target="_blank">Delphi 2009 aka Delphi 12</a>, and <a href="http://community.devexpress.com/forums/t/80031.aspx" target="_blank">Delphi 2010 aka Delphi 14</a>) was </em><em><a href="http://en.wikipedia.org/wiki/CodeGear_Delphi" target="_blank">never used as a Delphi version number</a><br />
Since Delphi is mainly developed in the USA, and since a lot people there have <a href="http://en.wikipedia.org/wiki/Triskaidekaphobia" target="_blank">Triskaidekaphobia</a>, they showed mercy to those and <a href="http://blogs.embarcadero.com/abauer/2009/09/04/38900" target="_blank">skipped Delphi 13</a>.</em></p></blockquote>
<p>&#8211;jeroen</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wiert.wordpress.com/912/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wiert.wordpress.com/912/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wiert.wordpress.com/912/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wiert.wordpress.com/912/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wiert.wordpress.com/912/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wiert.wordpress.com/912/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wiert.wordpress.com/912/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wiert.wordpress.com/912/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wiert.wordpress.com/912/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wiert.wordpress.com/912/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wiert.wordpress.com&blog=7443331&post=912&subd=wiert&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://wiert.wordpress.com/2009/10/15/delphi-finding-the-verxxx-define-for-a-particular-delphi-version/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11dc84116344a9ac90d0c2d01c1d4297?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jpluimers</media:title>
		</media:content>
	</item>
		<item>
		<title>Delphi &#8211; hardcore debugging the intialization of your app, dlls and packages</title>
		<link>http://wiert.wordpress.com/2009/10/15/delphi-hardcore-debugging-the-intialization-of-your-app-dlls-and-packages/</link>
		<comments>http://wiert.wordpress.com/2009/10/15/delphi-hardcore-debugging-the-intialization-of-your-app-dlls-and-packages/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 11:35:40 +0000</pubDate>
		<dc:creator>jpluimers</dc:creator>
				<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://wiert.wordpress.com/?p=899</guid>
		<description><![CDATA[Recently we got involved with a client having a large and complex application that (historically) consists of

A main .EXE that loads
Many DLLs
Underlying BPLs

One of the biggest problems is debugging the startup sequence.
Somehow, when the Delphi IDE loads DLLs in the initialization sequences of units, it looses its ability symbol tables.
This article describes a few tips [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wiert.wordpress.com&blog=7443331&post=899&subd=wiert&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Recently we got involved with a client having a large and complex application that (historically) consists of</p>
<ol>
<li>A main .<a href="http://en.wikipedia.org/wiki/EXE" target="_blank">EXE</a> that loads</li>
<li>Many <a href="http://en.wikipedia.org/wiki/Dynamic-link_library" target="_blank">DLL</a>s</li>
<li>Underlying <a href="http://delphi.about.com/od/objectpascalide/a/bpl_vs_dll.htm" target="_blank">BPL</a>s</li>
</ol>
<p>One of the biggest problems is debugging the startup sequence.<br />
Somehow, when the <a href="http://edn.embarcadero.com/article/34323" target="_blank">Delphi IDE</a> loads DLLs in the initialization sequences of units, it looses its ability symbol tables.</p>
<p>This article describes a few tips on how to debug those, especially where to put <a href="http://en.wikipedia.org/wiki/Breakpoint" target="_blank">breakpoints</a>.<br />
<span id="more-899"></span><br />
Yes, we have done the obvious things like:</p>
<ul>
<li>the EXE, DLLs and BPLs were already <a href="http://stackoverflow.com/questions/1326888/delphi-debugger-showing-for-currency-variables" target="_blank">in the same directory</a></li>
<li>that directory is referenced in the IDE <a href="http://blogs.embarcadero.com/chrishesik/2009/09/22/34916" target="_blank">Debug symbol search path</a> for loading the symbols</li>
<li>turned on all sorts of debug information (Turbo Debugger inside EXE/DLL/BPL, <a href="http://delphi.wikia.com/wiki/Delphi_File_Extensions" target="_self">RSM files</a>, <a href="http://en.wikipedia.org/wiki/MAP_(file_format)" target="_blank">MAP files</a>)</li>
<li>turned off Optimization and turned on Stack frames</li>
<li>and studied a lot of <a href="http://www.gexperts.org/opentools/" target="_blank">FAQs</a> and <a href="http://entwickler-forum.de/archive/index.php/t-24727.html" target="_blank">tips</a> from other people</li>
</ul>
<p>In the end, it appears that when DLL&#8217;s with symbols get loaded during unit initialization sections, the Delphi IDE (in this case 2007) loses the Symbol Tables either for the EXE or for the DLL (or both).</p>
<p>In order to work around this:</p>
<ul>
<li>We had to know which DLLs were loaded and when</li>
<li>We rewrote all the DLLs to be &#8216;demand/<a href="http://msdn.microsoft.com/en-us/library/151kt790.aspx" target="_blank">delay loaded</a>&#8216; (i.e. not statically linked, see code sample below)</li>
<li>We rewrote all the stuff that referenced the DLLs to initialize on demand as well</li>
</ul>
<p>Here are some tips for setting breakpoints to debug the startup sequence, including some links to relevant documentation, samples or articles:</p>
<ol>
<li>Unit <a href="http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/System.html" target="_blank">System</a>; procedure InitUnits; line &#8220;TProc(P)();&#8221;<br />
(this line gets called often: for each unit that is being initialized, either because the unit has an initialization section, or it has initialized consts; see <a href="http://www.devexpress.com/Support/Center/p/CB56365.aspx" target="_blank">an example call stack</a>) .</li>
<li>Unit <a href="http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/SysUtils1.html" target="_blank">SysUtils</a>; procedure <a href="http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/SysUtils_SafeLoadLibrary.html" target="_blank">SafeLoadLibrary</a>;<br />
(we call this for every DLL that gets loaded; this method saves and restores the FPU control word, especially handy for 3rd party DLLs that think they own the FPU).</li>
<li>unit System; procedure _InitLib; line &#8220;MOV     EDX,offset Module&#8221;<br />
(this gets called in a DLL when Windows is loading it with LoadLibrary)</li>
<li>unit SysInit; procedure <a href="http://www.mustangpeak.net/hooks_fix.htm" target="_blank">InitProcessTLS</a>;<br />
(inside a DLL this reserves the Thread Local Storage to be used by this DLL; it usually is the first thing called in a DLL)</li>
<li>unit System; procedure ExitDll; line &#8220;RET     12&#8243; (assembler)<br />
(this gets called in a DLL when Windows is almost finished processing the LoadLibrary for it)</li>
<li>DLL kernel32.LoadLibraryA and DLL kernel32.LoadLibraryW, CPU code &#8220;cmp dword ptr [ebp+$08],$00&#8243;, then in the data portion of the CPU viewer, go to the address &#8220;ebp+$08&#8243; , then press Ctrl-D to follow &#8220;long data&#8221;; now you see the module that is going to be loaded<br />
(this gets called by Windows when loading DLLs)</li>
<li><a href="http://www.microsoft.com/mspress/books/sampchap/4354a.aspx" target="_blank">ntdll.LdrInitializeThunk</a>, CPU code &#8220;call dword ptr[ebp+$08]&#8220;<br />
(this gets called by Windows just before loading the DLL)</li>
</ol>
<p>For the demand loading, we used this small unit:</p>
<pre class="brush: delphi;">
unit BLibrary;

interface

uses
  SysUtils, Windows;

const
  NoLibraryHandle = 0;

type
  ELibrary = class(Exception);
  TLibraryRecord = record
    Name: string;
    Handle: HModule;
  end;

  /// See also this method in the ComObj unit:
  /// procedure RegisterComServer(const DLLName: string);
function LoadLibrary(var LibraryRecord: TLibraryRecord): Boolean; overload;

procedure FreeLibrary(var LibraryRecord: TLibraryRecord); overload;

function GetProcAddress(var LibraryRecord: TLibraryRecord; const ProcName: string): FARPROC; overload;

implementation

function IsInvalidModuleHandle(const Handle: HModule): Boolean;
begin
  Result := (Handle &lt;= HINSTANCE_ERROR);
end;

function SysErrorMessageLastError(): string;
begin
  Result := SysErrorMessage(GetLastError);
end;

function LoadLibrary(var LibraryRecord: TLibraryRecord): Boolean;
begin
  Result := False;
  if IsInvalidModuleHandle(LibraryRecord.Handle) then
  begin
    LibraryRecord.Handle := SafeLoadLibrary(LibraryRecord.Name);
    if IsInvalidModuleHandle(LibraryRecord.Handle) then
      raise ELibrary.CreateFmt('DLL &quot;%s&quot; nicht geladen wegen: &quot;%s&quot;',
        [LibraryRecord.Name, SysErrorMessageLastError]);
    Result := True;
  end;
end;

procedure FreeLibrary(var LibraryRecord: TLibraryRecord);
var
  Success: Boolean;
begin
  if not IsInvalidModuleHandle(LibraryRecord.Handle) then
  begin
    Success := Windows.FreeLibrary(LibraryRecord.Handle);
    if not Success then
      raise ELibrary.CreateFmt('DLL &quot;%s&quot; entladen fehler: &quot;%s&quot;',
        [LibraryRecord.Name, SysErrorMessageLastError]);
    LibraryRecord.Handle := NoLibraryHandle;
  end
end;

function GetProcAddress(var LibraryRecord: TLibraryRecord; const ProcName: string): FARPROC;
begin
  LoadLibrary(LibraryRecord);
  Result := Windows.GetProcAddress(LibraryRecord.Handle, PChar(ProcName));
  if Result = nil then
    raise ELibrary.CreateFmt('DLL &quot;%s&quot; fehler beim laden von ohne Eintrittspunkt &quot;%s&quot;: &quot;%s&quot;',
      [LibraryRecord.Name, ProcName, SysErrorMessageLastError]);
end;

end.
</pre>
<p>This article is work-in-progress, so you will see updates in the next coming days.</p>
<p>&#8211;jeroen</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wiert.wordpress.com/899/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wiert.wordpress.com/899/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wiert.wordpress.com/899/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wiert.wordpress.com/899/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wiert.wordpress.com/899/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wiert.wordpress.com/899/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wiert.wordpress.com/899/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wiert.wordpress.com/899/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wiert.wordpress.com/899/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wiert.wordpress.com/899/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wiert.wordpress.com&blog=7443331&post=899&subd=wiert&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://wiert.wordpress.com/2009/10/15/delphi-hardcore-debugging-the-intialization-of-your-app-dlls-and-packages/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11dc84116344a9ac90d0c2d01c1d4297?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jpluimers</media:title>
		</media:content>
	</item>
		<item>
		<title>Te Waka o Delphi · Absolute for Beginners</title>
		<link>http://wiert.wordpress.com/2009/10/15/te-waka-o-delphi-%c2%b7-absolute-for-beginners/</link>
		<comments>http://wiert.wordpress.com/2009/10/15/te-waka-o-delphi-%c2%b7-absolute-for-beginners/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 09:08:30 +0000</pubDate>
		<dc:creator>jpluimers</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://wiert.wordpress.com/?p=897</guid>
		<description><![CDATA[Jolyon Smith just published a great article about using the absolute keyword in Delphi.
When used with care (just like the with or goto keywords), absolute can make your code much easier to maintain.
Recommended reading!
&#8211;jeroen
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wiert.wordpress.com&blog=7443331&post=897&subd=wiert&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://www.deltics.co.nz/blog/?author=2" target="_blank">Jolyon Smith</a> just published a <a href="http://www.deltics.co.nz/blog/?p=586" target="_blank">great article about using the absolute</a> keyword in Delphi.</p>
<p>When used with care (just like the <a href="http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/declarationsandstatements_xml.html" target="_blank">with or goto</a> keywords), <a href="http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/cm_var_expected_xml.html" target="_blank">absolute</a> can make your code much easier to maintain.</p>
<p>Recommended reading!</p>
<p>&#8211;jeroen</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wiert.wordpress.com/897/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wiert.wordpress.com/897/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wiert.wordpress.com/897/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wiert.wordpress.com/897/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wiert.wordpress.com/897/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wiert.wordpress.com/897/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wiert.wordpress.com/897/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wiert.wordpress.com/897/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wiert.wordpress.com/897/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wiert.wordpress.com/897/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wiert.wordpress.com&blog=7443331&post=897&subd=wiert&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://wiert.wordpress.com/2009/10/15/te-waka-o-delphi-%c2%b7-absolute-for-beginners/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11dc84116344a9ac90d0c2d01c1d4297?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jpluimers</media:title>
		</media:content>
	</item>
		<item>
		<title>Ancient history &#8211; found back one of my earliest email messages dated in februari 1989!</title>
		<link>http://wiert.wordpress.com/2009/10/12/ancient-history-found-back-one-of-my-earliest-email-messages-dated-in-februari-1989/</link>
		<comments>http://wiert.wordpress.com/2009/10/12/ancient-history-found-back-one-of-my-earliest-email-messages-dated-in-februari-1989/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 14:21:39 +0000</pubDate>
		<dc:creator>jpluimers</dc:creator>
				<category><![CDATA[About]]></category>
		<category><![CDATA[History]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://wiert.wordpress.com/?p=892</guid>
		<description><![CDATA[I found back one of my earliest mail messages: it is dated back in februari 1989.
Wow &#8211; ain&#8217;t search engines nice!
Today, messages like those seem totally irrelevant.
But back then, getting in touch with other people through email could be a real challenge.
The internet was forming (out of UUNET, DECnet, BITNET, Usenet, EARN, ARPANET and others), [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wiert.wordpress.com&blog=7443331&post=892&subd=wiert&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I found back one of <a href="http://groups.google.nl/group/comp.sys.ibm.pc.digest/browse_thread/thread/d0b700d83e3b413a/e7540e6c018357ae" target="_blank">my earliest mail messages</a>: it is dated back in februari 1989.</p>
<p>Wow &#8211; ain&#8217;t search engines nice!</p>
<p>Today, messages like those seem totally irrelevant.</p>
<p>But back then, getting in touch with other people through email could be a real challenge.</p>
<p>The internet was forming (out of <a href="http://en.wikipedia.org/wiki/Uunet" target="_blank">UUNET</a>, <a href="http://en.wikipedia.org/wiki/Decnet" target="_blank">DECnet</a>, <a href="http://en.wikipedia.org/wiki/BITNET" target="_blank">BITNET</a>, <a href="http://en.wikipedia.org/wiki/Usenet" target="_blank">Usenet</a>, <a href="http://en.wikipedia.org/wiki/European_Academic_Research_Network" target="_blank">EARN</a>, <a href="http://en.wikipedia.org/wiki/ARPANET" target="_blank">ARPANET</a> and others), and not everything was completely interconnected yet, let alone connected on-line 24/7.<br />
For instance, newsgroups were limited to the usenet portion of the internet, and not available on the bitnet portion.</p>
<p>So, mail and mailing lists were the prevalent means of communication: <a href="http://en.wikipedia.org/wiki/LISTSERV" target="_blank">LISTSERV</a> was the first program facilitating mailing lists.</p>
<p>Routing mail could be a challenge as well.<br />
There was not yet such a widespread thing as <a href="http://en.wikipedia.org/wiki/Smtp" target="_blank">SMTP</a> or <a href="http://en.wikipedia.org/wiki/Pop3" target="_blank">POP3</a> as it is today.<br />
So mail got <a href="http://www.faqs.org/rfcs/rfc1711.html" target="_blank">relayed</a> (in fact <a href="http://en.wikipedia.org/wiki/Open_mail_relay" target="_blank">open mail relays</a> were the standard configuration), and often you had to provide the routing instructions in your mail as well.</p>
<p>Hence the complicated mail addresses used in the message linked above.</p>
<p>Back then, on the for <a href="http://www.c-ad.bnl.gov/esfd/ES&amp;F%20Tech%20Notes/125.pdf" target="_blank">sending mail on the on the VAX/VMS</a> I was working on, gMail (note the spelling) was a very good mail program that would magically do most of the routing for you.</p>
<p>BITNIC used to be a repository to download <a href="http://textfiles.com/internet/bitnic" target="_blank">information and programs</a>.</p>
<p><a href="http://en.wikipedia.org/wiki/Uuencoding" target="_blank">UUENCODE</a> one of the early encoding schemes to send binaries over email (and still one of Microsoft&#8217;s email programs barfs when you put &#8216;begin 664&#8242; at the beginning of a line).</p>
<p><a href="http://en.wikipedia.org/wiki/Bitnet_Relay" target="_blank">BITNET Relay</a> was one of the earliest chat programs (much like <a href="http://en.wikipedia.org/wiki/Internet_Relay_Chat" target="_blank">IRC</a> now), and HEARN the mean node in The Netherlands.</p>
<p>History is fun!</p>
<p>&#8211;jeroen</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wiert.wordpress.com/892/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wiert.wordpress.com/892/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wiert.wordpress.com/892/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wiert.wordpress.com/892/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wiert.wordpress.com/892/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wiert.wordpress.com/892/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wiert.wordpress.com/892/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wiert.wordpress.com/892/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wiert.wordpress.com/892/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wiert.wordpress.com/892/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wiert.wordpress.com&blog=7443331&post=892&subd=wiert&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://wiert.wordpress.com/2009/10/12/ancient-history-found-back-one-of-my-earliest-email-messages-dated-in-februari-1989/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11dc84116344a9ac90d0c2d01c1d4297?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jpluimers</media:title>
		</media:content>
	</item>
		<item>
		<title>C# / .NET &#8211; setting or clearing the Password Never Expires flag for a user</title>
		<link>http://wiert.wordpress.com/2009/10/11/c-net-setting-or-clearing-the-password-never-expires-flag-for-a-user/</link>
		<comments>http://wiert.wordpress.com/2009/10/11/c-net-setting-or-clearing-the-password-never-expires-flag-for-a-user/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 22:37:22 +0000</pubDate>
		<dc:creator>jpluimers</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C# 2.0]]></category>
		<category><![CDATA[CommandLine]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[XP-embedded]]></category>

		<guid isPermaLink="false">http://wiert.wordpress.com/?p=886</guid>
		<description><![CDATA[Recently, I had to change the &#8220;Password Never Expires&#8221; flag for some users on Windows systems.
In the past, there used to be a netuser tool available from WindowsITPro where you could use the pwnexp flag to set or clear that flag.
That tool seems to be vanished, so I was searching for alternatives.
Most alternatives I found [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wiert.wordpress.com&blog=7443331&post=886&subd=wiert&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Recently, I had to change the &#8220;Password Never Expires&#8221; flag for some users on Windows systems.</p>
<p>In the past, there used to be a <a href="http://windowsitpro.com/article/articleid/71895/jsi-tip-0570---freeware-command-line--batch-account-rename.html" target="_blank">netuser tool available from WindowsITPro</a> where you could use the pwnexp flag to set or clear that flag.<br />
That tool seems to be vanished, so I was searching for alternatives.</p>
<p>Most <a href="http://www.servernewsgroups.net/scripting/t505-reset-local-account-properties.aspx" target="_blank">alternatives</a> I found depend on <a href="http://www.ureader.com/message/1168589.aspx" target="_blank">some  kind of scripting</a>, or the <a href="http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/XP/Q_23863118.html" target="_blank">use of the WMIC</a> WMI command line interface: that was &#8220;out&#8221; because this particular setup is running on <a href="http://en.wikipedia.org/wiki/Windows_XP_Embedded#Windows_XP_Embedded" target="_blank">Windows XP Embedded</a>, which is trimmed down very much.<br />
The only <a href="http://www.codeproject.com/KB/system/OSUserMangement.aspx" target="_blank">C# example I found was on CodeProject</a>, but it does</p>
<ul>
<li>not take into account the existing flags correctly,</li>
<li>have  hard coded literals without any references where they are from,</li>
<li>use bit flag arithmetic without letting the C# compiler do its magic with enums,</li>
<li>use a call to the deprecated  <a href="http://msdn.microsoft.com/en-us/library/system.directoryservices.directoryentry.invokeget.aspx" target="_blank">InvokeGet method</a>,</li>
<li>use the <a href="http://msdn.microsoft.com/en-us/library/system.directoryservices.directoryentry.invoke.aspx" target="_blank">Invoke(&#8220;Put&#8221;, &#8230; way of calling</a> that <a href="http://www.dotnet247.com/247reference/msgs/44/223276.aspx" target="_blank">so</a> <a href="http://stackoverflow.com/questions/1341786/work-with-directoryentry-not-on-a-domain-set-user-password-never-expire" target="_blank">many</a> <a href="http://forums.devx.com/showthread.php?t=98179" target="_blank">people</a> <a href="http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/ASP/Q_22921387.html" target="_blank">use</a> (which actually should have been an &#8211; also deprecated &#8211; <a href="http://msdn.microsoft.com/en-us/library/system.directoryservices.directoryentry.invokeset.aspx" target="_blank">InvokeSet method</a>),</li>
<li>use COM Interop</li>
</ul>
<p>Hence the solution below:<br />
C#, with the proper <a href="http://msdn.microsoft.com/en-us/library/aa772300(VS.85).aspx" target="_blank">ADS_USER_FLAG_ENUM enum from the MSDN documentation</a> and no COM Interop, it also moves all literals to constants.</p>
<p><span id="more-886"></span>This example does not use any Interop, but it</p>
<ul>
<li>requires the System.DirectoryServices.dll assembly (which ships with .NET 2.0 and up),</li>
<li>uses the <a href="http://msdn.microsoft.com/en-us/library/system.directoryservices.aspx" target="_blank">System.DirectoryServices namespace</a>,</li>
<li>and from there the <a href="http://msdn.microsoft.com/en-us/library/system.directoryservices.directoryentry.aspx" target="_blank">DirectoryEntry class</a> with the <a href="http://msdn.microsoft.com/en-us/library/system.directoryservices.directoryentry.properties.aspx" target="_blank">Properties property</a></li>
</ul>
<p>With those, it becomes more readable, easier to debug and therefore a lot more maintainable.</p>
<p>Note that <a href="http://msdn.microsoft.com/en-us/library/ms256748.aspx" target="_blank">this code needs full trust security</a>.<br />
In my case that is not a problem, as this code executes while building the Windows XP Embedded image.</p>
<pre class="brush: csharp;">
        // see http://msdn.microsoft.com/en-us/library/aa772300(VS.85).aspx
        [Flags]
        enum ADS_USER_FLAG_ENUM
        {
            ADS_UF_SCRIPT = 1,         // 0x1
            ADS_UF_ACCOUNTDISABLE = 2,         // 0x2
            ADS_UF_HOMEDIR_REQUIRED = 8,         // 0x8
            ADS_UF_LOCKOUT = 16,        // 0x10
            ADS_UF_PASSWD_NOTREQD = 32,        // 0x20
            ADS_UF_PASSWD_CANT_CHANGE = 64,        // 0x40
            ADS_UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED = 128,       // 0x80
            ADS_UF_TEMP_DUPLICATE_ACCOUNT = 256,       // 0x100
            ADS_UF_NORMAL_ACCOUNT = 512,       // 0x200
            ADS_UF_INTERDOMAIN_TRUST_ACCOUNT = 2048,      // 0x800
            ADS_UF_WORKSTATION_TRUST_ACCOUNT = 4096,      // 0x1000
            ADS_UF_SERVER_TRUST_ACCOUNT = 8192,      // 0x2000
            ADS_UF_DONT_EXPIRE_PASSWD = 65536,     // 0x10000
            ADS_UF_MNS_LOGON_ACCOUNT = 131072,    // 0x20000
            ADS_UF_SMARTCARD_REQUIRED = 262144,    // 0x40000
            ADS_UF_TRUSTED_FOR_DELEGATION = 524288,    // 0x80000
            ADS_UF_NOT_DELEGATED = 1048576,   // 0x100000
            ADS_UF_USE_DES_KEY_ONLY = 2097152,   // 0x200000
            ADS_UF_DONT_REQUIRE_PREAUTH = 4194304,   // 0x400000
            ADS_UF_PASSWORD_EXPIRED = 8388608,   // 0x800000
            ADS_UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION = 16777216   // 0x1000000
        } ;

        /// &lt;summary&gt;
        /// Sets or clears the &quot;Password Never Expires&quot; flag for a user on the current system.
        /// This is based on ideas in http://www.codeproject.com/KB/system/OSUserMangement.aspx,
        /// but not that the code there is wrong: it does not take into account the current userFlags value
        /// The code below does take that into account and is much more maintainable.
        ///
        /// the logic can be made a bit easier by applying sets
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;userName&quot;&gt;name of the user to set the Password Never Expires flag&lt;/param&gt;
        /// &lt;param name=&quot;passwordNeverExpires&quot;&gt;new flag value&lt;/param&gt;
        protected virtual void setPasswordNeverExpires(string userName, bool passwordNeverExpires)
        {
            const string userNameString = &quot;userName&quot;;
            const string userFlagsString = &quot;userFlags&quot;;

            string machineName = Environment.MachineName;

            DirectoryEntry userInThisComputerDirectoryEntry = getUserInThisComputerDirectoryEntry(machineName, userName);
            if (null == userInThisComputerDirectoryEntry)
                throw new ArgumentException(&quot;not found in &quot; + machineName, userNameString);

            PropertyValueCollection userFlagsProperties = userInThisComputerDirectoryEntry.Properties[userFlagsString];

            ADS_USER_FLAG_ENUM userFlags = (ADS_USER_FLAG_ENUM)(userFlagsProperties.Value);
            ADS_USER_FLAG_ENUM newUserFlags = userFlags;

            if (passwordNeverExpires)
                newUserFlags = newUserFlags | ADS_USER_FLAG_ENUM.ADS_UF_DONT_EXPIRE_PASSWD;
            else
                newUserFlags = newUserFlags &amp; (~ADS_USER_FLAG_ENUM.ADS_UF_DONT_EXPIRE_PASSWD);

            userFlagsProperties.Value = newUserFlags;

            userInThisComputerDirectoryEntry.CommitChanges();
        }

        protected virtual DirectoryEntry getUserInThisComputerDirectoryEntry(string machineName, string userName)
        {
            DirectoryEntry computerDirectoryEntry = getComputerDirectoryEntry(machineName);

            const string userSchemaClassName = &quot;user&quot;;
            return computerDirectoryEntry.Children.Find(userName, userSchemaClassName);
        }

        protected virtual DirectoryEntry getComputerDirectoryEntry(string machineName)
        {
            //Initiate DirectoryEntry Class To Connect Through WINNT Protocol
            // see: http://msdn.microsoft.com/en-us/library/system.directoryservices.directoryentry.path.aspx
            const string pathUsingWinNTComputerMask = &quot;WinNT://{0},computer&quot;;
            string path = string.Format(pathUsingWinNTComputerMask, machineName);
            DirectoryEntry thisComputerDirectoryEntry = new DirectoryEntry(path);
            return thisComputerDirectoryEntry;
        }
</pre>
<p>This code is just an example on how you can do it in a maintainable way.<br />
It can easily be extended to other properties as well.</p>
<p>&#8211;jeroen</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wiert.wordpress.com/886/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wiert.wordpress.com/886/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wiert.wordpress.com/886/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wiert.wordpress.com/886/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wiert.wordpress.com/886/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wiert.wordpress.com/886/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wiert.wordpress.com/886/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wiert.wordpress.com/886/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wiert.wordpress.com/886/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wiert.wordpress.com/886/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wiert.wordpress.com&blog=7443331&post=886&subd=wiert&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://wiert.wordpress.com/2009/10/11/c-net-setting-or-clearing-the-password-never-expires-flag-for-a-user/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11dc84116344a9ac90d0c2d01c1d4297?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jpluimers</media:title>
		</media:content>
	</item>
	</channel>
</rss>