Author Archives: daniel

VB Garbage collection

This article claims it’s pointless to Set objects to Nothing in VB when you’re finished with them, except in particular cases. Maybe it’s those particular cases I’ve come up against, but I don’t believe that, myself. I’ve observed time and time again IIS apps that call VB6 DLLs grabbing more and more memory for DLLHost, and eventually choking until an iisreset has been done.

Going through the code (both the ASP VB Script and the underlying DLL VB) with a fine tooth comb and ensuring EVERY object got set to Nothing afterwards cleared these issues. Though I’m embarassed to admit that on one early project I worked on, a bunch of people looked through the code trying to find the leak, couldn’t find it, and someone eventually wrote a nightly iisreset batch job.

Reading that article, it occurs to me that maybe there was a case of destroying objects that referred to each other in the wrong order. The code is long sinced vanished, so I don’t know, and don’t care to find out.

As far as I’m concerned, it’s not only better for performance to destroy your objects, and a helluva lot easier to do all the time than just some of the time. It’s also tidier in the code. I’ll keep on doing it.

.Net, of course, is a different kettle of fish altogether.

MSXML HTTP Post: Access Denied error

In MSXML 4 SP2 (and later, I assume in advance) if you try to send Post data using the ServerXMLHTTP40 object to a site that’s in the Internet Zone, you get an Access Denied error.

This is another of those things that had me banging my head in frustration until I eventually solved the problem. Contrary to what you may first think, it’s not a bug.

It’s actually upgraded security in this release: it uses the IE settings, and if you try to send unencrypted Post data by HTTP to Internet zone sites, you run into trouble. Details are at the end of the readme for the SP2 release and in KB 820882, but the workaround given does not work in Windows 2000 because the MMC Snapin referred to is only in Windows XP.

Apparently now there’s a Windows 2000 hotfix you can get, but as with all hotfixes, it involves mucking about ringing up Microsoft PSS to get it. (And when it says “Applies to Microsoft Windows 2000 Standard Edition”… what is that, exactly? Maybe they mean Professional?)

You can also get into IE and change the zone settings, but it has to be the same user that runs your process. If the process is some kind of robot, it’s not always possible to do this.

Eventually I dug around in some MSKB articles and eventually found article 182569 that talked about how to change the relevant settings via the registry.

To tell Windows to ignore user-specific settings, and always use the zone setting you are about to define, create or edit the following Registry key:

HKEY_LOCAL_MACHINE; Software; Policies; Microsoft; Windows; CurrentVersion; Internet Settings; Security_HKLM_only (DWord value) = 1

The alternative would be to change the following setting for each user that will try and do the HTTP post, eg in HKCU/HKU instead of HKLM.

Okay, so to tell it to allow unencrypted HTTP Post data into the Internet zone:

HKEY_LOCAL_MACHINE; Software; Microsoft; Windows; CurrentVersion; Internet Settings; Zones; 3; 1601 (DWord value) = 0

See MSKB 182569 for more details.

Two Office snippets

I reckon it’s about time Word (and other Office products) figured out that those last few paragraph breaks at the ends of documents don’t need to be printed, especially if they cause an extra blank page to be wasted.

Yesterday I was trying to work out how to tell if an Excel cell has a value or a formula in it, so some conditional formatting could indicate if a value was calculated or entered by a human. Seems to be no built-in function to do it. But this seems to work, though I’m still trying to figure out how, precisely. The explanation at the bottom more-or-less explains it, but damn Excel 2003’s help, which has no index, doesn’t integrate its VBA help into VB6, seems to download everything (maybe it’s just the way I have it configured) and makes it near impossible to jump straight to the definition of GET and CELL.

Windows XP search

Windows XP Search isn’t quite as good as it first appears to be. Oh sure, it’ll find stuff in files… sometimes. After almost banging my head on the table wondering why it couldn’t find some file content I knew to be there, I initially wrote it off, guessing that it had problems with the Unix-style LFs I’d given it.

But no… a little more fiddling and I discovered that it ignores file types that aren’t registered in Windows. It doesn’t seem to say this on the search options anywhere, but I proved it by creating two identical files, one called textfile.txt and the other called textfile.randomextension. Searching for content I knew to be in both, it consistently would only find textfile.txt

