Category Archives: windows

Semi-documented APIs in Windows

There have long been complaints about undocumented functions in the Windows API which give Microsoft’s internal developers an advantage over third-party software developers. Perhaps even more frustrating are those that are semi-documented. An example was found recently by a user of the htmleditor, a .NET wrapper for the HTML editor built into Internet Explorer. If you write an editor you might want to support undo and redo; there are simple undo and redo commands available but they are crude. The API also provides more advanced functions, including a change log and the ability to undo or redo entries in the log. You can find the documentation here; the relevant interfaces are IHTMLChangeLog, IHTMLChangePlayback and IHTMLChangeSink.

All looks good on a brief inspection; but note the lack of any sample code. Then think about how you might want to use this API. What exactly does an item in the change log represent – a single character, an HTML element, a paste operation, or what? How can you inspect the items (they seem to be a binary black box, understood only by an API function called ExecChange)? There is only one function for iterating through a change log, called GetNextChange – are you intended to cache the entries somewhere, since there is no GetPreviousChange or GetFirstChange? The API allows for notification of changes, but the Notify event has no arguments: presumably you are meant to call GetNextChange and do something or other with the log entry.

Of course developers have shrugged their shoulders and experimented a bit. Some have found Notify failing to fire, particularly with MFC. Others have just been puzzled. I tried it with my C# wrapper and got strange results; I think the only way forward would be to reverse-engineer the log entries to work out what it is they represent.

But what about Microsoft’s developer support? There are managed newsgroups, which are meant to guarantee a response for developers with MSDN subscriptions, as well as other online forums supposedly monitored by Microsoft developers – like Senior Program Manager Dave Massy, who says in his welcome:

Welcome to the MSDN forum for Internet Explorer Addon Development. If you have questions around development of extensions for Internet Explorer then this is the place to ask them.

Perhaps it is; but Massy is strangely silent on the intricacies of IHTMLChangeSink. I have seen this often: easy questions get a ready reponse either from Microsoft or from community members, but the tough ones, where only Microsoft has the answer, are simply ignored; or else there is a request for further information which looks promising at first but leads nowhere. Try Googling on this API; you will find questions but few answers.

My question is this: why bother publishing the API at all if it is so poorly documented and badly supported that nobody can figure out how to use it?

I would guess that this API is or has been used internally, by other Microsoft products that use the IE editor, and that somewhere in the bowels of Redmond there is proper documentation or sample code, perhaps not in sufficiently polished form for general release.

It’s time Microsoft either stopped pretending to offer developer support through these online forums, or put in the effort required to make them work.

 

Delphi 2007 is done

CodeGear says it has completed Delphi 2007, its RAD development tool for Windows. What’s notable about Delphi 2007? First, it’s Win32 only. Borland CodeGear hasn’t yet won over many .NET developers, so it took the decision to concentrate on native code in this release, although CodeGear is not abandoning .NET completely.

Second, it builds apps that work right on Windows Vista.

Third, there’s a new database API (CodeGear calls it an “architecture”) called DBX4; I’ve not investigated this yet. 

Fourth, it’s mostly binary-compatible with Delphi 2006 so that existing add-ins should work.

Fifth, it uses MSBuild (same as Visual Studio 2005), which is good news for anyone with a non-trivial build process.

Delphi 2006 was a huge improvement over the two previous versions (Delphi 8 and Delphi 2005). Version 8 was for .NET only, bypassed by most Delphi developers. 2005 brought .NET and Win32 together, but the IDE was barely usable. 2006 is pretty good; it looks as if 2007 may be better still. Although the feature set is not particularly exciting, the product is said to be faster and more reliable, which is what Delphi developers care about most. I will be reviewing the release shortly and will post links when available.

 

Technorati tags: , , ,

Software architects cautious about SOA; London Underground makes it work

SOA (Service Oriented Architecture) once seemed to promise a new world of smooth cross-platform and cross-language interopability, high software reuse, easier maintenance of complex systems, and clean wrapping of legacy systems. Has it delivered? I found the recent Microsoft Architecture Insight Conference surprisingly downbeat. Sam Lowe from Capgemini gave a brisk overview of where SOA is valuable, emphasizing that it is not always applicable, that its value is hard to prove, and that it often does not live up to its hype. “You need to think across business and IT”, he said, making the point that project roadmaps should not be technology-centric. It is no good rewarding people simply for creating services; if you do, you end up with lots of services for no clear reason. Too many services may be worse than too few.

