Delphi Class Completion (Ctl-Shft-C) Stops Working

March 18th, 2012

Suddenly, pressing Ctl-Shft-C in the Delphi XE2 IDE stopped working.  You could press that magic key combination all day and nothing would happen.  It took hours to figure out what the problem was.

I had installed update 4 for Delphi XE2, which contained, among other things, something called AQTime.  This appears to be some kind of application profiler.  Anyway, it was AQTime that was interfering with class completion.  A quick trip to Control Panel to uninstall the offending bit of software and everything went back to normal.

Never build package %s must be recompiled

March 18th, 2012

I was recompiling my application they other day, switching everything from Debug to Release.  Suddenly I started getting “Never build package %s must be recompiled” errors.  I couldn’t understand this, since the previous step in the recompile had just finished compiling the package in question.

It finally turned out to be caused by recompiling the Release packages into a different directory than the Debug packages.  The Debug packages went into Delphi’s default DCP and BPL directories while the Release packages went into the projects ($Platform)\($Config) directory.  I did this because the packages in question contain Delphi components that appear in the component toolbar and I want to be able to step into the source for those packages while debugging.  I thought that compiling the Release packages to a different directory would solve all kinds of problems related to debugging.   And it did, but it created these errors when compiling for Release.  It was the order of directories on Delphi’s search path that caused the problem.  The Delphi wide options specify the default package directory early on in the search path.  Even though I had the Release directory on the project’s search path, the Release DCPs were never found, because the Debug DCPs were found first.  Since I was compiling the Release packages to ..\$(Platform)\($Config) all I had to do was add that to the Delphi wide search path before the default DCP directory and the problem was solved.

How to Rename Administrator Account on Windows 2000

December 15th, 2011
  1. Start the Active Directory Users and Computers snap-in.
  2. In the console tree, right click your domain or the organizational unit that contains the group policy that you and and then click Properties.
  3. Click the Group Policy tab, select the group policy object that you want (Default Domain Policy) and the click Edit.
  4. Expand Computer Configuration, expand Windows Settings, expand Security Setting, expand Local Policies and the click Security Options.
  5. In the right pane of the Group Policy snap-in double click Rename administrator account.
  6. Click to select the Define this policy setting check box and then type the name to which you want to rename the Administrator account.
  7. Click OK.

Issues with IE8

December 6th, 2011

I have found that <DIV overflow-y: scroll> in IE 8 with Compatibility View enabled does not work properly.  The content that overflows the DIV continues to be rendered outside of the bounds of the DIV.  The solution to the problem is the disable Compatibility View.  To do that click the Tools menu in IE and uncheck Compatibility Views.

Providing an Automated Response to NET USE prompts

December 6th, 2011

If you have ever had to the use Windows NET USE command in a batch file, like I have, you will have noticed that occasionally it will notify you of some potential problem and then hang waiting for a response from the user.  This is aggravating but OK if you are running the batch file while you are sitting at the console, but it is a disaster if you are running the batch file in the background (as a scheduled task for instance).  In the latter case, the batch file just sits there forever waiting for a response that will never come.

It turns out that there are two undocumented options for the NET USE command that will automatically answer those annoying messages with a fixed response.  The two options are /Y and /N.  These options will respond to all prompts with Y or N respectively, allowing the batch file to continue.

Delphi, Firebird, IBObjects and Transaction Management

November 17th, 2011

I recently had reason to revisit transaction management in our application.  The application makes extensive use of data aware grids (TDBGrid) and, as I am sure everyone is aware, it is impossible to explicitly manage transactions when you are displaying data in a grid.

Fortunately, IBObjects provides the means to automatically clean up transactions left hanging by TDBGrid.  Unfortunately, this isn’t as well documented or as straightforward as I would like.  So, after much research using the programmer’s secret weapon (Google) and a few questions posted to the IBObjects support group (thanks Jason) I think I finally understand how it works. Read the rest of this entry »

