Category Archives: software

image

Delphi and Windows Installer: small problem, fiddly solution

A Windows technology I love to hate is the Windows Installer, the setup engine built into Windows that is hard to avoid if you want to comply with Microsoft logo requirements and system management tools.

I have a little application which uses this, which uses a custom action written in Delphi. Originally this was an executable with some command-line arguments, which worked fine except that occasionally the custom action needs to show a dialog. Sometimes (not always) this would show up behind the main setup window, causing users to think that setup had hung.

Incidentally, I saw this exact problem when installing Delphi itself on Windows Vista.

It is all to do with a long-standing and complex Windows issue concerning whether applications can force a window to be on top of other windows. In a nutshell, a well-behaved application should not normally do this, though it can make itself flash in the taskbar. Not a great user experience. However, you can ensure that a window is on top within a specific application (in this case the setup), provided you know the handle of that application’s main window. Unfortunately there is no obvious way to get this value, other than via an API called FindWindow which might occasionally find the wrong window, for example if the user managed to open two instances of the setup.

The correct solution for this is not to use an EXE as a custom actions, but rather to use a DLL. This runs in-process with the setup, which enables it to call MSI (Microsoft Installer) functions like MsiProcessMessage, enabling it to show dialogs safely. You can also do useful things like writing entries to the installer log. (Thanks to Mike on the Microsoft.public.windows.msi newsgroup for this tip).

Therefore I converted the custom action to a DLL. Not too difficult; but I discovered that the Windows Installer is not especially flexible about calling custom actions in DLLs. The only argument it can (and must) give is a handle to itself. That’s unlikely to be enough. So how do you pass data to your custom action?

If you use an MSI editor such as that in Visual Studio, you will see a property called CustomActionData which you can set when calling a custom action. All this does is to set a property within the installer. Your custom action can then call MsiGetProperty to retrieve the value. It is a single string; if you want to pass several values, you need to use some sort of delimiter and parse it within your custom action code.

Although many Windows API functions have Delphi wrappers built into Delphi’s runtime library, the Installer functions are not among them. I hate reinventing the wheel, so I searched for a Delphi wrapper for msi.dll. It’s not easy to find, suggesting that few developers have gone down this route, though it is part of some versions of the Project JEDI JCL (JEDI component library). In the end it was easier to find the header files in the SDK and do my own wrapper for the few functions I needed.

Delphi is a great tool, but at times like this you realise that there is a price to pay for not falling in with the crowd and using Visual C++. All the low-level Windows API documentation assumes that you are at least using C++.

The good news: it all works fine. Dialogs appear reliably above the setup window, and access to the MSI API may prove useful for other things as well.

That said, it all goes to demonstrate why developers sometimes take ages to fix seemingly simple problems.

 

Technorati tags: , , ,

Sun’s J2EE certification may be too slack

In a series of blog posts here and here, Compuware’s Andrei Iltchenko writes about incompatibilities between different vendor implementations of J2EE. He works on the OptimalJ MDA (Model Driven Architecture)  product which generates Java code from language-independent application models. He found unexpected inconsistencies between Sun-certified J2EE application servers, for example:

When we started testing our code generation modules for J2EE web services on one vendor’s application server, we were in for a big surprise. The application server had a non-XML Schema aware web services stack, which effectively meant no proper support for WS-I Basic Profile. Why wasn’t such a major omission caught by SUN’s compatibility test suite for J2EE 1.4?

I was also surprised by his comments since in general Java’s cross-platform, cross-vendor compatibility strikes me as much better than it was in the early days. No doubt Iltchenko stresses this more than most developers, but note his conclusion:

With the differences in implementing the same J2EE 1.4 features I described, one should probably start questioning how feasible it would be to maintain a J2EE 1.4 application that needs to run on more than one application server and not be rigged toward a given vendor.

Technorati tags: , , ,

Tube trains show off Windows Presentation Foundation