All sound stuff. A second session from Conchango’s James Saull continued the theme in his “real world” session. It’s “very very rare” to see SOA success stories, he told us, following up with “I have never seen a business case for doing a service-oriented engagement.” One delegate immediately came up with one; but there was a fair amount of head-nodding as well. The supposed reusability of SOA services also got bashed. “I haven’t seen anyone to date really getting reuse,” said another delegate. Versioning and dependency issues were mentioned. The takeaway was not that SOA is useless, but rather that resources have been wasted in a mistaken belief in SOA as a solution to everthing.

It took a case study to bring relief from these depressing assessments. This was from the London Underground, the same WPF (Windows Presentation Foundation) application that I commented on earlier, but with a little more detail. I was not the only person impressed by this application; apparently the governor of the Bank of England, Mervyn King, paid the developers a visit to find out more about it. Although the project is only a proof of concept, there is great enthusiasm for it and a production version is actively being planned, though it will take until Q3 2007 before the 20,000 London Underground desktops are powerful enough to run it (.NET Framework 3.0 is required). Passengers may actually see station displays running WPF.

The London Underground application brings 3 or 4 systems together into one visualization. You can think of it as a kind of Enterprise mash-up. Although it is the user interface that catches the eye, it would not be possible without an existing investment in SOA, going back several years. It therefore appears that London Underground is getting reusability and other SOA benefits that are eluding most others. I asked what the secret was. The answer was a little vague. “We’re fortunate that we had the right services in the right place at the right time,” said developer Keith Walker. Peter Goss expanded on this. “We have four of five main services we use, but each of our large applications has an interface exposed which we can consume from if necessary. It’s an ongoing process.” In other words, every application was designed to be part of a platform, not just to work in isolation.  There was the right level of granularity for the services, which matched the business well.

Here at last is an example of SOA yielding perhaps unexpected benefits, presuming that the proof of concept does translate successfully into a deployed application. For more background on this case study, download the presentation referenced in my earlier post.

So what does it take to be successful with SOA? It’s hard to discern whether London Underground is just a particularly good fit for this kind of architecture, or whether it happens to be using development principles that would work equally well in other contexts.

 

Visual Studio 2005: still needs admin rights on Vista?

It was good to see – at last – the release of Visual Studio 2005 Service Pack 1 Update for Vista.

I was hoping this update would remove the need to run Visual Studio 2005 with administrator rights on Vista. Unfortunately I don’t think it does. It’s hard to be sure; in fact, I can’t find any clear statement about what the “Update for Vista” actually does. Following the “more information” links on the download page is like playing the original Adventure game – a maze of twisty little passages, all alike – none of which tells you what you want to know.

Still, I note that the list of bad things which happen when you run with normal permissions still exists; so I’m presuming Microsoft still recommends using “Run as administrator” for Visual Studio.

I dislike doing this. I don’t develop on Linux as root, nor on the Mac – why should it be needed on Windows? I realise that some things need local admin rights for good reasons – registering a COM DLL, for example – but I don’t see why I should have to run the entire IDE as admin just for the sake of those few activities.

How dangerous is it? I presume it’s no worse than running as admin on XP, for example, but it’s pretty bad. For example, I checked out what happens with online help if you use “Run as administrator” to start Visual Studio. Help opens in a separate application called Document Explorer, which embeds Internet Explorer to render the online documentation. As I expected, if you open this from Visual Studio’s Help menu it runs with elevated rights. Naturally, the docs include links to external web sites. What if you right-click one of these and choose “Open link in external window”? The site will open in IE, but take a look at bottom right. “Protected mode off”. In fact, IE is now running with a high integrity level, just like Visual Studio. Nothing to stop you browsing the web from here, probably not realising you are more at risk than usual.

It’s crazy to be reading documentation and browsing the web with full admin rights, just to keep Visual Studio happy.

I intend to try running Visual Studio as a normal user and see how it goes. I reckon it will work for some projects at least.

Note: if you want to see the integrity level of the processes on your system, download the latest Process Explorer. You’ll need to select the Integrity Level column. The ins and outs of UAC and the extent to which it protects you are discussed in Mark Russinovich’s blog entry on the subject.

 

Technorati tags: , , ,

What would the young Bill Gates make of today’s Microsoft?

He would be hacking (in a good way) with the crowd at the Future of Web Apps conference I attended two weeks ago, not here with a bunch of senior software architects discussing the failures and successes of SOA (Service Oriented Architecture). I’m at the Microsoft Architecture Insight Conference in Wales, where I’ve been hearing a lot about old-fashioned ideas like requirements analysis, making the business case for change, being realistic about software reuse, and other sound, sensible, but unexciting software development principles.