The Mystery of the Disappearing Icon

November 3rd, 2011

I just finished creating a new custom control for Delphi.  I’ve done this dozens of times in the past and never had a problem until now.  This time the control’s icon simply would not appear in the tool palette.  No matter what I did, all I got was the default icon.

It turns out, that the first time I installed the component I had a problem with the DCR file that held the icon, so Delphi installed the control with the default icon.  Perfectly reasonable.  However, Delphi keeps a cache of custom controls that have been installed and, apparently, no matter how many times you uninstall and reinstall, it remembers certain settings (like the icon) from the cache.  To fix this problem, you need to manually edit the registry and remove the offending cache items.  To do this:

  1. Uninstall your custom control from the Delphi IDE.
  2. Open the registry editor (regedit.exe).
  3. Browse to HKEY_CURRENT_USER\Software\Embarcadero\DBS\9.0\Package Cache.  Where 9.0 is the version number for Delphi XE2.  Your version number may vary.
  4. Delete the key MyCustomControl.bpl where MyCustomControl is the name of your custom control’s package.
  5. Browse to HKEY_CURRENT_USER\Software\Embarcadero\DBS\9.0\Palette\Cache.
  6. Delete the key MyCustomControl.bpl where MyCustomControl is the name of your custom control’s package.
  7. Reinstall your custom control as your normally would.

Hopefully, the proper icon will now appear in the tool palette.

Delphi Compiler Versions

October 25th, 2011

If you ever need it, here is the list of Delphi compiler version numbers:

Compiler CompilerVersion Defined Symbol
Delphi XE5 26 VER260
Delphi XE4 25 VER250
Delphi XE3 24 VER240
Delphi XE2 23 VER230
Delphi XE 22 VER220
Delphi 2010 21 VER210
Delphi 2009 20 VER200
Delphi 2007 18.5 VER185
Delphi 2006 18 VER180
Delphi 2005 17 VER170
Delphi 8 16 VER160
Delphi 7 15 VER150
Delphi 6 14 VER140
Delphi 5 13 VER130
Delphi 4 12 VER120
Delphi 3 10 VER100
Delphi 2 9 VER90
Delphi 1 8 VER80

To make use of this information in a Delphi program you can define conditionally compiled bits, like this:

{$if CompilerVersion >= 20} // Delphi2010 or later



{$ifdef VER200} // Delphi2010


Allowing Remote Control Without Showing An “Allow Access” Prompt

October 5th, 2011

Sometimes, it is useful to be able to remote control a session on a Windows terminal server without having to have the user respond to a prompt asking whether or not it is alright to allow you to take over control of his or her session.  This is particularly true if you need to take over the console session as there often isn’t anyone standing at the console to respond to the prompt.

To allow this to happen you need to change the setting of a group policy.  The location and name of this policy varies depending on the version of Windows that you are running.  In all cases you have to begin by start the group policy editor (gpedit.msc).

Windows 2008 R2

  •  Expand Computer Configuration, Administrative Templates | Windows Components | Remote Desktop Services | Remote Desktop Session Host.
  • Click Connections.
  • Right click Set rules for remote control of Remote Desktop Services user sessions and select Edit.
  • Click the Enabled radio button and under Options select Full Control without user’s permission.
  • Click Apply.

SQL Server Permissions - Aaarrgghh!

August 11th, 2011

I recently ran into a situation where I could attach to our SQL Server server but had no permission to do anything.  I couldn’t create a database, couldn’t change my permissions to allow myself access, nothing.  I couldn’t even attach to the server as sa because we were configured for Windows authentication only.  It seemed as though I was well and truly screwed.

A little (a lot actually) time spent with the programmer’s secret weapon, Google, revealed the solution.  It turns out to be a long and involved process but basically you need to enable both Windows authentication and SQL server authentication.  Set up a new sysadmin user that you can use to fix sa and then, finally, give yourself permission to do what you need to do. Read the rest of this entry »