<?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>Fredrik Haglund's blog &#187; Delphi</title>
	<atom:link href="http://blog.fredrikhaglund.se/blog/tag/delphi/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.fredrikhaglund.se</link>
	<description>Chatter about EPiServer, ASP.NET, CSS and Web Development.</description>
	<lastBuildDate>Tue, 28 Jun 2011 13:37:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Migrate an old Kylix project to Delphi 2007</title>
		<link>http://blog.fredrikhaglund.se/blog/2007/09/06/migrate-an-old-kylix-project-to-delphi-2007/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2007/09/06/migrate-an-old-kylix-project-to-delphi-2007/#comments</comments>
		<pubDate>Thu, 06 Sep 2007 10:44:27 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=37</guid>
		<description><![CDATA[I got a question today how to migrate an old Kylix project to Delphi 2007 and here is what I answered. None of our current products support the CLX-framework any more for legal reasons (CodeGear does not have a license from Trolltech on Qt library). It is possible to manually convert a Kylix project to [...]]]></description>
			<content:encoded><![CDATA[<p>I got a question today how to migrate an old Kylix project to Delphi 2007 and here is what I answered.</p>
<p>None of our current products support the CLX-framework any more for legal reasons (CodeGear does not have a license from Trolltech on Qt library).</p>
<p>It is possible to manually convert a Kylix project to an ordinary Delphi project very easily, though.</p>
<p>Here is a simplified description of the approach:</p>
<ul>
<li>You need to rename the units in the uses clause in all pas-files. Usually you only need to remove the Q infront of the unit name.</li>
<li>For forms you need to change the extension of the xfm file to dfm. Change the $R directive in the pas-file to include the dfm file instead.</li>
<li>Properties should be 99% compatible with current version. Open each converted form in Delphi to verify this. If there is any problem, click ignore and make a note so you can investigate if it demands any adjustments.</li>
</ul>
<p>If you have more tips and trix, drop a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2007/09/06/migrate-an-old-kylix-project-to-delphi-2007/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Vista Enable Your Applications</title>
		<link>http://blog.fredrikhaglund.se/blog/2007/07/18/vista-enable-your-applications/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2007/07/18/vista-enable-your-applications/#comments</comments>
		<pubDate>Wed, 18 Jul 2007 17:03:10 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[UAC]]></category>
		<category><![CDATA[User Account Control]]></category>
		<category><![CDATA[Vista, UAC]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=26</guid>
		<description><![CDATA[You can watch the recording of my session &#8220;Vista Enable Your Applications&#8221; during the CodeGear European Web Seminar Developer Days. I have also uploaded the slides on code central.]]></description>
			<content:encoded><![CDATA[<p>You can watch the recording of my session &#8220;<a href="http://cc.codegear.com/item/24730">Vista Enable Your Applications</a>&#8221; during the <a href="http://dn.codegear.com/article/36708">CodeGear European Web Seminar Developer Days</a>. I have also uploaded the <a href="http://cc.codegear.com/item/24730">slides on code central</a>.</p>
<p><img width="1" src="http://blogs.codegear.com/fhaglund/aggbug/37553.aspx" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2007/07/18/vista-enable-your-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UAC and Signed Applications</title>
		<link>http://blog.fredrikhaglund.se/blog/2007/06/08/uac-and-signed-applications/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2007/06/08/uac-and-signed-applications/#comments</comments>
		<pubDate>Fri, 08 Jun 2007 15:03:45 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[UAC]]></category>
		<category><![CDATA[User Account Control]]></category>
		<category><![CDATA[Vista, UAC]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=25</guid>
		<description><![CDATA[I talked about User Account Control in Windows Vista at the Developer Day in Gothenburg yesterday. One of the topics was about signing you application so a user knows who published it. In earlier windows versions this is something that the user see when he download an application like an installer but in Windows Vista [...]]]></description>
			<content:encoded><![CDATA[<p>I talked about User Account Control in Windows Vista at the Developer Day in Gothenburg yesterday.</p>
<p>One of the topics was about signing you application so a user knows who published it. In earlier windows versions this is something that the user see when he download an application like an installer but in Windows Vista publisher is also showed in the consent dialog every time you start an application elevated (running as administrator).</p>
<p>And there is also one more difference &#8211; if you elevate an unsigned application User Account Control shows a big orange dialog with a lot of threatening text. If it is signed UAC will use a smaller, less threatening dialog similar to the one you see when you elevate applications signed by Microsoft.</p>
<p>Signing your application is also an requirement to get your application Vista Logo compliant.</p>
<p>So how do you get you application signed then? Well, the descriptions you find when you search is really scary.</p>
<p>&#8220;If the programmer uses a Borland product, for example Delphi, the developer has to find those 3 files on the Microsoft web site. Microsoft has removed the file codesigningx86.exe from their web site which contained the 3 files. Now the developer is required to download 19 different files, perform a cab extraction of nearly a GB of files, and install an SDK just to get those 3 files.&#8221;</p>
<p>But I found an exelent small tool that solves the whole process in a minute from <a href="http://www.x2net.com">x2net</a>. It comes with a demo cert to make it easy to test. (If you want the demo cert to work with UAC dialog on Windows Vista you must manually install the demo root certificate into the local machines certificate store)</p>
<p><img width="1" src="http://blogs.codegear.com/fhaglund/aggbug/35729.aspx" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2007/06/08/uac-and-signed-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More about BDE</title>
		<link>http://blog.fredrikhaglund.se/blog/2007/05/12/more-about-bde/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2007/05/12/more-about-bde/#comments</comments>
		<pubDate>Sat, 12 May 2007 17:41:06 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[BDE]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[UAC]]></category>
		<category><![CDATA[User Account Control]]></category>
		<category><![CDATA[Vista, UAC]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=24</guid>
		<description><![CDATA[I got some more questions yesterday after bloging about how to get you application using Paradox or dBase tables to function under Windows Vista yesterday. The first one is how do you add BDE to you installation project? That is easy. Just download the BDE Merge Module and add the MSM-file to you Setup-project. I [...]]]></description>
			<content:encoded><![CDATA[<p>I got some more questions yesterday after bloging about how to <a href="http://blog.fredrikhaglund.se/2007/05/09/small-questions/">get you application using Paradox or dBase tables to function under Windows Vista</a> yesterday.</p>
<p>The first one is how do you add BDE to you installation project? That is easy. Just download the <a href="http://www.codegear.com/downloads/regusers/delphi">BDE Merge Module</a> and add the MSM-file to you Setup-project.</p>
<p>I read a <a href="http://forums.installaware.com/viewtopic.php?p=4773&amp;sid=676c752c20a29c61269887cb9dc999c9">forum post how this can be extended with InstallAware pre-requisites mechanism</a> so the file-set is only downloaded and installed if needed.</p>
<p><img width="1" src="http://blogs.codegear.com/fhaglund/aggbug/34489.aspx" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2007/05/12/more-about-bde/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Small questions</title>
		<link>http://blog.fredrikhaglund.se/blog/2007/05/09/small-questions/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2007/05/09/small-questions/#comments</comments>
		<pubDate>Wed, 09 May 2007 17:59:40 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[BDE]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[UAC]]></category>
		<category><![CDATA[User Account Control]]></category>
		<category><![CDATA[Vista, UAC]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=23</guid>
		<description><![CDATA[I get a constant stream of small questions about Delphi in my inbox. Some are easy to answer and usually just send a quick response others are more complicated. But why not share some of those answers with all of you? 1) How can I install an external ActiveX control (.OCX file) in Delphi? Click [...]]]></description>
			<content:encoded><![CDATA[<p>I get a constant stream of small questions about Delphi in my inbox. Some are easy to answer and usually just send a quick response others are more complicated. But why not share some of those answers with all of you?</p>
<p><strong>1) How can I install an external ActiveX control (.OCX file) in Delphi?</strong></p>
<ul>
<li>Click <em>File</em> &gt; <em>New </em>&gt; <em>Package – Delphi for Win32</em></li>
<li>Save the Package project.</li>
<li>Click <em>Component</em> &gt; <em>Import Component…</em></li>
<li>Select <em>Import ActiveX control.</em></li>
<li>Select ActiveX-control in list or click Add and browse the for file.</li>
<li>Fill in component details, like name and palette page.
<ul>
<li>Optionally set unit directory to same location as where you saved the package project.</li>
<li>Optionally check <em>Generate component wrappers</em>.</li>
</ul>
</li>
<li>Select <em>Add unit to Package</em> and <em>Finish</em>.</li>
<li>Right click on<br />
the Package in Project manager to <em>Build</em> and <em>Install </em>package.´</li>
</ul>
<p>Why should I change where the unit is saved? Personally I prefer to have the package and its source in a folder under version control rather than have it stored in Delphi&#8217;s local import folder. It makes it easier for the rest of the team.</p>
<p><strong>Turbo Delphi 2006 Professional users</strong><br />
Import Component and View&gt;Type Library is missing because of a defect. Here is a workaround:</p>
<ul>
<li>Create this directory: $(BDS)\include\atl\</li>
<li>Create an empty file named: ATLBASE.H</li>
</ul>
<p>Turbo Delphi Pro now has the Component/Import Component and View/Type Library menu choices.</p>
<p><strong>2) How do I get my application with Paradox tables to work on Windows Vista?</strong></p>
<p>This one is a little bit tricky. There are several pitfalls here.</p>
<p>First of all you need to install BDE with your applications installer as usual. If you are using a comercial installer or call you installation executable setup.exe, Vista will detect that it is an installer and suggest running it as administrator which is needed to write files in the Program Files folder and the local machine registry.</p>
<p>Secondly, do you add global BDE-aliases for you database? They are stored in idapi.cfg file under Program Files where a standard user does not have the rights needed to alter files. It will work if you do this from the installer since it is running as administrator but if you add aliases from your application there might be trouble ahead! Windows Vista has a nasty compatibility feature called Virtualization or Redirection that will silently create personal copies of files instead of giving you an access denied error. Consider the administrative nightmare when every user has their own copy of idapi.cfg hidden in a personal VirtualStore folder. You can easily turn all compatibility features off by checking <em>Enable runtime themes</em> in <em>Project</em> &gt; <em>Options</em> &gt; <em>Application</em> in Delphi 2007 (or by manually adding a manifest). Remember that should always run the BDE Admin tool and control panel applet as administrator since running them as Standard User also will create a copy of idapi.cfg in the personal VirtualStore.</p>
<p>My suggestion is that you use a <em>TDatabase</em> component in you application instead of using global aliases and create a private alias for you application by setting DatabaseName and use <em>DriverName</em> and <em>Params</em> property instead of <em>Alias</em> property.</p>
<p>Next problem is the location of the database. If you have put you Paradox or dBase files it in the Program Files folder you will trigger Virtualization and then you have parts of the database in each users VirtualStore! Try to mend that mess into one database again. You should follow the steps above to add a manifest to your executable and get access denied errors instead of this mess.</p>
<p>Use the <em>SHGetFolderPath</em> function to get a path to a better location where Standard Users have read and write access. You will find an example of this in the <em>File &gt; New Other…&gt; Win2000 Logo Application.</em> Consider using CSIDL_COMMON_APPDATA if it is a shared database. You can easily get you installer to put you database files here instead by using pre-defined constants (i.e. [CommonAppDataFolder] in InstallShield, $ALLAPPDATA$ in InstallAware).</p>
<p>For Paradox there is the problem with <em>NetFileDir</em>. The default value &#8220;C:\&#8221; will not work. To get around this, add a <em>TSession</em> component to your application and set <em>NetFileDir</em> using a value from the <em>SHGetFolderPath</em> function. Use CSIDL_COMMON_APPDATA.</p>
<p>Finally, consider upgrading your Paradox or dBase database to InterBase instead! <img src='http://blog.fredrikhaglund.se/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2007/05/09/small-questions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Vista User Account Control and Command Line Applications</title>
		<link>http://blog.fredrikhaglund.se/blog/2007/03/19/vista-user-account-control-and-command-line-applications/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2007/03/19/vista-user-account-control-and-command-line-applications/#comments</comments>
		<pubDate>Mon, 19 Mar 2007 01:57:27 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[UAC]]></category>
		<category><![CDATA[User Account Control]]></category>
		<category><![CDATA[Vista, UAC]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=22</guid>
		<description><![CDATA[The last weeks have been quite hectic, I have been face-to-face with over a thousand Delphi developers talking about Delphi 2007 for Win32 in Stockholm, Gothenburg (thanks Karl-Otto for the CodeGeare cap), Budapest, Prauge (see picture), Helsinki, Copenhagen and Oslo. Jason Vokes tagged me and challenged me to write about five things I like with [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/prauge.jpg"><img vspace="2" align="right" width="160" src="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/prauge.jpg" hspace="5" alt="Prauge Delphi Day" /></a>The last weeks have been quite hectic, I have been face-to-face with over a thousand Delphi developers talking about <em>Delphi 2007 for Win32 </em>in Stockholm, Gothenburg (thanks Karl-Otto for the CodeGeare cap), Budapest, Prauge (see picture), Helsinki, Copenhagen and Oslo.</p>
<p><a href="http://blogs.codegear.com/jasonvokes/">Jason Vokes</a> tagged me and challenged me to write about five things I like with the new Delphi release:</p>
<ol>
<li>Like many other already have said, Delphi 2007 launches fast and has a quick and responsive IDE.</li>
<li>Second out are some small debugger features that are really usefull &#8211; You can set breakpoints in the call stack and stop execution when it returns to a specific stack frame and you can also select some code and drag and drop it to the watches windows for evaluation.</li>
<li>All RTL and VCL improvements like the MainFormOnTaskbar property on TApplication that solves the long existing problem with the application context menu, Flip3D and Thumbnail support. Improvement of DoubleBuffered rendering. Usage of themed components in IDE. Updated memory manager, etc.</li>
<li>The much improved help system.</li>
<li>And finally another small productivity feature &#8211; you can save several diffrent configurations of compiler and linker settings and easily switch between them with the Configuration Manager.</li>
</ol>
<p>I talked about <em>User Account Control</em> (UAC) during my CodeRage-session last week. I think UAC is one of the most important features of <em>Windows Vista</em> and if you are not in total control of your users&#8217; environment, sooner or later you will run into questions and support issus related to UAC.</p>
<p><strong>UAC Horror Story<br />
</strong>I heard a real horror story related to UAC from a developer in Sweden last week during the <a href="http://delphi.meetup.com/172">Delphi User Group meeting in Stockholm</a>. Their application has a local database and the database engine is launched by the application. Since UAC made the application start as <em>Standard User</em> the database enginge also started as Standard User. But a Standard User did not have the rights needed to modify the database files where they got installed. You would assume that this would generate an <em>Access Denied</em> error or some other error message? But no, and now the horror begins&#8230;</p>
<p>Since their application did not have required execution level information in the manifest Windows Vista runs the process in compatibility mode. Instead of failing to open the database which the process has no right to modify Windows Vista silently makes a copy of the whole database (to the personal VirtualStore for each user) and saves the changes there instead. The users did not notice anything initally because they work on diffrent projects but after a while they started to wonder why they could not see any changes their colleagues have done.</p>
<p>When they found out what was wrong they had to do a lot of manual work to merge each users&#8217; copy of the database back into one database again&#8230;</p>
<p><strong>Conclusion:</strong> To get rid of the dangerous compatibility feature called Virtualization or Redirection by adding a manifest with required execution level to all you executables immediately! This can be done easily by just recompiling your application in <em>Delphi 2007 for Win32</em> and checking use themes in project options or use the <em>xpman</em> unit in D2007. With an earlier Delphi release you can manually create and include the manifest.</p>
<p><strong>Command Line Applications<br />
</strong>I did not talk so much about command line applications and UAC during my Code-Rage session so I would like to write a little about that.</p>
<p>First, like with all applications targeting Windows Vista, you should have a manifest with required execution level to turn off compatibility mode. But even if you command line tool requires admin privileges you should never set <em>level = &#8220;requireAdministrator&#8221;</em>. The reason for this is that you do not want a batch script to be interrupted with a modal consent dialog, instead Microsoft recommends you to halt execution with an error message and set the exit code to <em>ERROR_ELEVATION_REQUIRED</em>.</p>
<blockquote><p><font size="2" face="Courier New"><strong>program</strong> VistaConsoleApplication;</font></p>
<p><font size="2" face="Courier New">{$APPTYPE CONSOLE}</font></p>
<p><font size="2" face="Courier New">//Include Manifest with trustinfo to make executable Vista Logo Compliant and not run in compatibility mode.<br />
//Console Applications should always run as invoker even if they require admin privileges.<br />
{$R &#8216;ExecutionLevelAsInvokerManifest.res&#8217; &#8216;ExecutionLevelAsInvokerManifest.rc&#8217;}</font></p>
<p><font size="2" face="Courier New"><strong>uses</strong><br />
SysUtils,<br />
UserAccessControlUtils in &#8216;UserAccessControlUtils.pas&#8217;;</font></p>
<p><font size="2" face="Courier New"><strong>begin</strong><br />
</font><font size="2" face="Courier New">//Call function to test we have admin privelieges<br />
</font><font size="2" face="Courier New">RequireAdminConsole;<br />
</font><font size="2" face="Courier New"><br />
//TODO: Your admin tool here&#8230;<br />
</font><font size="2" face="Courier New"><strong>end</strong>.</font></p></blockquote>
<p>The RequireAdminConsole function is really simple and it uses a function IsUserAnAdmin in the WinAPI to test. I have written the code so it binds dynamically. The reason is to make it work on operation systems before Windows 2000. You could also use a <a href="http://www.swissdelphicenter.ch/torry/showcode.php?id=189">NT4 compatible apporoach and check if token has SID for admin group</a> but that would be much more code&#8230;</p>
<blockquote><p><font size="2" face="Courier New"><strong>const</strong><br />
ModName = <font color="#008000">&#8216;shell32.dll&#8217;</font>;<br />
<strong>var</strong><br />
hShell32: HMODULE;<br />
_IsUserAnAdmin: <strong>function</strong>(): BOOL; <strong>stdcall</strong>;</font></p>
<p><font size="2" face="Courier New"><strong>function</strong> IsUserAnAdmin: Boolean;<br />
<strong>begin</strong><br />
<strong>if</strong> Assigned(_IsUserAnAdmin) <strong>then</strong><br />
Result := _IsUserAnAdmin()<br />
<strong>else</strong><br />
<strong>begin</strong><br />
Result := True;<br />
<strong>if</strong> hShell32 = 0 <strong>then</strong><br />
hShell32 := LoadLibrary(ModName);<br />
<strong>if</strong> hShell32 &lt;&gt; 0 <strong>then</strong><br />
<strong>begin</strong><br />
_IsUserAnAdmin := GetProcAddress(hShell32, <font color="#008000">&#8216;IsUserAnAdmin&#8217;</font>); // Do not localize<br />
<strong>if</strong> Assigned(_IsUserAnAdmin) <strong>then</strong><br />
Result := _IsUserAnAdmin();<br />
<strong>end</strong>;<br />
<strong>end</strong>;<br />
<strong>end</strong>;</font></p>
<p><font size="2" face="Courier New"><strong>resourcestring</strong><br />
SErrorElevationRequired = <font color="#008000">&#8216;Access Denied. Administrator permissions are needed to use the selected options. Use an administrator command prompt to complete these tasks.&#8217;</font>;<br />
<strong>const</strong><br />
ERROR_ELEVATION_REQUIRED = 740;</font></p>
<p><font size="2" face="Courier New"><strong>procedure</strong> RequireAdminConsole;<br />
<strong>begin</strong><br />
<strong>if</strong> <strong>not</strong> IsUserAnAdmin <strong>then</strong><br />
<strong>begin</strong><br />
WriteLn(SErrorElevationRequired);<br />
Halt(ERROR_ELEVATION_REQUIRED);<br />
<strong>end</strong>;<br />
<strong>end</strong>;</font></p></blockquote>
<p><strong>A new question</strong><br />
The code above just checks if your process is currently running with admin privileges. But with UAC there is also another question &#8211; <em>can the user become an administrator?</em></p>
<p>Since UAC splits the login token into a user token and a full token during login (if you have admin priveliges) you need to use new WinAPI features to find the answer to this question.</p>
<blockquote><p><font size="2" face="Courier New"><strong>type</strong><br />
<font color="#008000">//Enumeration is mirroring TOKEN_ELEVATION_TYPE in Windows Vista SDK (except first value).</font><br />
TTokenElevationType = (TokenElevationNotAvailable, TokenElevationTypeDefault, TokenElevationTypeFull, TokenElevationTypeLimited);</font></p>
<p><font size="2" face="Courier New"><font color="#008000">//Extend existing enumeration in Windows.pas with new Vista constants</font><br />
TTokenInformationClass = (TokenUser = 1, TokenGroups, TokenPrivileges,<br />
TokenOwner, TokenPrimaryGroup, TokenDefaultDacl, TokenSource, TokenType,<br />
TokenImpersonationLevel, TokenStatistics, TokenRestrictedSids, TokenSessionId,<br />
TokenGroupsAndPrivileges, TokenSessionReference, TokenSandBoxInert, TokenAuditPolicy,<br />
TokenOrigin, TokenElevationType, TokenLinkedToken, TokenElevation, TokenHasRestrictions,<br />
TokenAccessInformation, TokenVirtualizationAllowed, TokenVirtualizationEnabled,<br />
TokenIntegrityLevel, TokenUIAccess, TokenMandatoryPolicy, TokenLogonSid);</font></p>
<p><font size="2" face="Courier New"><strong>function</strong> GetTokenElevationType: TTokenElevationType;<br />
<strong>var</strong><br />
hToken: THandle;<br />
elevationType: Integer;<br />
dwSize: DWORD;<br />
<strong>begin</strong><br />
Result := TokenElevationNotAvailable;<br />
hToken := 0;<br />
Win32Check(OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, hToken));<br />
<strong>if</strong> GetTokenInformation(hToken, Windows.TTokenInformationClass(TokenElevationType), @elevationType, sizeof(elevationType), dwSize) <strong>then</strong><br />
Result := TTokenElevationType(elevationType);<br />
<strong>if</strong> hToken&lt;&gt;0 <strong>then</strong><br />
CloseHandle(hToken);<br />
<strong>end</strong>;</font></p></blockquote>
<p>Call the function GetTokenElevationType above to test the current state of elevation.</p>
<blockquote><p><font size="2" face="Courier New"><strong>case</strong> GetTokenElevationType <strong>of</strong><br />
TokenElevationNotAvailable:<br />
<strong>WriteLn</strong>(<font color="#008000">&#8216;No information about elevation is available. (This is a non-vista machine)&#8217;</font>);<br />
TokenElevationTypeDefault:<br />
<strong>WriteLn</strong>(<font color="#008000">&#8216;TokenElevationTypeDefault &#8211; User is not using a split token.&#8217;</font>);<br />
TokenElevationTypeFull:<br />
<strong>WriteLn</strong>(<font color="#008000">&#8216;TokenElevationTypeFull &#8211; User has a split token, and the process is running elevated.&#8217;</font>);<br />
TokenElevationTypeLimited:<br />
<strong>WriteLn</strong>(<font color="#008000">&#8216;TokenElevationTypeLimited &#8211; User has a split token, but the process is not running elevated.&#8217;</font>);<br />
<strong>end</strong>;</font></p></blockquote>
<p>You can <a href="http://cc.codegear.com/item/24512">download the example application here</a>. Please, share if you find any problems with the code above or if you have your UAC horror stories of you own!</p>
<p><img width="1" src="http://blogs.codegear.com/fhaglund/aggbug/33207.aspx" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2007/03/19/vista-user-account-control-and-command-line-applications/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Delphi Launch in Stockholm</title>
		<link>http://blog.fredrikhaglund.se/blog/2007/02/23/delphi-launch-in-stockholm/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2007/02/23/delphi-launch-in-stockholm/#comments</comments>
		<pubDate>Fri, 23 Feb 2007 16:32:58 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=21</guid>
		<description><![CDATA[Me and Jason Vokes did the first Delphi 2007 for Win32 Launch Event in Stockholm yesterday with almost 100 attendees. It was my first but hopefully not last CodeGear Launch and it was fun to talk in public about the new consolidated Database stack that DBX4 brings and the Windows Vista support in Delphi 2007. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/launchstockholm.jpg"><img vspace="2" align="right" src="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/launchstockholm.thumbnail.jpg" hspace="5" alt="launchstockholm.jpg" /></a>Me and Jason Vokes did the first Delphi 2007 for Win32 Launch Event in Stockholm yesterday with almost 100 attendees. It was my first but hopefully not last CodeGear Launch and it was fun to talk in public about the new consolidated Database stack that DBX4 brings and the Windows Vista support in Delphi 2007.</p>
<p>If you live in the Stockholm are, do not miss the next <a href="http://delphi.meetup.com/172">Delphi User Group event at 15th March</a>. I will talk more in depth about migration to Windows Vista there and Jonas Rapp from Cybercom Group will talk about how they automated their build process and improved their product. He will also talk about their process for localization.</p>
<p>Talking about Windows Vista we had a small incident yesterday. I have problems with my Video drivers on my lap-top when I run Vista. It is strange, I always get a nice picture on the projector when I run Windows XP but with Vista (and same hardware) my image flickers or does not display at all. This is the second lap-top where I experienced the same problem so in the future I will triple check that the Projector works and have an extra machine with me. Anyone else that have experience the same problem and maybe have a solution for the flickering?</p>
<p>Finally, I happens to like my PlayStation and I&#8217;m eagerly waiting for my PS3. One of the games I like is Dancing Stage Max but I think I never <a href="http://youtube.com/watch?v=uWmgBKTmXvQ">will be as good as this kid.</a></p>
<p><img width="1" src="http://blogs.codegear.com/fhaglund/aggbug/32264.aspx" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2007/02/23/delphi-launch-in-stockholm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The longest night of the year</title>
		<link>http://blog.fredrikhaglund.se/blog/2006/12/23/the-longest-night-of-the-year/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2006/12/23/the-longest-night-of-the-year/#comments</comments>
		<pubDate>Fri, 22 Dec 2006 23:05:21 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[UAC]]></category>
		<category><![CDATA[User Account Control]]></category>
		<category><![CDATA[Vista, UAC]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=20</guid>
		<description><![CDATA[This night was the longest night this year in the Nordic countries. In Stockholm the sun raised around nine and it was dark again at three. In the northern part of Norway, Sweden and Finland, above the polar circle, they did not even see the sun at all today. Flying around I have been to [...]]]></description>
			<content:encoded><![CDATA[<p>This night was the longest night this year in the Nordic countries. In Stockholm the sun raised around nine and it was dark again at three. In the northern part of Norway, Sweden and Finland, above the polar circle, they did not even see the sun at all today.</p>
<p><strong>Flying around<br />
</strong>I have been to Oslo, Copenhagen, Gothenburg, Helsinki and back to Oslo again the last weeks talking about Migrating from earlier Delphi to the current release and also about what you should do to make your application work on Windows Vista.</p>
<p>I have recorded one of my sessions that I presented at Oslo Delphi Club last week. It is about Windows Vista User Acount Control (UAC) and how you get your Delphi application to work with UAC. You can <a href="http://bdntv.borland.com/pix/fhaglund/VistaUACandDelphi/">watch the recording</a>, download the <a href="http://bdntv.borland.com/pix/fhaglund/VistaUACandDelphi/UAC_Demo.zip">example application</a> or just <a href="http://bdntv.borland.com/pix/fhaglund/VistaUACandDelphi/VistaUACandDelphi.ppt">look at my slide deck</a>.</p>
<p><img width="1" src="http://blogs.codegear.com/fhaglund/aggbug/30838.aspx" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2006/12/23/the-longest-night-of-the-year/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>InterBase on Windows Vista</title>
		<link>http://blog.fredrikhaglund.se/blog/2006/12/18/interbase-on-windows-vista/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2006/12/18/interbase-on-windows-vista/#comments</comments>
		<pubDate>Mon, 18 Dec 2006 18:47:28 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[InterBase]]></category>
		<category><![CDATA[UAC]]></category>
		<category><![CDATA[User Account Control]]></category>
		<category><![CDATA[Vista, UAC]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=19</guid>
		<description><![CDATA[Here are a few tips if you want to run InterBase on Windows Vista. Last InterBase release was made before Windows Vista so there are a few issues that you must be aware of. License Management Does not work as expected at all times. The backward compatibility feature called Virtualization or Redirection in Windows Vista [...]]]></description>
			<content:encoded><![CDATA[<p>Here are a few tips if you want to run InterBase on Windows Vista. Last InterBase release was made before Windows Vista so there are a few issues that you must be aware of.</p>
<h2>License Management</h2>
<p>Does not work as expected at all times. The backward compatibility feature called Virtualization or Redirection in Windows Vista can break it if you start the InterBase server or License Manager as a standard user. You risk getting copies of borland.lic, regXXX.txt, etc, in several folders and that makes things complicated.</p>
<p><strong>Workaround: </strong>Check “Run this program as Administrator” on shortcuts to InterBase Server Manager and License Manager. Make sure you do not have files in <em>c:\Users\&lt;username&gt;\AppData\Local\VirtualStore\Program Files\Borland\InterBase\license</em>. If you have, delete all files in licenses and place new copy of your regXXX.txt file to start over.</p>
<h2>Connect to Local Server</h2>
<p>Due to new process isolation in Windows Vista and the fact services starts in different session/desktop than users connecting to InterBase as Local Server in IBConsole and from your applications will not work.</p>
<p><strong>Workaround:</strong> Use Remote Server and TCP/IP protocol instead of Local Server. Connect to 127.0.0.1 or localhost. For you connection string in other applications use “127.0.0.1:” infront of the path to your database file.</p>
<h2>Windows Vista User Account Control (UAC)</h2>
<p>InterBase Server Manager starts as an ordinary user even if you are an administrator. Symptoms of this is that you get access denied if you try to register InterBase to run as a service.</p>
<p><strong>Workaround: </strong>Check “Run this program as Administrator” on shortcuts to InterBase Server Manager. Always check run InterBase server as a Service.</p>
<p>IBConsole saves settings in IBConsole.xml in program files and if you start it as an standard user it does not have write access to this folder so you will get a local copy in <em>c:\Users\&lt;username&gt;\AppData\Local\VirtualStore\Program Files\Borland\InterBase</em> instead. This can be confusing because if you make changes to the on in Program Files as administrator, nothing will happened for users with a local copy.</p>
<p><strong>Workaround:</strong> Change ACL to allow ordinary users to update it or start IBConsole or check “Run this program as Administrator” on shortcut.</p>
<p><img width="1" src="http://blogs.codegear.com/fhaglund/aggbug/30695.aspx" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2006/12/18/interbase-on-windows-vista/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>About Packages &#8211; Thougts after a Delphi Migration Workshop in Denmark</title>
		<link>http://blog.fredrikhaglund.se/blog/2006/12/09/about-packages-thougts-after-a-delphi-migration-workshop-in-denmark/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2006/12/09/about-packages-thougts-after-a-delphi-migration-workshop-in-denmark/#comments</comments>
		<pubDate>Sat, 09 Dec 2006 00:58:06 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=18</guid>
		<description><![CDATA[I had a nice day at PC-Ware in Denmark yesterday. The seminar was full and it was fun to talk through all new stuff in Delphi from a Win32 developer’s perspective. One of the topics of the seminar was to give attendees a good strategy to migrate a project from one Delphi version to another. [...]]]></description>
			<content:encoded><![CDATA[<p>I had a nice day at PC-Ware in Denmark yesterday. The seminar was full and it was fun to talk through all new stuff in Delphi from a Win32 developer’s perspective. One of the topics of the seminar was to give attendees a good strategy to<br />
migrate a project from one Delphi version to another.</p>
<p>One of the participants in the Migrate workshop completed his upgrade of a large Delphi 7 project in less than one hour with only one minor problem when upgrading component packages.</p>
<p>Recompiling your home written and 3rd party components is a problem I see many users struggle with when migrating.</p>
<p>I always strongly encourage developers to make sure they have all source code for their 3rd party components to guarantee that they will be able to upgrade to new Delphi versions in the future.</p>
<h3>Gift wrap</h3>
<p>Components are classes in ordinary units compiled into a package. A package is actually an ordinary <em>dll</em> with the extension changed to <em>bpl</em>. A package can be either a design-time package or a run-time package. Design-time packages are loaded by Delphi to get the components onto the Tools Palette and into the Form Designer in the IDE. It is important to understand that Delphi only can load packages compiled with the same Delphi version.</p>
<p>A package has usually dependencies to other run-time packages. This is listed in the <strong><em>requires</em></strong>-clause in the Delphi package project file. Select view source on the <em>dpk</em>-file to see them.</p>
<h3>Complex Search</h3>
<p>The ordinary Windows API’s <em>LoadLibrary</em> is used to load packages into memory. This means that dependent packages must be in a location where <em>LoadLibrary</em><br />
looks for them. <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/dynamic-link_library_search_order.asp">It is a complex search that depends on operating system version</a>. Basically it looks in the directory from which the application was loaded, the system and windows folder, current directory and in all folders in the process environment variable <em>PATH</em>. As you can guess it can easily get hold of the wrong version of the file if you are not careful.</p>
<p>To minimize the risk of loading a package compiled by another Delphi version it is recommended to add a number after the package name that corresponds with the version number of Delphi. For Delphi 7 that would be <em>70</em> and for Delphi 2006 the number is <em>100</em>.</p>
<h3>Simple to upgrade</h3>
<p>To make it easier for you to upgrade a package this number is added automatically to the package name of all packages listed in the <strong><em>requires</em></strong>-clause. So, the only thing you need to do to upgrade a package is to save it with a new number corresponding to the new Delphi version, build it and install it.</p>
<p>This functionality was added after Delphi 5 so if you upgrade a Delphi 5 it is probably easier to empty the <strong><em>requires</em></strong>-clause and let the Delphi IDE help you to<br />
rebuild it by recompiling several times.</p>
<h3>Migrate in minutes</h3>
<p>So to make a simple to upgrade your component packages follow this check list:</p>
<ul>
<li>Open each DPK-file and save them with a new version number matching the Delphi version.</li>
<li>Add all DPK-files to a project group by right clicking on the Project Group in the Project Manager and clicking <em>add existing project</em>. If several packages depend on each other order them with build sooner and build later.</li>
<li>Verify that your package output directory (set in Tools|Options) is in your Path variable. Otherwise LoadLibrary will not be able to find dependent packages. It is also possible to<br />
make a local override for environmental variables in Delphi’s Options dialog.</li>
<li>Build all packages.</li>
<li>If you have IFDEF in the source code and it does not compile, try to add conditional defines for earlier Delphi Compilers in Project Options until it compiles. (VER150 &#8211; Delphi 7; VER140 &#8211; Delphi 6; VER130 &#8211; Delphi 5). NOTE! Remember that version number of Delphi used in package names and the version number of Delphi compiler used in IFDEF is different!</li>
<li>If you get an error because unit DsgnIntf is missing, replace it with DesignIntf and DesignEditors.</li>
<li>If you are using units like DesignIntf and other units from the ToolsAPI folder and it does not compile try to add DesignIDE to your <strong><em>requires</em></strong>-clause of your package.</li>
<li>Finally, right click on all packages from top to bottom and select install on each of them. Run-time packages will fail to install but it is harmless.</li>
</ul>
<p><img width="1" src="http://blogs.codegear.com/fhaglund/aggbug/30383.aspx" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2006/12/09/about-packages-thougts-after-a-delphi-migration-workshop-in-denmark/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Small Celebration</title>
		<link>http://blog.fredrikhaglund.se/blog/2006/12/05/small-celebration/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2006/12/05/small-celebration/#comments</comments>
		<pubDate>Tue, 05 Dec 2006 18:56:37 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=17</guid>
		<description><![CDATA[We rewarded us with a small celebration today at the office in Stockholm. The count of Delphi 2006 licenses sold in the Nordic countries (that is Denmark, Finland, Norway, Sweden and Iceland) passed the count of Delphi 7 licenses. And No, we are not cheating and counting the free Turbo products. The following days are [...]]]></description>
			<content:encoded><![CDATA[<p>We rewarded us with a small celebration today at the office in Stockholm. The count of Delphi 2006 licenses sold in the Nordic countries (that is Denmark, Finland, Norway, Sweden and Iceland) passed the count of Delphi 7 licenses. And No, we are not cheating and counting the free Turbo products.</p>
<p>The following days are going to be busy for me. I&#8217;m doing a Delphi Migration seminar in <a href="http://ec.borland.com/eventDisplay.faces?e=712&amp;v=month&amp;t=1165341148014">Denmark on Thursday</a>, <a href="http://ec.borland.com/eventDisplay.faces?e=711&amp;v=month&amp;t=1165341170749">Gothenburg on Friday</a>, <a href="http://ec.borland.com/eventDisplay.faces?e=713&amp;v=month&amp;t=1165341213593">Helsinki on Monday</a> and <a href="http://ec.borland.com/eventDisplay.faces?e=710&amp;v=month&amp;t=1165341254311">Stockholm on Tuesday</a>. The goal with the seminar and workshop is to help Delphi developers that wants to upgrade their projects from Delphi 5,6,7 to Delphi 2006 or want to learn more about what they have to do to adapt their application to Windows Vista. All events are fully booked except in Helsinki where there are a few seats left.</p>
<p><img width="1" src="http://blogs.codegear.com/fhaglund/aggbug/30261.aspx" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2006/12/05/small-celebration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delphi 2006 on Vista</title>
		<link>http://blog.fredrikhaglund.se/blog/2006/12/04/delphi-on-vista-and-swedish-irc-channel/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2006/12/04/delphi-on-vista-and-swedish-irc-channel/#comments</comments>
		<pubDate>Mon, 04 Dec 2006 21:03:03 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Vista, UAC]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=16</guid>
		<description><![CDATA[I promised Magnus who is one of the organizers of the Delphi User Group in Gothenburg to promote the Swedish Delphi IRC channel. Just start IRC when you come to work and have the channel open and your Swedish Delphi peers are only a few clicks away&#8230; I guess our Scandinavian friends are welcome to [...]]]></description>
			<content:encoded><![CDATA[<p>I promised Magnus who is one of the organizers of the <a href="http://delphi.meetup.com/11">Delphi User Group in Gothenburg</a> to promote the <a href="irc://se.quakenet.org/delphi.nordic">Swedish Delphi IRC channel</a>. Just start IRC when you come to work and have the channel open and your Swedish Delphi peers are only a few clicks away&#8230; I guess our Scandinavian friends are welcome to <img src='http://blog.fredrikhaglund.se/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>To use IRC you need a client just like your browser and the most popular client is <a href="http://www.mirc.co.uk/">mIRC</a> (<a href="http://www.mirc.co.uk/get.html">download</a>). It is shareware but there are others that are free, just google around a little&#8230;</p>
<p>There are many, many different irc networks so you need to connect to Quakenet when your client is installed and join the channel #delphi.nordic</p>
<h3>Delphi 2006 and Windows Vista</h3>
<p>I reinstalled the RTM version of Windows Vista a few days ago. Delphi 2006 is running fine on the my new operating system even if there where some quirks during the install. I thought I should mention them here if you too run into them. The installer issues appear to be related to the fact that Windows Vista has a new version of msiexec that behaves slightly different. If you google this topic you might find a few references on the net that Delphi does not install at all on Vista but that only applies to Vista Release Candidate 2, that had a defect in the installer.</p>
<p>Bootstrap &#8211; Before you can install you have to install a few Microsoft components. All of them installs fine except SP1 for dot net 1.1. You will get a big dialogue with all msi command line options. Before you hit OK manually start the installation of SP1 from you CD by double clicking on XXX. When installation is complete, reboot you computer. When it restarts there will be a warning in your system tray that a program is blocked. Right click on the icon and select run blocked program from the popup menu.</p>
<p>Delphi Update 2 &#8211; The msi package with update 2 does not find the installation if you double click on it. You have to click on the Windows Start button, type cmd, right click on the Cmd Short cut and select run as administrator. From the console windows follow the instructions in the readme file for msi version 3.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2006/12/04/delphi-on-vista-and-swedish-irc-channel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Friday &#8211; Finally! (And how to butify your Pascal)</title>
		<link>http://blog.fredrikhaglund.se/blog/2006/11/24/how-to-butify-your-pascal/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2006/11/24/how-to-butify-your-pascal/#comments</comments>
		<pubDate>Fri, 24 Nov 2006 18:34:01 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=15</guid>
		<description><![CDATA[I have been teaching Delphi in Linkoping, Sweden this week. Even if you know your topic it requires constant concentration and it is exhausting but fun. This week, a colleague of mine attended the Java User Group meetings in Stockholm and Gothenburg (together with 350 Java developers) and talked about JBuilder 2007. Most seem to [...]]]></description>
			<content:encoded><![CDATA[<p>I have been teaching Delphi in Linkoping, Sweden this week. Even if you know your topic it requires constant concentration and it is exhausting but fun.</p>
<p>This week, a colleague of mine attended the Java User Group meetings in Stockholm and Gothenburg (together with 350 Java developers) and talked about JBuilder 2007. Most seem to have the understanding that we have been knocked-out but are happy to see us up and running again with new innovations in the Java area and a good well founded support for our Eclipse strategy. All developers that we have spoken to are courious about JB2007 and most understand the needs we address in the product and they way we are doing it. All find Eclipse to be a hassle to configure but really appreciate the open api&#8217;s and flexibility, from that perspective all buy into what we are doing with JBuilder.</p>
<p>It is nice to have a company name again and at December 13th we (the eight CodeGear guys in Stockholm) move to our new office in <a href="http://www.solnabusinesspark.se/">Solna Business Park</a>.</p>
<p>There are a lot of Delphi activities in Scandinavia the following weeks.</p>
<h3>Delphi Migration Seminar and Workshop</h3>
<p>For Delphi developers that want help to upgrade their projects from Delphi 5, 6, 7 to Delphi 2006 or want to learn more about what they have to do to adapt their applications to Windows Vista.</p>
<p><strong><a href="http://www.ravenholm.dk/Software/Seminars/SeminarsInfo.asp?id=55">Copenhagen, December 7th</a></strong></p>
<p><a href="http://www.pc-ware.se/Software/Seminars/SeminarsInfo.asp?id=24">Gothenburg, December 8th</a></p>
<p><a href="http://www.moonsoft.fi/customerservice/delphivista.aspx">Helsinki, December 11th</a></p>
<p><a href="http://www.pc-ware.se/Software/Seminars/SeminarsInfo.asp?id=24">Stockholm, December 12th</a></p>
<h3>Delphi Day in Oslo</h3>
<p>There are also plans for a one day seminar in Oslo at December 15th. More details are coming about this&#8230;</p>
<p><strong>Have a look at <a href="http://jedicodeformat.sourceforge.net/">Jedi Code Format</a></strong></p>
<p>A very useful little tool if you are running into a project that has all text in uppercase and no indenting. I love it! I just had to tell you about it if you missed it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2006/11/24/how-to-butify-your-pascal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Looking for a new Job?</title>
		<link>http://blog.fredrikhaglund.se/blog/2006/09/24/looking-for-a-new-job/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2006/09/24/looking-for-a-new-job/#comments</comments>
		<pubDate>Sat, 23 Sep 2006 23:13:45 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=14</guid>
		<description><![CDATA[I noticed that Skype is searching for a new Delphi programmer doing UI Development for Windows. Interesting if you happens to live in Estonia! You do not have so many options good options today if you want to develop native applications (and with native I mean not a managed .NET application). I guess the main [...]]]></description>
			<content:encoded><![CDATA[<p>I noticed that Skype is searching for a new <a href="http://jobs.skype.com/2006/07/ui_developer_for_windows.html">Delphi programmer doing UI Development for Windows</a>. Interesting if you happens to live in Estonia!</p>
<p>You do not have so many options good options today if you want to develop native applications (and with native I mean not a managed .NET application). I guess the main candidates are Delphi, C++Builder, VB6 and possible C++ if you like MFC. Correct me if I&#8217;m wrong&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2006/09/24/looking-for-a-new-job/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The new Memory Manager in Delphi</title>
		<link>http://blog.fredrikhaglund.se/blog/2006/09/15/user-group-meeting-in-stockholm/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2006/09/15/user-group-meeting-in-stockholm/#comments</comments>
		<pubDate>Fri, 15 Sep 2006 18:16:25 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=13</guid>
		<description><![CDATA[Yesterday evening I attended a Delphi user group meeting in Stockholm, Sweden. Memory Manager I spoke very shortly about the change of Memory Manager in Delphi 2006. Except for the IDE, the new memory manager only affects Delphi and C++ applications compiled to native code (i.e. Win 32) not .Net applications. function GetMem(Size: Integer): Pointer; [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday evening I attended a <a href="http://delphi.meetup.com/172/">Delphi user group meeting in Stockholm, Sweden</a>.</p>
<p><strong>Memory Manager</strong></p>
<p>I spoke very shortly about the change of Memory Manager in Delphi 2006. Except for the IDE, the new memory manager only affects Delphi and C++ applications compiled to native code (i.e. Win 32) not .Net applications.</p>
<p><code><strong>function</strong> GetMem(Size: Integer): Pointer;</code></p>
<p><code><strong>function</strong> FreeMem(P: Pointer): Integer;</code></p>
<p><code><strong>function</strong> ReallocMem(P: Pointer; Size: Integer): Pointer;</code></p>
<p>The Memory Management is only three functions to implement as effectively as possible. These basal functions are used by almost everything in you application so changing them can have a remarkable effect on your application &#8211; they affect the overall speed and memory usage.</p>
<p>But implementing them is easier said than done. There is a lot of interesting optimizations problems; memory fragmentation is one area.</p>
<p><strong>Memory Fragmentation</strong></p>
<p>The large rectangle in picture 1 represents one part of your heap. It is a larger memory block that the memory manager required from the operating system. The green rectangles are smaller blocks that are in use – they could contain for example a string, a button instance, a dynamic array, etc.</p>
<p>In picture 2 more objects are created and space is reserved for them on the heap. In picture 3 old objects are freed and memory is available for use again.</p>
<p>Notice that we get gaps. In picture 4 we need to allocate room for a new block that is slightly larger. We need to spend time to search for a space that is large enough and when we find a gap the fit might not be perfect and we get smaller gaps of unused space.</p>
<p><a href="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/fragmentation1.gif"><img src="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/fragmentation1.gif" alt="fragmentation1.gif" /></a></p>
<p><strong>FastCode Project</strong></p>
<p>In 2005 the <a href="http://www.fastcodeproject.org/">FastCode Project</a> had a challenge to write the fastest replacement for the Delphi Memory Manager. The Fastcode Challenges is a project running on a volunteer basis that provides highly optimized functions for the Delphi community. (Thank you guys!) Functions are faster versions of Delphi runtime library functions, VCL functions or functions meant as extensions for these.</p>
<p>Pierre le Riche won the challenge with his memory manager <a href="http://sourceforge.net/projects/fastmm">FastMM</a>. In Developer Studio<br />
2006 (and the new Turbo Delphi and Turbo C++) is the old Memory Manager (located in getmem.inc) replaced with Pierre’s code from FastMM.</p>
<p><strong>New and Old</strong></p>
<p>The FastCode project has a benchmark and validation tool to measure and test the different contributions and the benchmark below compares the default memory manager in Delphi 7 and Delphi 2006.</p>
<p><a href="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/benchmark1.gif"><img src="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/benchmark1.gif" alt="benchmark1.gif" /></a></p>
<p>As you can see there is a drastic difference. Will it double the speed of your application if you recompile? Probably not but it depends on your code off course. I guess the easiest way to find out is to recompile your application in Delphi 2006 and test.</p>
<p>There are other benefits except for increased speed and reduced memory consumption. Since there is less memory fragmentation, memory intense application can run longer before the dreaded out of memory exception occurs. You can also use more than 3GB memory.</p>
<p><strong>Report on Memory Leaks </strong></p>
<p>The new memory manager works differently than the old memory manager and does more pointer checking, so it will catch more errors.</p>
<p>Setting ReportMemoryLeaksOnShutdown to True shows a message box with a report on all memory leaks every time you shut down your application.</p>
<p><code>{Display leaks on shutdown if a debugger is present}<br />
ReportMemoryLeaksOnShutdown := DebugHook &lt;&gt; 0;</code></p>
<p>Turning it on can be a bit horrifying if you add it to an existing project. It will take some time before you get a clean project but it can be very useful if you have it in place from the beginning of a new project.</p>
<p>Read more about the new memory manager in a <a href="http://bdn.borland.com/article/33416">BDN article by Pierre le Riche</a>.</p>
<p><strong>Stuck on older versions?</strong></p>
<p>It is possible to replace the default memory manager in older Delphi versions with your own. The only thing you have to do is to call SetMemoryManager in the System unit. If you have an old Delphi application you have not upgraded yet it is possible to download FastMM and use it in your existing application.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2006/09/15/user-group-meeting-in-stockholm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Front, Middle or Back?</title>
		<link>http://blog.fredrikhaglund.se/blog/2006/09/04/front-middle-or-back/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2006/09/04/front-middle-or-back/#comments</comments>
		<pubDate>Mon, 04 Sep 2006 16:00:22 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=12</guid>
		<description><![CDATA[I attended the annual autumn seminar organised by the Delphi user group in Gothenburg, Sweden. We where twenty four enthusiastic Delphi hackers networking and sharing ideas about development. I was invited to talk about the Roadmap of DevCo’s products and listen to feedback. We ended the day by visiting the amusement park Liseberg. They have [...]]]></description>
			<content:encoded><![CDATA[<p>I attended the annual autumn seminar organised by the Delphi user group in Gothenburg, Sweden. We where twenty four enthusiastic Delphi hackers networking and sharing ideas about development. I was invited to talk about the <a href="http://bdn.borland.com/article/33519">Roadmap of DevCo’s products</a> and listen to feedback.</p>
<p><a href="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/balder434x300.jpg"><img vspace="2" align="right" src="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/balder434x300.thumbnail.jpg" hspace="5" alt="Balder" /></a>We ended the day by visiting the amusement park Liseberg. They have a cool rollercoaster built in wood called Balder and I tried to empirical find out where it is best to sit. <em>“Different forces operate on the front and the back of the train and the ride in the front is distinctly different from the back. … The train is slowing down as the train begins to climb over the top of the hill, and speeding up again as it starts to descend again. Thus, if there is any airtime to be had before the top of the hill, it will be best in the front, as that is the part of the train moving fastest there, but airtime after the top of a hill will be best in the back. Thus, depending on the configuration of hills on a coaster, it may a better front seat ride or back seat ride.”</em> For this rollercoaster I think the front seat is best. <img src='http://blog.fredrikhaglund.se/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><a href="http://hallvards.blogspot.com/">Hallvard Vassbotn</a>, one of the Delphi Gurus in Norway, is <a href="http://hallvards.blogspot.com/2006/08/nordic-delphi-meetup-groups.html">bloging about community meetings in Oslo</a>. He is also writing a lot of intresting things about what’s new in the language since Delphi 7.</p>
<p>One of the messages I bring back from the users at the Gothenburg meeting to DevCo is not to loose focus on native development. Win32 development is still very important.<br />
– Make it future proof with Win64 compiler, Unicode support and Avalon (WPF) for VCL and bring back Delphi.NET language improvements to the native compiler.</p>
<p>Next community meeting in the Nordic region is in Stockholm in 10 days: <a href="http://delphi.meetup.com/172/events/5040855/">http://delphi.meetup.com/172/events/5040855/</a></p>
<p><img width="1" src="http://blogs.codegear.com/fhaglund/aggbug/27302.aspx" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2006/09/04/front-middle-or-back/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nostalgia &#8211; what&#8217;s next?</title>
		<link>http://blog.fredrikhaglund.se/blog/2006/08/26/nostalgia-whats-next/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2006/08/26/nostalgia-whats-next/#comments</comments>
		<pubDate>Sat, 26 Aug 2006 14:32:54 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=11</guid>
		<description><![CDATA[I had a little delayed spring cleaning of my apartment. And look what I found deep down in a drawer! It is easy to feel nostalgic but what I learned back then back in school using Turbo Pascal has formed my whole carrier. I have always liked the Pascal language; I do not know why [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/disketterhi.jpg"><img vspace="2" align="right" src="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/disketterhi.thumbnail.jpg" hspace="5" alt="disketterhi.jpg" /></a>I had a little delayed spring cleaning of my apartment. And look what I found deep down in a drawer!</p>
<p>It is easy to feel nostalgic but what I learned back then back in school using Turbo Pascal has formed my whole carrier. I have always liked the Pascal language; I do not know why but I think it is because I feel productive and it is easy to get a grip of the code compared to other languages. (A very subjective, personal opinion – please do not flame me with a language war.)</p>
<p>It is easy when you speak one programming language fluently to look down on other languages and see what is missing in them and what makes your language more high level and effective. But what about the other way around? If you look up at a language that has something that make it more effective and help you develop on a higher level of abstraction. Will you recognise it? Probably not. I guess that most people would have a look at it and disregard it as something strange that you do not need.</p>
<p>I loved when the Pascal language was extended with objects in back in Turbo Pascal 5.5 but it took a while of study and thinking before I got it. We have made a lot of improvements over the years (and I like all of them except nested types which I think looks ugly, it does not feel right).</p>
<p>So what is the next major improvement of Object Pascal going to be? If I could decide I would have a look at one of the cool features of Lisp – <a href="http://en.wikipedia.org/wiki/Closure_%28computer_science%29">closures</a>.</p>
<p>How could that look like in Pascal? Procedural types can already be used to pass along a pointer to a function but passing a pointer to a local procedure to a procedure variable will not be accepted by the compiler today.</p>
<pre><strong>procedure</strong> doThreetimes( P: TProcedure );
<strong>begin</strong>
  P;
  P;
  P;
<strong>end</strong>;<strong>procedure</strong> Count;
<strong>var</strong>
  n: <strong>integer</strong>;
<strong>procedure</strong> add1;
  <strong>begin</strong>
    n := n + 1;
  <strong>end</strong>;
<strong>begin</strong>
  n := 0;
  doThreeTimes( add1 );
  WriteLn( n ) // here n is 3
<strong>end</strong>;</pre>
<p>Another way could be to pass anonymous functions.</p>
<pre><strong>procedure</strong> doThreetimes( P: TProcedure );
<strong>begin</strong>
  P;
  P;
  P;
<strong>end</strong>;<strong>procedure</strong> Count;
<strong>var</strong>
  I: integer;
<strong>begin</strong>
  I := 0;
  doThreeTimes(
    <strong>procedure</strong>();
    <strong>begin</strong>
      I := I + 1;
    <strong>end</strong>; );
  WriteLn( I ) // here I is 3
<strong>end</strong>;</pre>
<p>Or maybe like this:</p>
<pre><strong>procedure</strong> TForm1.FormCreate(Sender: TObject);
<strong>begin</strong>
  Button1.OnClick := <strong>procedure</strong>(); <strong>begin</strong>
    Self.Caption := 'New Form Title';
  <strong>end</strong>;
<strong>end</strong>;</pre>
<p>So what would you choose to improve in Object Pascal if you could decide for yourself?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2006/08/26/nostalgia-whats-next/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Swedish Info&#8230;</title>
		<link>http://blog.fredrikhaglund.se/blog/2006/08/24/swedish-info/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2006/08/24/swedish-info/#comments</comments>
		<pubDate>Wed, 23 Aug 2006 23:52:14 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=10</guid>
		<description><![CDATA[Användargrupp i Göteborg Vi vill lyfta fram användargruppen för Delphi i Göteborg som organiseras av Magnus Flysjö. Vill du träffa andra utvecklare och byta erfarenheter? Gruppen träffas regelbundet och det kostar inget att vara medlem. Läs mer och bli medlem» Höstseminarium i GöteborgFredagen den 1 september anordnar användargruppen för Delphi i Göteborg sitt höstseminarium och [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Användargrupp i Göteborg</strong><br />
Vi vill lyfta fram användargruppen för Delphi i Göteborg som organiseras av Magnus Flysjö. Vill du träffa andra utvecklare och byta erfarenheter? Gruppen träffas regelbundet och det kostar inget att vara medlem.</p>
<p><a href="http://delphi.meetup.com/11">Läs mer och bli medlem»</a></p>
<hr /><strong>Höstseminarium i Göteborg</strong>Fredagen den 1 september anordnar användargruppen för Delphi i Göteborg sitt höstseminarium och det finns fortfarande några platser kvar.</p>
<p>Seminariet hålls på hotell Gothia Towers i centrala Göteborg mellan klockan 08:30 och 15:30. Efteråt blir det femkamp på Liseberg för dem som vill och vinnaren kan gå hem med en iPod Nano eller digitalkamera.</p>
<p><a href="http://delphi.meetup.com/11/events/5007456/">Läs mer om programmet och anmäl dig här»</a></p>
<hr /><strong>Användarmöte i Stockholm</strong>Torsdag den 14 september blir det användarmöte efter jobbet i Stockholm. Mötet är på Nordic Sea hotell (vid Arlanda Express) klockan 17:00.</p>
<p>Det kommer att finnas möjlighet att presentera sig och vad man jobbar med. Vi bjuder på en matig smörgås under kvällen och det finns tid för lite nätverkande och småprat. Kort information om delningen av Borland. Vi har bjudit hit Holger Flick från Tyskland för att prata om webbprogrammering med ASP.NET och ECO.</p>
<p>Varför den nya minneshanteraren i BDS 2006 kan fördubbla hastigheten på din Win32 applikation och andra tips.</p>
<p>Produktchefen för Interbase samt utvecklingsavdelningen för Delphi i Stockholm är på plats för att svara på dina frågor.</p>
<p><a href="http://delphi.meetup.com/172/events/5040855/">Läs mer och anmäl dig här»</a></p>
<hr /><strong>EuroDevCon 2006</strong>I slutet av september hålls den Europeiska utvecklarkonferensen i Frankfurt, Tyskland. Här kan du se semiarier av Marco Cantù, Ray Konopka, Michael Li, Bob Swart, m.fl. Före och efter konferensen finns också endags workshops för den som vill fördjupa sig.</p>
<p><a href="http://www.eurodevcon.com/">Läs mer»</a></p>
<hr />Tveka inte att kontakta mig, mina kollegor eller våra partners med synpunkter och frågor.Vänliga hälsningar,<br />
Fredrik Haglund</p>
<p><img width="1" src="http://blogs.codegear.com/fhaglund/aggbug/26925.aspx" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2006/08/24/swedish-info/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delphi Community meetings in Sweden</title>
		<link>http://blog.fredrikhaglund.se/blog/2006/07/25/delphi-community-meetings-in-sweden/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2006/07/25/delphi-community-meetings-in-sweden/#comments</comments>
		<pubDate>Tue, 25 Jul 2006 16:49:43 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=9</guid>
		<description><![CDATA[If you do not live in Sweden you can stop reading now&#8230; I min nya roll på Borland som ”Evangelist” för Developer Tools Group i Norden ingår det bland annat att hålla kontakt med alla utvecklare. Både att lyssna på er feedback och prata ur ett teknikst perspektiv om våra utvecklingsverktyg, så vad kan vara [...]]]></description>
			<content:encoded><![CDATA[<p>If you do not live in Sweden you can stop reading now&#8230;</p>
<hr />I min nya roll på Borland som ”Evangelist” för Developer Tools Group i Norden ingår det bland annat att hålla kontakt med alla utvecklare. Både att lyssna på er feedback och prata ur ett teknikst perspektiv om våra utvecklingsverktyg, så vad kan vara lämpligare att börja med att ha några möten där vi kan träffas?I september ser det ut att bli två Delphi Community Möten.Det första arrangeras av <a href="http://delphi.meetup.com/11/">Göteborg Delphi Meetup Group</a> och är den <strong>1 september i Göteborg</strong>. Agendan håller på att ta form just nu men det blir en heldag som avslutas med fem-kamp på Liseberg för dem som vill.Det andra mötet blir i <strong>Stockholm den 14 september</strong> efter jobbet. Inga detaljer klara ännu men sätt ett märke i din kalender!</p>
<p>Några frågor? Skriv gärna en rad och berätta att du finns och vad du gör. Vi hörs!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2006/07/25/delphi-community-meetings-in-sweden/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delphi on Rails?</title>
		<link>http://blog.fredrikhaglund.se/blog/2006/07/15/delphi-on-rails/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2006/07/15/delphi-on-rails/#comments</comments>
		<pubDate>Sat, 15 Jul 2006 15:17:54 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=8</guid>
		<description><![CDATA[There is a lot of hype around the open source project Ruby on Rails these days so I spent some time looking into the framework because I’m always curious about new technology. First impression is always important and I really liked the home page for Ruby on Rails for its simplicity and David Heinemeier Hansson’s [...]]]></description>
			<content:encoded><![CDATA[<p><strong>There is a lot of hype around the open source project Ruby on Rails these days so I spent some time looking into the framework because I’m always curious about new technology. First impression is always important and I really liked the home page for Ruby on Rails for its simplicity and David Heinemeier Hansson’s exciting 15 minutes introduction. </strong></p>
<p>Personally I think it is the commercial open source framework part (read VCL if you like) of Delphi that has been one of the strongest success factors for the product over the years. One of the newest additions of frameworks in Delphi (or BDS if you prefer) is the ECO framework and that framework has some things in common with Rails.</p>
<p>- Yes, before someone rubs it in my face, I know we do not ship every line of source for the ECO framework like with most other parts of VCL. I agree that it is important to be able to recompile and study the source of the foundation you build your application on. I promise you that I nag on the ECO-team every day about this.</p>
<p>The ECO framework is one of the more secret weapons in Delphi. I must admit we have not been very good at educating our developer community on how to benefit from this fantastic framework in the product. A lot of you out there have glanced at it and either got scared because of the first step is a little to large or got disheartened by the modelling surface in the IDE before you even started to look at the framework. I encourage you to take another look!</p>
<p>I started to roll with Ruby on Rails by looking at the Cookbook example. With a few steps you have a simple application up and running with a classic Model-View-Controller architecture using a database but without tedious manual SQL-mapping.</p>
<p><a href="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/rail2.PNG"><img src="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/rail2.PNG" alt="rail2.PNG" /></a></p>
<p>Very nice! This is showing that more developers are getting ready to work with domain objects, attributes and methods instead of tables, columns and rows. I remember how hard it was to explain the benefits of model-view back in 1997 when I started to develop applications using domain objects instead of using the database approach with TQueries, etc.</p>
<p>One important part of the Rails framework is the mapping between Objects and the Database. This part of a framework is usually called an Object-Relational mapper (or short OR-mapper) and takes care of all basic CRUD-operations (Create, Retrieve, Update and Delete).</p>
<p>In Delphi.NET (and C#) the ECO-framework can do OR-mapping for you. ECO has been around for some time, it is actually version seven. We have made four major releases for Win32 under the name Bold (Business Object Layer for Delphi) and three DotNet releases. ECO is very model centric than Rails which is more database centric. I like the Rails concept “Don’t Repeat Yourself”. Maybe it is easier for adopters to understand and start with a database centric approach? ECO has a tool that can import a schema from a database but it could be simpler to use…</p>
<p>Anyone who has tried to write an OR-mapper knows that the first steps are very simple and then you will hit a wall of complex problem you have to solve. I tried to provoke the OR-mapper in Rails just to see how mature it is and what would happen.<br />
The cookbook example has only two classes, recipe and category. I created a new category and then a new recipe. I assigned the category pointer in the new recipe instance to point to my new category. Then I deleted my newly created category. BANG! I got a nil pointer error in the view. It happens and is easy to fix, who has not got Access Violations in there applications when the code does not expect nil pointers?</p>
<p><a href="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/rail1.PNG"><img src="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/rail1.PNG" alt="rail1.PNG" /></a></p>
<p>But more worrying is that Rails OR-mapper <em>has not updated the other end of the relation at all</em>. Looking directly at the SQL table there is records with category_id pointing to a category that does not exist. And when I added referential integrity to that database Rails got problems updating the database isntead. There might be easy ways get this to work in Rails but I’m a Rails rookie and I have not found it yet. Can someone with deeper knowledge enlighten me?</p>
<p>Anyway, I know that we have spent several a lot of time perfecting the OR-mapper in the ECO framework to solve problems like this. Managing associations between objects is one complex area where much thought has been spent. If you modify one end of a relation, you need to update pointers in the other end and generating the correct order of SQL insert-, update- and delete-statements is crucial to not violate referential integrity in the database.</p>
<p><img width="1" src="http://blogs.codegear.com/fhaglund/aggbug/25963.aspx" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2006/07/15/delphi-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimized Pascal compilation time</title>
		<link>http://blog.fredrikhaglund.se/blog/2006/07/03/optimized-pascal-compilation-time/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2006/07/03/optimized-pascal-compilation-time/#comments</comments>
		<pubDate>Mon, 03 Jul 2006 19:18:18 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=7</guid>
		<description><![CDATA[I was helping a customer to migrate from Delphi 5 to Delphi 2006 for some time ago. It was almost only to reopen and compile the project except for some minor changes. We had to add a few units (i.e. variants) to the uses clause here and there and fiddle with conditional defines in a [...]]]></description>
			<content:encoded><![CDATA[<p>I was helping a customer to migrate from Delphi 5 to Delphi 2006 for some time ago.</p>
<p>It was almost only to reopen and compile the project except for some minor changes. We had to add a few units (i.e. variants) to the uses clause here and there and fiddle with conditional defines in a few places to get it to compile with both D5 and D2006. A third party component was not a backward compatible as you cold wish but in general the major work was done in less than a day.</p>
<p>But there where one big issue that we had to address first. The size of the project was about a few hundred forms and half a million lines of code. It took 90 minutes to compile in D5 and even longer in D2006. What is going on here? Ninety minutes for half a million lines of code is not the speed of the lightning fast Pascal compiler as I know it!</p>
<p>After analyzing the code I found that there was a general pattern of including a lot of units in the uses-clause in every unit. It appeared that this crisscross of references had a non-linear time complexity on the compiler. The only way to fix it immediately was to remove as many units as you can from the uses-clause in the interface section or move them to the implementation section. I imagined a nightmare of daunting manual work…</p>
<p>In the end the recipe to fix this was rather simple. It involves some free tools and open source tools but it does the job automatic. And the result was a rather successful optimization. <strong>We reduced compiled time from 90 minutes to 50 seconds &#8211; over 100 times! And the linker could remove 100.000 lines of unused code.</strong> I was pretty pleased with myself that evening. <img src='http://blog.fredrikhaglund.se/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h2>Ingredients</h2>
<ul>
<li>ICARUS – a free tool from the maker of Pascal Analyzer. <a href="http://www.peganza.com/products.htm">http://www.peganza.com/products.htm</a>. Icarus parses Delphi or Borland Pascal source code and generates a Uses Report. This report will help you remove unneeded units from your uses lists. You will also know which units that can be moved from the interface uses list to the implementation uses list.</li>
<li>Uses Cleanup Tool – by Oleg Zhukov <a href="http://cc.borland.com/Item.aspx?id=23199">http://cc.borland.com/Item.aspx?id=23199</a>.</li>
</ul>
<h2>Step-by-step</h2>
<ul>
<li>Run ICARUS on your delphi project to get a report of which units depends on each other.</li>
<li>Input this report in the Uses Cleanup tool to automatically update all uses-clauses in your source code.</li>
<li>Delete all DCU-files and recompile.</li>
</ul>
<p><img width="1" src="http://blogs.codegear.com/fhaglund/aggbug/25804.aspx" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2006/07/03/optimized-pascal-compilation-time/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Hello World&#8230; or at least Hello Scandinavia!</title>
		<link>http://blog.fredrikhaglund.se/blog/2006/06/30/hello-world-or-at-least-hello-scandinavia/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2006/06/30/hello-world-or-at-least-hello-scandinavia/#comments</comments>
		<pubDate>Thu, 29 Jun 2006 22:29:46 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=6</guid>
		<description><![CDATA[The Developer Tools Group is growing; I&#8217;m new in the role as Evangelist in the Nordic Countries. It feels good and all nine of us DevCo guys in the Stockholm office are excited. Part of my job is to stay in touch with You, the Developer Community in Finland, Denmark, Norway and Sweden. Keep you [...]]]></description>
			<content:encoded><![CDATA[<p>The Developer Tools Group is growing; I&#8217;m new in the role as Evangelist in the Nordic Countries. It feels good and all nine of us DevCo guys in the Stockholm office are excited.</p>
<p>Part of my job is to stay in touch with You, the Developer Community in Finland, Denmark, Norway and Sweden. Keep you updated and feedback your suggestion and ideas to the guys at Engineering.</p>
<hr />Skriv gärna en rad och berätta att du finns och vad du gör. Vi hörs!Minä en puhu suomea mikä jo varmaankin herätti huomiosi, ja sehän oli tarkoituskin. Olen uusi tässä DevCo &#8220;Evankelista&#8221; rollissa ja haluaisin mielelläni päästä yhteyteen kaikkien pohjoismaalaisten kanssa jotka käyttävät meidän tuotteitamme. Kirjoita muutamalla rivillä itsestäsi ja kerro mitä teet. Pidetään yhteyttä!</p>
<hr />Click Contact in the menu to send me a private mail! &#8211; Don&#8217;t forget your own e-mail address otherwise I can not get back to you <img src='http://blog.fredrikhaglund.se/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> <em>/Fredrik</em></p>
<p><img width="1" src="http://blogs.codegear.com/fhaglund/aggbug/25724.aspx" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2006/06/30/hello-world-or-at-least-hello-scandinavia/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