That’s not to say this is a bad conference, far from it. I had an excellent chat with Microsoft’s Jack Greenfield, a Microsoft architect who is putting together the next generation of Microsoft’s modeling and enterprise development tools for Visual Studio. “Software factories” is the buzzword – see here for more background on this. There is also good stuff on identity management within and beyond the firewall, sessions on using development methodologies in Visual Studio Team System; amigo Ivar Jacobson is here talking up his Essential Unified Process (though “process” is last year’s word; we do “practices” now); and a number of case studies including one on visualizing the London Underground network which I’m looking forward to later today – this is the amazing WPF application which was shown off at one of the Vista launches.

It’s easy to find fault with products like Vista or Office 2007; yet you have to give Microsoft credit for establishing .NET as a major platform for enterprise development against considerable JEE momentum.

That said, let’s go back to the young Bill Gates. There is a track here on SaaS (Software as a service), which seems to mean hosted, on-demand applications versus traditional premises-based development. We heard some research on disruptive technology which Microsoft is sponsoring in conjunction with the Manchester Business School, including a look at Siebel vs Salesforce.com for CRM (Customer Relationship Management). Here’s one facet that stuck in my mind. According to Dr Steven Moxley of the MBS, Marc Benioff’s first customers were not SMEs or start-ups, but groups within large enterprises that were frustrated by the shortcomings or inflexibility of their existing software. It was a kind of stealth adoption. Salesforce.com was able to sell to such groups because its software is zero-install, pay as you go.

I immediately thought of the times I’ve had phone calls that go, “Could you send that attachment to my Gmail account. Our email is playing up today.”

Gmail may be less feature-rich than Exchange; but it tends to just work.

In other words, you could as easily do Microsoft vs Google as Siebel vs Salesforce.com. Why is Microsoft sponsoring studies that articulate its own vulnerability? Officially, this is about helping its partners to grown their own distruptive solutions using Microsoft technology; but I also see this as evidence that Microsoft has abundant understanding of the difficulties it faces. What it lacks is any conherent strategy for overcoming them, though there are always hints that some such strategy will emerge sometime “soon”.

I think it might. Gates disrupted IBM; he didn’t topple it. But there is going to be some pain.

Postscript: See also this pertinent post from Zoli Erdos who is looking forward to ditching his desktop software, subject to finding a solution for a couple of unsolved problems:

My bet is on Google or Zoho to get there first. As soon as it happens, I’m going 100% on-demand.

 

IE7 phishing site confusion

Preparing for a conference, I saved the agenda from a web page to a file, so that I could read it on the train. I used the IE “web archive” feature, which saves a page to a single file with the extension .mht. When I re-opened the page later, I was suprised to see the following warning:

Local file identified as phishing site

Something wrong here I reckon. Apparently my own hard drive is a phishing site.

I suppose IE7 has a point. After all, I’ve copied the page from one place to another, and although it looks like a page on the web, it isn’t. Then again, it isn’t criminal either. I’m using a feature of IE exactly as designed.

Amusing; but the difficulty I have with these kinds of false alarms is that they undermine the real ones. How is the non-technical user to know which warnings they can safely ignore? The danger is that they end up taking none of them seriously.

 

Technorati tags: , ,

Got Paint.NET?

I am late with this; Paint.NET 3.0 was released at the end of last month. It deserves more publicity, since it is of high quality. If you have .NET Framework 2.0, Download it here.

The application is fine for general use; I may switch to it from my old favourite Paint Shop Pro, for trimming and touching up screen captures. One feature I like is the way it handles multiple documents. A thumbnail of each open document appears at top right, in a fat toolbar; click a thumbnail to switch to that document.

Paint.NET is particularly interesting for developers. It is written in C#, and started out as a design project; as I understand it, one of the intentions was to discover whether Microsoft’s .NET Framework was up to the task, given that image applications do a lot of intensive number-crunching. Most of the code is C# but not quite all. There is a shell extension written in C++ and some use of PInvoke and COM interop. I get the impression that the chief developer Rick Brewster is now more interested in creating an excellent application than in proving a point about .NET.

One point of interest is the user of multi-threading for optimized performance on multicore processors. Brewster has recently posted his performance tests on various processors from two to eight cores:

The 8-core system is frightfully fast, and it’s very clear that having rendering code optimized for multiple threads is a big win. However, I will be honest and state that the performance scaling is not at the level I was hoping for: we’re already seeing diminishing returns at this point! In general, I am seeing gains of about 3.0x on a quad-core system, and 5.1x on an 8-core system (compared to running with only 1 thread). Unfortunately, I do not have an 8-core Opteron system to compare against which might provide some more meaty information to chew on (does it scale better? worse?).