If you have any interest in .NET Framework 3.0 I recommend this keynote presentation, from Microsoft’s UK developer launch for Vista and Office last weekend. It was given by Sanjay Parthasarathy, Vice president of the Developer and Platform Evangelism Group at Microsoft Corp. He reiterates the themes Microsoft watchers will have heard before: unifying designer and developer, SOA (Service Oriented Architecture), Office as a platform, Enterprise mashups and so on. I’d advise skipping forward to about 38.30 and viewing the presentation given by a couple of developers from the London Underground on their WPF (Windows Presentation Foundation) application for managing the network.

The London Underground is a busy network, clocking up 971 million passenger journeys last year. The WPF app is a real-time visual presentation of its status, based on the familiar tube map. There are “teardrop” indicators which show where there is congestion, technical problems, crime or other incidents. You can click an indicator to open a detailed panel, and dock the panel to get live update. All the data is driven by web services. Everything zooms and drags; you can show or hide specific lines and indicators; and finally there is an amazing 3D view which seems to model the entire system so you can access a report on any part of it with a click. Of course there is an option to see little trains chugging round and stopping at lights; how could this fail to enthuse developers?

The claim is that WPF/XAML combined with SOA makes creating this kind of application much easier than in the past (the whole thing is an XBAP – browser-hosted WPF).

I certainly found the demonstration thought-provoking. This particular case study is a great fit for a highly visual presentation, but to what extent does this also apply to the mainstream business applications that occupy so much developer time? What about the danger of prettification – highly visual apps that are slower and harder to use than the simple GUIs they replace? That app you are working on right now – would it benefit from a WPF redesign?

If you have any insights or comments on the above, I’d love to hear them.

Slow Outlook 2007: the comments keep coming

Comments to blogs are less visible than the blogs themselves, especially to feed subscribers, yet they can be equally or more interesting than the original entry. Since I blogged about Outlook 2007 performance problems, the comments have kept on coming. Here’s the latest:

I can only say that my Outlook 2003 was OK, but after upgrading to 2007 its just been insanely slow. I can barely write an email, Outlook will hang while I type. Unbelieveable that my ten human fingers are faster than a computer capable of doing millions of calculations per second … I am wasting 2+ hours daily waiting for Outlook.

Why do users care so much about Outlook? Maybe because it is where they live; email, contacts, appointments, everything is there.

 At least, it is where they live at the moment. Nobody can afford to waste 2 hours a day on slow software.

I realise that not every Outlook 2007 user is affected – just the ones with the largest mailboxes. These are the people who use Outlook most intensively. Microsoft should give this urgent attention.

MySpace, Microsoft and scalability

I was impressed when I learned at Mix06 last year that MySpace runs on Microsoft’s platform. After all, MySpace is one of the top 10 busiest sites on the web (currently 6 according to Alexa), and stuffed with dynamic content. So it makes a great case study for Microsoft.

Or does it? The downside of being so prominent is that problems with MySpace reflect badly on Microsoft’s platform. Thus you get articles like Larry Dignan’s MySpace: IT On a Wing and Microsoft Prayer.  

The article Dignan references describes how MySpace has coped, just about, with unexpected and explosive growth. It’s been a ragged evolution, and sounds more like a desperate attempt to keep pace than smooth upscaling. That said, this is more a characteristic of the particular scenario – web site copes with unexpected growth – than a characteristic of the Microsoft platform as such. However it is apparent that 32-bit SQL Server 7.0 was really not up to this level of scalability, and by all accounts even 64-bit SQL Server 2005 is being pushed to its limits.

Two bits of context here. First, the majority of software projects have far more modest requirements than MySpace. Second, there are other scalability examples, such as Microsoft’s favourite case study the London Stock Exchange, which runs smoothly enough as far as I know. Smaller than MySpace, of course, but business-critical in a way that MySpace will never be. On balance it seems that Microsoft’s platform is scalable enough for most of us. That does not mean that it is the best choice, or the most cost effective, or the more reliable. It just means that muttering “it doesn’t scale” is not the potent argument that perhaps it used to be.