Is this sensible? Is this right? Well okay, I can understand that you’d write a search tool that didn’t want to search particular types of files, for speed purposes. But why stop the user switching it to search everything? And why hide this fact so well? I can find no mention of it in the help or on the screens. Sure, you can search with an animated screen character (Clippy lives… almost), but how about looking in all files, and I mean ALL files?

Windows XP search results

Eventually I found a KB article that shows how to dodge around it:

309173: Using the “A word or phrase in the file” search criterion may not work. This lets you switch on searching for specified extensions, or to tell the Index Service to index absolutely everything, which I assume would burn up lots of disk space. There seems to be no way of searching everything on-the-fly without using Index Service.

Registering your weirdo extension as a text file doesn’t work. Renaming your file does. If there’s lots of them, you can always go to DOS and: ren *.randomextension *.txt then back again when you’re finished. (Windows XP Command Line Reference.)

And of course, there’s always DOS’s FIND "phrase" *.* >resultsfile.txt

Dictionary ads

I find dictionary.com to be a very handy resource. But boy are their ads annoying. And it looks like they’ve gone that extra mile to get their popup ads to dodge around Firefox and IE+Google Toolbar’s popup defences. (At least I assume it’s them, not some other site with popups sitting in the background).

Not to mention the fact that the popup ads are the worst kind – the ones that look to people of limited computer-literacy like legitimate system messages, for instance:

Fake warning

Oh sure, they have “advertisement” written in tiny tiny greyed writing in the corner. That makes it all better, doesn’t it. I wonder if Cancel actually closes it? (I clicked the X in the corner.)

Snippets

Hax0r gameshow contestant wagers $1337 on Jeopardy. (via Rick)

Gary Schare, Director of Windows Product Management at Microsoft, talks about the future of IE, its features and security. (Via Cameron Reilly)

Speaking of ADO (which I was yesterday), trying to figure out the black magic that is an OLEDB connection string? Try here.

Feel like writing a little C++ or Java applet for your phone? Here’s tech specs for Nokia phones. For me that’s the kind of project I’d love to do, but it will have to happen after I invent a time machine so I’ve got the time to do it in.

Empty recordset from MDB queries via ADO

Every so often I’ll find the solution to an obscure issue, and wonder “why isn’t this in the MSKB? Why has nobody written an explanation I could find in Google?” Well through this site, now I can do something about that.

If you call an Access (Jet 4.0) query via ADO/MDAC, you may get empty recordsets back if the query uses parameters. There’s a bug that Microsoft reckons applies to RDO calls, but also appears to affect ADO/MDAC 2.7 in the same way.

To fix it you need to define the parameter size to an arbitrary amount before you set the parameter. Here’s some hopefully useful (to somebody, somewhere, some day) sample code…

(This is VB6. Dim everything beforehand of course, ‘cos everybody loves early-binding. What, you want to play with fire by using late-binding and no Option Explicit? Silly you.)

Set oCommand = New ADODB.Command
oCommand.ActiveConnection = gcDatabase.Connection
oCommand.CommandText = "select * from MyQuery"

Set oParam = New ADODB.Parameter
oParam.Size = 255 'Take this out and you get an empty recordset back, but no error. Wacky.
oParam.value = "your value"
oParam.Name = "your parameter name"
oParam.Type = adYourFieldType
oCommand.Parameters.Append oParam

Set oRS = New ADODB.Recordset
oRS.Open oCommand, adOpenForwardOnly, adLockReadOnly

(and close and destroy everything when you’re done, natch. You know what VB6’s garbage collection is like.)

FileZilla oddity

FileZilla is my FTP client of choice. But it has one oddity: some files on the remote Unix system weren’t showing up — to be precise, .htaccess, which is pretty important in the web world, all things considered.

It occurred to me to check all the options to see if there was one that might be causing this. After all, a bug like that couldn’t continue to go unnoticed and unfixed, could it?

Sure enough… Edit -> Settings -> Interface settings -> Remote file list -> turn on “Always show hidden files”

Personally, I wouldn’t have made this the default, but then, there’d be a lot of things different if I ruled the world.