Monthly Archives: November 2007

Reimagining MsgBox

0
Filed under Code Garage, Software Architecture, VB Feng Shui

Here’s a little trick I’m not sure many people know about, but that I’ve used for so long, I’d basically forgotten about it.

I wrote about overriding the ERR object in VB here, and also wrote a far more involved article about it.

But did you know you can also override the MSGBOX function?

Just create a function with the following signature in a BAS module of your choice:

Public Function MsgBox(ByVal Prompt$, Optional ByVal Buttons As VbMsgBoxStyle = vbOKOnly, Optional ByVal Title$ = "", Optional ByVal HelpFile$ = "", Optional ByVal Context As Long = 0) As VbMsgBoxResult

Put the appropriate code in it, and presto, custom msgbox.

Why, you might ask?

  • Personally, I like the option of logging every msgbox that’s displayed by my app. Errs are handier, but msgbox’s can be useful.
  • In addition, you have the option of calling the MessageBox API call directly yourself, which gives you access to additional flags that you can’t use with the VB version alone.
  • You might also decide that the MSGBOX proper just doesn’t look good, and craft up a modal, nicely skinned form to stand in its place.
  • And finally, in a particular app I worked on, I needed to call a function BEFORE and a different function AFTER displaying every msgbox. I certainly didn’t want to alter every call to MSGBOX and add those extra lines. Overriding it made that a trivial task.

Please let me know if you come up with any good uses for this trick.

Vista and the Phantom Floppy Drive B

3
Filed under Uncategorized

Ok, yeah, it’s probably, um, quaint?, to even have a floppy drive in a Core 2 Duo based machine, but still, that’ no excuse for Vista to mysteriously change my floppy drive to Drive B.

You can’t fix this with the Drive Management dialog, and I couldn’t find any place else to assign a drive letter to the floppy. And there’s no jumpers on floppies, so what the hell?

On a whim, I opened up the Device Manager and started looking for any drive letter controls on the floppy devices.

There weren’t any.

But then, I started wondering if just uninstalling the drivers and letting “scan for new hardware” do it’s thing would work. It usually does for network cards.

So I right-clicked on each and uninstalled the drivers for both the Floppy Drive and Controller:

image

Then right clicked on my computer and chose “Scan for new hardware”. In reality, just rebooting would also work.

A few seconds later, I’m back in the land of the whopping 1.4mb Drive A floppy!

Hey, you can get about a second and a half of HD Video on one of those things. Awesome.

Setting up a USB Memory Stick to Boot in VMWare

1
Filed under Uncategorized

You might think such a thing would be insane to attempt. And why bother?

Here’s a shot of GParted (a Linux based partition editor) booted from a USB stick (in the host machine). It’s quite handy in that it seems to work about as well as Partition Magic. It’ll copy partitions as well.

image

The main reason for all this is that it’s awfully handy to test USB bootable key configurations from a VM instead of having to constantly reboot a real machine. And why a bootable USB configuration? Well, if you’re in IT, you often find yourself sitting at a machine that won’t boot or that needs to low level lovin’ to get it back on track. And things like GParted, Partition Magic, Partition Commander, or SysInternal’s NTFSDOS, not to mention SPintrite can be awfully handy to have swinging from a gold chain around your neck.

One caveat to this. Make SURE you DON’T access the USB key from your host machine while you do this. Doing so will likely trash the formatting on the key. You have been warned, young jedi.

Ok. Here we go…

Make sure you’ve inserted the USB Key and Windows “sees” it (doncha love that bong sound).

Start VMware (it will see the USB if it’s inserted, but it might not see it if you insert the USB key AFTER you’ve started VMWare).

Make sure the virtual machine in VMware is turned off.

image 

Click on the virtual machine settings and click Add:

image 

Choose “Hard Disk” from the device type list, then “Use a Physical Disk”, since we’ll be booting to the USB Key.

Here’s the important part. You should get a window like this:

image

See that drop down list with the PhysicalDrive0 in it? If you drop it down, you should see at least one other drive (Physical Drive 0 is typically the C: drive in your host machine, you DON’T want to use that drive!). In mine, it was PhysicalDrive5. Select which ever one is your USB Key drive.

And select “Use Entire Disk” (unless you’ve partitioned your USB Key drive).

Finally, give it a filename for the vmdk file (that’s a little config file that VMWare uses to keep track of what physical drive is mapped to what virtual drive).

Fire up the VM, and be quick about pressing F2. That’s how you get into the VMware bios for the vm.

image

It might take a few tries to get it, but eventually, you should get to the BIOS screen. Move over to BOOT and press Enter to expand the hard drive options:

image

On my system, that “VMware Virtual Scsi Hard Drive (0:0) entry was listed 3’rd. Use the “+” key to move it up to the top of the boot priority list.

Then save your changes.

If you did everything right, when you reboot the VM, you should boot to your USB drive.

How did I get GParted to actually be able to boot from a memory stick?

I’ve blogged about getting USB memory stick drives bootable here, and here.

But for GParted, there’s a little more wizardry at work. You’ll need to use fat32format to format the drive, then use SYSLINUX to make it linux bootable, then copy the GParted ISO contents to the stick. See the above links for details.