I take his point, though a 5.1x gain on an 8-core system strikes me as decent. I recommend downloading the source code and taking a look; it is well commented and has workarounds for various System.Windows.Forms annoyances. Before you ask the obvious question, Brewster recently commented in the Paint.NET forum that he has not yet looked at WPF (Windows Presentation Foundation).

 

Technorati tags: , , ,

Peeking into Vista’s virtual store

In the user data area in Vista is a virtual store. Find it at:

C:\Users\[USERNAME]\AppData\Local\VirtualStore\

It is worth having a peek now and again. Here’s part of mine:

The Virtual Store is a feature of User Account Control, the centerpiece of Vista’s enhanced security. Applications that try to write to protected system locations, including Program Files, Windows, and HKEY_LOCAL_MACHINE in the registry, are prevented from doing so. Instead, a compatibility feature kicks in, and these applications write to a location in your home directory. Registry entries are written to a special area in HKEY_CURRENT_USER. The application mostly won’t know the difference, though there are limitations and you can get strange results. For example, if an application deletes a file from the virtual store when a file of the same name exists in the real location, the delete appears to succeed but the file still exists. Virtualization also fails (by design) if the application is run under another user account, or using Run As Administrator. The files written to the first user’s virtual store are invisible to these other users.

Virtualization is a stop-gap measure. Well-behaved applications should not write to these locations except when first installed, or for maintenance, both of which are administrative tasks. So the Virtual Store is a hall of shame. Microsoft features heavily in mine; we can just about forgive the appearance of the beta Expression tools, but Visual Foxpro 9.0? Adobe’s Flex Builder 2 is another disappointment. In most cases there are only one or two files, so we are not talking about major design issues, but they still need fixing.

If you are developing software, it is worth checking your virtual store in case stuff is slipping through. Note that you must have UAC enabled, and not be using Run As Administrator, since either of these settings will prevent the virtual store being used.

Technorati tags: , , ,

Annoying Word 2007 problem: can’t select text

I run Word 2007 on Vista. Today I hit a curious problem. Word opened, but something was badly wrong. I could not select text with the mouse. The document scroll bar did not work. Word crashed on exit. And going into Options – Addins, I could not navigate beyond the “Popular” section.

After several crashes an Office Diagnostics wizard popped up and offered to help. Kind of it. It chugged through numerous tests and finally told me it could not see anything wrong. Never mind.

Checking the newgroups, I found fellow-sufferers but no solution. I decided to be methodical. I started Word in safe mode. (winword /a). It worked. Probably an add-in. I went to the COM add-ins and tried to disable them. Message: “The connected state of Office add-ins registered in HKEY_LOCAL_MACHINE cannot be changed”. OK, registry then. Navigated to:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\Word\Addins

Found three add-ins listed. I changed the value of the LoadBehavior key from 3 to 0 for each add-in.

Word now worked OK, but still crashed on closing. I found I could restore two of the add-ins without problems. The guilty party: OfficePrintAddIn, a component of Flash Paper.

I had a look at active templates. There was one called FlashPaperWordUITemplate.2302.dot. If I tried to unload it, Word crashed. Perhaps it needs the related COM add-in to be loaded. I closed Word, found the template file, and deleted it. Everything is fine now.

A quicker route might be to uninstall Macromedia Flash Paper, unless you use this of course.

I’m still puzzled about why this problem only showed up today. I’d not made any changes to Flash Paper or Word that I’m aware of. And I don’t blame Macromedia (now Adobe) for this; Word 2007 did not exist when this Flash add-in was released.

Posted in the hope that it saves someone else some time.

 

Technorati tags: ,

Microsoft Soapbox uses Flash

Took a quick look at Microsoft Soapbox which seems to be a me-too version of YouTube.

The first thing I noticed was the absence of any content I wanted to view, whereas YouTube is really dangerous if you want to avoid distraction. That will change if the service is popular; but I’m not clear why someone would use Microsoft’s service instead of YouTube which gets the traffic.

The second thing I noticed is that Microsoft is using Flash for these videos, as does YouTube. I gave it a cross-platform test, and was able to use the site on the Mac with Safari and on Linux with FireFox, so kudos to Microsoft for that. I’m puzzled though, because the system requirements state Windows Media Player 9 as well as Flash 8, and Windows Media Player 9 isn’t available for Linux. Nevertheless, it works.

That said, I’m surprised that Microsoft isn’t using SoapBox to show off WPF/E. I appreciate that this is still in beta, but then so is Soapbox. Does Microsoft not intend to use its cross-platform, video-capable solution for its own site? Or will it transition in future?

 

Technorati tags: , , ,