Technorati tags: , , ,

Word 2007 clipboard slowdown

Office 2007 is a great piece of work, but there are some annoyances. Here’s one. Ever tried to grab some text from a web page and paste it into Word? I do this, using IE7, and often experience an irritating delay of up to 30 seconds or so, during which time this message appears:

“Contacting the server for information. Press ESC to cancel”. If you press ESC, nothing gets pasted. If you let it do its thing, then eventually your text gets pasted, by default with some attempt to preserve layout. I almost always just want the plain text, so I select that from the little paste menu that appears (the last vestige of smart tags).

What’s going on here? Well, the Windows clipboard is a complex and ancient Windows feature. When you copy something to the clipboard, applications may place data there in several different formats. Creating all these different formats can be an expensive operation, so there is also an option for the recipient application (client) to query the sending application (server) dynamically. In other words, the paste operation might initiate a conversation, instead of just grabbing some data and inserting it into a document. It wouldn’t astonish me if it still uses DDE, the forerunner to COM from the days of Windows 3.1.

If the paste operation is complex, you can forgive a little delay. But Word 2007 now lets you specify a default paste, which I have set to plain text. I’m confident that IE7 puts plain text on the clipboard as soon as you copy. In fact, you can prove this by copying something in IE7, then pasting into Notepad, which only understands plain text. It appears instantly. Then switch to Word 2007 and repeat the paste. You still get half a minute delay, before the text appears.

The explanation must be that Word 2007 gets all the complex formats first, and only then pastes the plain text. In consequence, even if you only want the plain text you nevertheless have to suffer the delay. The only way round it is to use Paste Special and select plain text from the formats on offer.

I guess it might be possible to write a macro to do this and attach it to a keyboard shortcut. Perhaps I’ll investigate when I get a quiet moment.

Technorati tags: , ,

Vista, Office 2007 changes: cosmetic, or not?

This is the statement that most intrigued me in Walter Mossberg’s review of Office 2007:

These changes in Office, while much less publicized, are far bolder and more important than the mostly cosmetic user interface changes in the highly hyped new version of Windows, called Vista, which comes out on the same day.

Mossberg’s reviews are not deeply technical but he represents a good example of intelligent opinion on technology issues. Is he right about Vista? I’ve puzzled a bit over what he is saying here. I think he is only referring to the user interface, yet one could argue that all user interfaces are “cosmetic” since they are about appearance in contrast to underlying functionality.

My own view is that it is difficult to describe the user interface changes in Vista as cosmetic, though I am unclear how to define what is “user interface” and what is not. This is from an MSDN article on the Desktop Window Manager:

The new Microsoft Windows Vista desktop composition feature fundamentally changes the way applications display pixels on the screen. When desktop composition is enabled, individual windows no longer draw directly to the screen or primary display device as they did in previous versions of Windows. Instead, their drawing is redirected to off-screen surfaces in video memory, which are then rendered into a desktop image and presented on the display.

That said, the user just sees windows on the screen: it is not obvious that this is so different from XP. That makes Vista’s UI changes the opposite of “cosmetic”: it looks the same, but underneath it is radically different.

How about the little search box at the bottom of the Vista Start menu? A small detail, yet once you learn that you can start Excel just by typing “ex” and hitting Enter, it becomes a big deal. I could ramble on here about search as UI. Not cosmetic.

Another change which I think falls in the UI category is that Vista now treats the user’s home directory sensibly. I ranted about this on XP. The home directory is a key part of the Windows operating system, but on XP it is hidden under Documents and Settings and both hard to find and intimidating for users. Vista promotes the home directory to the Start menu, renames the obscure Documents and Settings to “Users”, and sensibly moves things like Music and Pictures out of My Documents to the top level; it also gets rid of the annoying “My” prefix. You could argue that this is a cosmetic change, though I think it is an important one.