Finally, you’ll need to move a few files.

The root of the GParted image look like this:

image

Nav into the syslinux folder and move all the files there, down to the root of the drive.

Then nav to the boot folder, and move the gparted and gparted.igz files down to the root of the drive.

That should do it. Fire up a VM and give it the boot.

So what have you done with your USB key today? (absconding with company secrets doesn’t count, shame on you!)

No Nonsense Touch Utility

0
Filed under Uncategorized

I have to force timestamps so rarely, I just can’t justify spending money on such a utility.

But writing a little code to do it is annoying, so I went on a little hunt today to find a package that’s simple, quick and easy with little to no installation, drag and drop functionality (command line touch utils are a dime a dozen, after all), and straightforward date entry.

WinTouch fit the bill perfect for what I was looking for.

image

You can drag files to that top list box, set the date/time and go. It’s no Directory Opus, but then, it’s not 85$ either.

Unleash the Fury

0
Filed under Uncategorized

I’m generally not one to pass on those annoying joke emails, but this one (from here) I just can’t resist.

image

A Modern Undo

1
Filed under Uncategorized

I happened across an interesting post about Undo this afternoon.

The author is the guy behind “e – Textmate for Windows“, which looks to be a pretty slick little editor.

Now, I can’t say much to the editor (at least not yet, but I plan on taking a closer look).

But his comments on Undo struck me as particularly prescient.

I’ve had a nagging feeling for years that Undo (even of the “unlimited” variety that’s in just about every app out there now), was not really what it could or should be. The Undo Visualization is particularly nice, as is the idea of branching. I’ve seen something similar in graphics packages before (though I can’t remember which ones off hand). Never seen anything like it in a text editor or IDE, though.

His solution and implementation really points out the inadequacies of the typical modern undo. Granted, some of it might be a little advanced for a casual user. But for a casual user, the standard Ctrl-Z multi level undo should continue to work just fine anyway.

New Windows Live Writer Available

1
Filed under Blogging

I’ve blogged about Live Writer before. It’s an awesome offline blogging app from Microsoft, and it’s free! It can even read the style sheet of your blog and apply it while you write (mostly).

Anyway, looks like the first official release is out and it’s definitely worth the download. They’ve fixed the most irritating bug in the beta (having too many pictures in an entry would cause GPF’s), and so far, it appears very stable.

Even better, the new version will upgrade the beta in place. All my draft entries were preserved perfectly.

Grab it here.

Nested SQL Express Installation – Part Deux

3
Filed under Installations, SQL

I wrote about various troubles nesting SQL Express installations a few days ago here.

I just wanted to add a little more info for those interested.

Come to find out, it’s still possible for SQL Express to end up requiring a reboot, which, if you’re install was planning on performing DB tasks, puts a cold, wet, nasty damper on your fireworks quick.

But, from what I can tell so far, it’s almost always going to be related to a file or files that the SQLExpress install needs to replace but can’t because they’re locked.

I’d had some difficulty finding any info on how you might determine exactly what file(s) it was that were locked when I came across this post on MS Technet.

Basically, immediately after you install, but BEFORE you actually reboot, fire up REGEDIT and check out:

HKLM\system\currentcontrolset\control\sessionmanager\pendingfilerenameoperations

The value should contain the names of any files that couldn’t be replaced during the install and are queued for replacement.

At that point, it’s just a matter of determining which process(es) have those files open, and making sure your install verifies that those processes are closed before allowing the installation to continue.

In my case, so far it’s always been an issue with MSDE 2000 already installed a running on the machine. The SQLDMO.DLL is used and locked by the running MSDE process, but the SQLExpress install needs to replace it.

It’s a royal pain to be sure, but at least there is something that can be done about it.

Damn, I Gotta Get Into .NET

2
Filed under .NET, VB Feng Shui

I’ve been trying to make a point of reading more .NET code lately.

Maybe it’s Scott Hanselman’s Weekly Source Code.

Or maybe it’s that Code Project gadget on my Google home page.

At any rate, I just ran across a project there call LinFU (don’t ask what it stands for), but…wow.

It reminds me of the Black Belt columns by Matt Curland ages ago in Visual Basic Pro (or whatever it was called then, now Visual Studio Magazine). There hasn’t been articles like his in that rag for years. (and btw, if you still do VB6 and don’t have his Advanced Visual Basic 6, I’d highly recommend getting a copy).

Anyway, it’s stuff like Philip Laureano’s LinFU that really is making .NET seem more and more attractive.

So I Printed Out all the Internets Yesterday….

2
Filed under EMail, Rants

I was reading the latest ComputerWorld (Oct 29) and came across one of the best quotes I’ve seen in a while.

I’m not a huge fan of Grady Booch, but he has had quite the impact on IT. I just can’t stand UML.

At any rate, there’s an interview with him in this issue and at the end, he’s asked what has surprised him most in the last decade.

He responded:

“I haven’t seen any revolutions.Heck, I had my first email address in 1979. There was a printed document with everyone’s email address [in the world].”

Man, oh man, that’d be a sweet piece of tech memorabilia to hang on the wall.

Does that make me a geek<g>