Archive for the 'Microsoftish' Category

Note: I've reorganized this site to use tags; the category archive remains to support old links. Only posts prior to April, 2006 are categorized. Tag Archive »

It’s Never too Late to Fix Bugs

Time once again to mention my dirty little secret… yes, I’m a Visual Basic programmer. Of course, I also do alot of Perl, and I’ve done my share of Java, but much of the software I’ve written in the past 10 years has been VB, starting with VB3.0 (I did play with VB 1.0, but not for work). My current major project at work is mostly implemented in VB6.0 (service pack 5) because of the requirement to interact with the Excel and Word application binaries.

Why do I bring this up now? Because Microsoft has released Service Pack 6 for Visual Studio, which includes updates for VB6, VC++ 6, and SourceSafe. I took a look at the list of VB bugs addressed by this update, and found a couple that make this upgrade worthwhile for me.

Knowledge Base article 297112, “BUG: Visual Basic Compiler Pads Embedded Resources to Align on 32-Bit Dword Boundaries”, is an old friend of mine. I have an application that makes use of a number of XSLT stylesheets and W3C Schema Defs (XSD). In order to ease deployment issues I decided to load these documents into the app’s DLL as resources. When I tested this, some documents would work, but others would not. At the time (a couple of years ago), this article was not in the KB (or at least, I was unable to find it. Fortunately, I was able to work out the solution on my own. Every now and then, I forget to check the file sizes when build a maintenance release, and run into the problem again. Nice to see it’s finally being addressed.

The other fixed bug that caught my attention is KB Article 312218, “BUG: Deadlock in Multithreaded Process If You Use Declare Statements for APIs in Visual Basic ActiveX .dll Files or .ocx Files.” The short version is this: VB6-authored DLLs which use the Declare statement to access API functions can deadlock things like IIS and MTX. If you’re using such a DLL under IIS, it’s running under one of these two executables. I don’t know how long this problem has been documented, but it may be the answer to many untraceable, non-reproducable issues I’ve had. The problems occur on a production IIS webserver that uses a custom COM component written in VB6 for mainframe access. I think I’ll be putting a new build into production soon. This one really ticks me off, since it I’ve been having these problems for a long time, and since it affects such core techonologies… the ones Microsoft spent so many years convincing me to use (before .NET came along and changed the rules. Again.)

If you, like me, have any ongoing interaction with VB6 or VC++6, give this service pack a look. If not, well, congratulations.

UrlGetPart, and the Parts it Won’t Get

This is a narrow post. If you don’t understand or don’t care, do skip it (you won’t be missing much). For the rest, and for the search engines, here’s some trivia.

There are a bunch of handy functions in the Win32 Shell API for handling file paths and URLs, provided by SHLWAPI.DLL. One of these, UrlGetPart, is described thusly:

Accepts a [sic] URL string and returns a specified part of that URL.

Very handy function, until you realize that the one part of an URL you can’t specify to be returned is the path. For example, in the (fictitious) url:

http://bond:007@example.com/topsecret/martini.cgi?method=shaken+not+stirred

I can use UrlGetPart to retrieve the scheme (http:), the username (bond), the password (007), the host (example.com), and the query (?method=shaken+not+stirred), but I cannot retrieve the path (/topsecret/martini.cgi).

So, How do extract the path from an URL using UrlGetPart? You don’t. Instead, use InternetCrackUrl, in wininet.dll. If you need to do this from VB6 (and this may work with VB5, but I’ve not tried it), take a look at this helper class, which also supports a few other handy URL-handling functions.

I have now officially seen it all

Pac-man, written in Microsoft Excel. (via 0xDECAFBAD)

There are no words.

Word to Your Mama

Much to my woe and dismay, I’m writing a significant amount of new code on Windows again. I’m extending a reporting engine I wrote about a year ago at work, that generates Excel reports from XML data, to also create Word reports. This is my first foray into the Word object model. I’ve worked extensively with the Excel object model; if the WOM is even half as buggy as the EOM, I can’t be held responsible for my actions.

I’ve been looking for a good book on the subject. Good meaning it spends more than 25 pages on the object model before refering you to the help(less) file. There are none. Nada. Zip. There may have been at one time; I’ve found a few promising titles on Amazon… all out-of-print. I don’t have a couple of weeks to wait; so Half.com and it’s ilk are out. Guess I’ll just have to do it the old-fashioned way… slog through the lousy MS documentation, the object-browser, and some test code.

As long as I’m whining, here’s some more. There are a couple of books I’d like to take a look at which are O’Reilly books. I thought I’d be clever and look on Safari Bookshelf. However, neither is available on bookshelf. The books were published in ’98 and ’99, so they aren’t ancient. I just can’t win.

I sent an e-mail to the feedback alias for Safari Bookshelf. The basic gist of the reply is that it is the Publisher, and not Safari Bookshelf, who decide what to publish, but they will forward my suggestion. Gee, that’s swell of them, but isn’t Safari owned by O’Reilly? At least in part? At any rate, I think O’Reilly is a great company; hopefully they’ll get this worked out.