For sure, there are cosmetic changes in Vista. I think transparency, which Mossberg or any user will soon notice, is an example. Cool, but of little practical benefit as currently implemented. What about the way that Window key – Tab displays a 3D view of all your open applications (the update to Alt-Tab)? Is that cosmetic? Actually, I don’t think it is. If you have, for example, multiple documents open in Word and Excel, seeing the preview image makes it easier to find the one you want. The same applies to the pop-up previews on the task bar. This is information the user interface did not give us before. My vote: Not cosmetic.

I like Mossberg’s take on the new Office UI, though I still think there is more than just usability behind Microsoft’s strategy here. Yet I am still using the same Office features that I used in Office 2003. The changes are do with appearance, not functionality. Doesn’t that make the new stuff in Office 2007 more “cosmetic” than those in Vista, important though they are?

Why does Vista think my documents are music?

One especially memorable Microsoft bug was in Word 97. You would be typing away, and then Clippy popped up with a balloon saying “It looks like you’re writing a letter.” Invariably you were not. The phrase is referenced over 9,000 times on the Internet according to Google, proving that this blunder has indeed passed into tech folklore.

I guess some team put considerable effort into Clippy and thought it was making life easier for non-technical users.

I was reminded of this when I noticed Vista had decided that my Documents folder contained music. I’ve fixed this folder now, but I found another one to illustrate this blog. I promise I did not configure this manually; Vista did it all on its own:

As you can see, Vista’s Explorer is presenting a folder which happens to contain some Java code as if it were a music folder. There are options to play the files, or burn them to a CD, though I don’t suggest you try. It is actually fairly annoying. When I first hit this problem, I wanted to see the file sizes and dates. I realized it was a View problem, so I hit the View dropdown. I set it to Details, no joy. I tried Organize – Folder and Search options. Lots of options, none any use. The solution is to right-click one of the files and choose Customize this folder. Then you get a dropdown where you can set the folder type. All Items works fine for me.

Just an annoyance, no big deal. It’s disappointing though. Two obvious questions:

  • Why is Vista automatically setting folders as Music when they don’t contain any playable files?
  • Why doesn’t the View menu help me to view the files differently?

It reminds me of Clippy because it is another example of software trying to be over-helpful, and ending up obstructing rather than improving the user experience.

In closing, let me say that I prefer Vista to XP for all sorts of reasons, and software compatibility is proving less of a problem than I’d expected. And good user interface design is very, very difficult. So take this in that context.

Technorati tags: , ,

XNA, XBox 360 and the decline of computer science

I promised some more comment on the conference on XNA game development last week. It was a fascinating event, not so much because of sparkling content (though it was good), but because of the underlying themes. This conference was for the academic community, both students and lecturers. The idea was to promote the adoption of XNA on computer science courses. Presenters included members of Microsoft’s XNA team, Nick Burton who is a graphics programmer from Rare, and Peter Molyneux from Lionhead.

XNA is Microsoft’s new framework for games development. It is a .NET wrapper for DirectX, and a replacement for the earlier Managed DirectX libraries. You can create games for both Windows and XBox 360. The initial target is student and hobbyist developers, and the development kit is free except that to deploy to an XBox 360 you have to join the XNA Creator’s Club, for a modest subscription fee. Even then, you cannot distribute your 360 game except as source code to other club members; you would need to find a publisher or get the game on XBox Live Arcade. A future XNA studio product is planned which will target professional developers.

There is an obvious benefit to Microsoft if it can establish XNA in universities. It gets students familiar with the Visual Studio/Windows platform and helps foster the next generation of Windows and XBox 360 game developers. But what’s in it for the universities?

Here the context is important. There is a crisis in computer science, with dramatic falls in the numbers of students applying for courses. I spoke to Rob Miles, lecturer in computer science at the University of Hull. “The number of people applying to courses across the country has dropped by something like 40% over the last few years,” he told me. Including games programming in the syllabus is a bit of sugar to attract new students. “It will help me motivate students to want to learn to program,” said Miles.

Microsoft says XNA will help to address another crisis, this time in the games industry itself. Developing a game has become extraordinarily expensive. The industry has moved towards the Hollywood model of big-budget titles that can make or break their publishers. Gamers on the other hand complain of too many sequels, lack of innovation, and poor gameplay. Microsoft likes to talk up XNA as the future YouTube of games, recovering the community and excitement that was around thirty years ago, in the days of the BBC micro and other home computers.

Here XNA is competing with Flash, which already has a considerable community of game developers. XNA is vastly more powerful than Flash, but for small, easily deployed games Flash has many advantages including cross-platform support and browser integration.

Is XNA just another hobbyist game programming tool, likes others including AMOS and STOS (for the Amiga and Atari ST), or more recently DarkBASIC? There is a range of opinions here. Peter Molyneux enthused to me about XNA, saying it is “a fast, efficient, better language” than earlier more compromised tools, and “built with ambition in mind,” so that XNA programmers can create the next Populous (the game which made Molyneux his fortune).

On the other hand, Molyneux undermined his evangelism by also stating that C++ remains the language of choice for professional development. If this is the case, then XNA will always be a hobbyist niche, which implies that serious students of game programming should not waste too much time on it.

Not everyone takes this line. The Rare team has spent time with XNA and appears genuinely impressed with its capabilities. Nick Burton showed us both the dramatic reduction in code and the impressive performance of XNA code. While Rare is not yet using XNA commercially, it does expect to do so in a few year’s time. This might be some sort of mixed code, using XNA for game logic and C++ for graphics heavy lifting, or might be pure XNA. A factor for Rare and any professional game studio is the extensive C++ code library which it has built up over the years, which makes any quick move to another platform out of the question.

My view is that the productivity win makes XNA or something like it inevitable in games development at every level. Timing is another matter, and C++ will be hard to shift.

Finally, a couple of hot snippets of game gossip. One is that Rare is working on a Live Arcade title. I got the impression that it is fairly well advanced, though nothing is yet formally announced.

The other is that Molyneux talked up innovation in Fable 2. He told me that it has an unique and surprising feature which he had to fight to include, and which will be unveiled in March at the Game Developers Conference in San Francisco.

Microsoft’s XNA site is here. Note that if you want to develop in XNA, you are well-advised to get hold of the wired XBox 360 controller. It is a decent controller and works nicely with XNA both on Windows and 360.

Technorati tags: , , , , , ,

Installing XNA Game Studio Express on Vista

Yesterday I attended a conference on XNA game development. More on that soon; but first a quick note on what happened when, fired with enthusiasm for XNA, I installed the release build of XNA Game Studio Express on Vista.

At least I tried. You have to install Visual C# Express first (since for some reason XNA does not work with the grown-up Visual Studio 2005). That’s OK since it works side-by-side. Visual C# Express went on OK, but setup for XNA Game Studio Express failed towards the end of the install with an error about a file that could not be run. The install then rolls back completely leaving you with nothing.

I ran msiexec with logging to see more detail. Here it is:

Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. Action: RegisterWithCSExpress, location: E:\, command: “C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\VCSExpress.exe” /installvstemplates

It occurred to me that even an install without the templates might be of some use, or perhaps I could manually install the templates. So I ran up Orca (MSI editor), opened the InstallExecuteSequence table, and deleted the RegisterWithCSExpress action (yes, I’ve wrestled with MSI before).

The hacked install ran OK, and to my surprise the templates were present. This might be because of the earlier failed install, or because I also ran:

VCSExpress.exe /installvstemplates

from the command line. This command, which tells VC# Express to refresh its template cache, is the one that fails. On my system it causes VC# Express to crash, which is why it trips up the XNA install, but it appears to install the templates before it crashes so it is kinda OK.

My official advice therefore is not to try and install XNA on Vista, but the above may help if you are determined.

Microsoft knows about problems with Visual Studio on Vista; we are promised a “Vista Support Update” next year. In the meantime it does mostly work if you run it with elevated permissions.

I noticed that the Microsoft folk were running XNA on Vista yesterday.