FEBE to go

0
Filed under Utilities

If you use FireFox (and if not, what’s up with that), you need to check out Chuck Baker’s FireFox Environment Backup Utility (FEBE).

Slick little tool for saving all your FireFox goodness for that day when, suddenly, you realize you’ll be paving your machine and having to dig through your subconscious to come up with all those bookmarks, RSS feeds and FireFox extensions that you use everyday but couldn’t name to save your ass.

One Big Control or Lots of Little Ones (redux)

0
Filed under .NET, ASP, Rants, VB Feng Shui

Some time ago, (or here in the wonderfully virtual web world), I questioned the whole aspect of all this pile of controls in ASP.NET. Of course, you’ve got the grids and listviews, and you also have all the radio buttons, checkboxes. But then you’ve got a separate validator for each kind of validation you want to use, and even validators to let you combine other validators in “AND” and “OR” logical relations.

My thoughts were “Jeez. this is madness.”

Wouldn’t a single control that you could adapt to different display behaviors, validation rules etc be much easier to work with and create a more maintainable solution?

Well, apparently someone at Microsoft had the same bright idea, at least with the new ListView control in ASP.NET 3.5.

Take a read of Fritz Onion’s article in the latest MSDN magazine.

He describes the new ListView as a control that can “literally replace all other databinding controls in ASP.NET. That’s right. Every last one.”

Now, if they’d do the same for that validation nonsense, we might be getting somewhere!

Quick Find in VS2008, Not So Much

0
Filed under Uncategorized

It looks like I’m not the only person experiencing absolutely terrible performance in VS 2008 when performing what is ostensibly known as a “Quick Find”

image

This is the dialog you normally get when you do a Quick Find (Ctrl-F).

Note that I typically have it set for Entire Solution, Hidden Text and Use Wildcards.

With things set up this way, on a Core 2 Dual Core machine, I typically see a 2-4 second delay when I click the Find Next button. Pressing F3 to continue the find yields similar times.

And this is when the next occurrence is on the same line of code as the current occurrence!

Not much of a “Quick Find” in my book.

I tried all the various options, and nothing has any effect EXCEPT for the “Look In” option. If I change it from Entire Solution, to, well, anything else, the finds are then instantaneous.

If anyone knows of the cause or solution, I’d love to hear about it. So far, I’ve turned up bupcus on this one.

Till then, the Find In Files (Ctrl-Shift-F) option seems to be the best alternative.

Office File Formats Released

0
Filed under Uncategorized

Microsoft has just recently (as of Feb 15) released the full specs on the various Office file formats (including Word DOC files, Excel XLS files and Powerpoint PPT files, in particular).

The specs are available here.

If you’re a file format geek, or your job actually revolves around manipulating these types of files, this is surely a welcome addition to your arsenal.

Some of this information has been available, more or less, for quite some time. Most everyone who’s interested knows, for instance, that these files are actually OLE structured storage files, essentially entire “mini file systems” unto themselves.

But much of the detail has been sketchy at best, till now.

One word of warning though. Don’t expect these to be simple, cookbook recipes on rolling your own version of Word or Excel. The specs are huge and the formats unbelievably complex, having evolved over the course of 10 or more years. Further, these are not Web 2.0, nice, friendly XML/HTML/Text/human readable files by any stretch. They’re tangled, binary, pointer-ridden globs of structures that take a good deal of code just to render somewhat intelligible.

That said, official documentation is far better than none, and surely beats reverse-engineering the formats, as has been done up to this point.

I know I’ll be digging into this more in the coming weeks.

Happy hacking!

Implementing a Shell Context Menu Handler In VB6

0
Filed under Uncategorized

I won’t go over the details of doing this here. There is a excellent run through online at O’Reilly. Check here. Specifically, it’s chapter 4 of J.P. Hamilton’s book “Visual Basic Shell Programming”.

I suppose it’s so dated now that they’re making it available online free. Not sure whether that’s a good thing, or a bad indicator of the age of tools I’m using<g>.

At any rate, this is an excellent reference if you happen to be doing this.

Specifically, the part about modifying the VTable on the fly to handle some of the IContextMenu methods is very good.

But the part that really had me smacking my head was the “Restore the VTable during object termination” section.

Duh! No wonder I was having some weird, after my context menu handler had popped up and done it’s thing, Explorer would crash kind of moments.

This is one of those times when telecommuting can be a drag. Having a co-worker glance over my shoulder probably could have caught that kind of mistake much earlier than when I caught it.

Moral of the story: If you’re gonna manually jack up COM VTable pointers, always put ’em back they way you found ’em.

DVDs on your Tivo

0
Filed under Tivo

image At one point, a few months back, it struck me that it might be nice to watch DVDs via my Tivo.

Why on earth do that, you might ask?

  • You won’t have to jockey with discs (my 4 year old loves watching things a second time, or in the case of Mr Roger’s Neighborhood, Sesame Street and any movie with a princess in it, a third, forth, or x^nth time).
  • The Tivo has a pause even my 4 year old can use (which is very important when there’s the need for a potty break mid-Cinderella!)
  • Pause, rewind, etc just seem to work so much smoother on the Tivo. Plus, if you do have to pause your movie, the Tivo will preserve where you are, even if you bail out completely. My DVD player can’t do that.

What you need

  1. A DVD (that you want to convert to a Tivo-friendly movie)
  2. A DVD drive in a PC (preferably, a reasonably fast PC)
  3. A networked Tivo (not much point if it’s not networked)
  4. DVDFab HD Decryptor Freeware version – used to extract the main movie from a DVD
  5. VOB2MPG – used to convert the extracted VOB fileset into a single MP4 file
  6. Tivo Desktop installed on your PC – This is how you get the final MP4 movie transferred to the Tivo

A Word of Caution

A few of my DVD’s just couldn’t be converted this way. I’m guessing they’re of the sort that have the “mangled disc” copy protection, but I can’t swear to it. Maybe there’s a utility out there that could work around this, but, hell, if I want to watch those discs, I just use the disc itself and be done with it.

At any rate, your mileage may vary.

Extract the Main Movie VOB (Video Object)

Install DVDFab, and start it.

Insert your DVD and let it load in into DVDFab.

image

Select the Main Movie option, enter a Target Path (a scratch folder on a harddrive with at least 5-7gig free), and make sure the main movie chapter is highlighted (it’ll usually be the one with the longest Play Time).

Then click Start.

On my machine, it takes about 7 minutes to extract a typical DVD movie.

Convert the Main Movie VOB to an MPG file

Now install and run VOB2MPG

You should see this:

image

Click the folder button beside the “Folder Containing VOB sets” box, and select the Video_TS folder created by DVDFab during the conversion above.

The click the folder button beside the “Folder to write MPGs to” and just select some other scratch folder somewhere. This is where it’ll save the converted MPG file.

Make sure the target drive has plenty of free diskspace (another 5-7 gig should be fine).

And click Start.

This also takes about 5 minutes or so on my machine.

When it finishes, you’ll have a nice and tidy MPG movie file that you can transfer to your Tivo. At this point, you can get rid of the VOB files and folder created by DVDFab above; they are no longer necessary.

To figure out where to put the MPG file, just open the Tivo Desktop and click View – Published Video.

image

You should see the above screen. Click the highlighted “Where is this Folder” link to open an Explorer window right to the proper place.

Copy your MPG file here (be sure to name it something nice and readable).

Then go to your Tivo and follow the instructions on the above screen.

Downloading the MPG file from your PC to your Tivo may take a while, depending on how you’ve got your Tivo networked, but eventually it should get there and be ready for your viewing pleasure!

And a final note

Before people start whacking me, yes, I’m sure there are plenty of low cost apps out there that’ll do this entire process more-or-less automatically (heck, some might even handle the few discs I ran into that didn’t work because of bad sectors).

For that matter the paid version of DVDFab looks like it’d do it.

If you know of a good app for this, by all means let me know!

It’s just that I only have a 320GB Tivo<g> and even if I could, I’m just not interested in filling it with ALL my DVD’s. Just the ones that might get watched repeatedly.

I guess I’m just pragmatic that way.

Now, where’d I put those 120$ industrial arcade trackballs?

Quicken Online?

0
Filed under Misc, Rants, Security

I can see doing a lot of things “online”.

Email? GMail is pretty dang slick, with a spam filter that’s second to none.

Stock Portfolio and watchlists? Sure.

Craig’s List Searches? Right there on my homepage.

Word Processing? Spreadsheets? Hmmm. Google apps is definitely interesting, although I tend to want to keep my files close at hand.

Personal finance information? Huhwhaaaa?

Call me old fashioned, but the thought of putting access info to my entire checkbook/credit card/bank account/investment accounts online just seems a little, uh, risky?

Hell, it’s probably all already out there, but is it really a good idea to put concentrate all that in one place, online, in the ether on someone else’s server?

Hmm, looks like somebody already has. But wait, this is great. Check out the bold restriction in their terms of use. Why oh why would anyone put private info on some company’s server when said company says up front not to put financial info there. Damn, I hope they have a good E&O policy!

I suppose SalesForce.com asks their customers to do it every day (after all, isn’t your company’s client list a bit like your ledger?) and nobody has much of a problem with it.

So maybe I am old fashioned.

Then I saw this (from the QuickenOnline.com website):

Build your whole financial picture for up to 5 years.
Most banks keep your online data for only 60 to 90 days. 
With Quicken Online, you build your whole financial picture 
from the day you start. We keep active customer's data for up to 5 years.

5 whole years! How generous! And I guess after five years, all that data would be useless to me?

Um. I don’t think so.

Guess I’ll stick to the tried and true for now.

A Grousing About Properties in .NET

0
Filed under .NET, Rants, VB Feng Shui

I’ve started playing more and more with .NET lately. There’s a lot to like, a lot to dislike, and a few things that left me scratching my head.

One is this new fascination with moving regional (or class scoped variables) up to right on top of the properties that are wrapping them.

You’ve no doubt seen the pattern.

In old school VB6, you’d have something like this:

    {top of class}
    Private _MyPropVar As Boolean

    {lots of code here}

    Public Property Get MyProp() As Boolean
        Return _MyPropVar
    End Get

    Public Property Let MyProp(Byval NewValue as Boolean)
       _MyPropVar = value
    End Set
    {code continues}

And in the New Order, you have this:

    {other code}

    Private Shared _MyPropVar As Boolean = True
    Public Shared Property MyProp() As Boolean
        Get
            Return _MyPropVar
        End Get
        Set(ByVal value As Boolean)
            _MyPropVar = value
        End Set
    End Property

    {code continues}

Now, the pundits out there claim that the ability to move the definition of the variable that stores the property value down in the code to where the property is actually defined is a good thing.

And it very well might be.

But if that variable is used elsewhere in the class (it is, after all, visible to the entire class), then it makes more sense to me for it to be grouped with other such class scoped variables at the top of the class, and not buried within the class.

What’s most frustrating about this, though, is that the language designers had the perfect opportunity to solve this problem elegantly, and didn’t.

The simple introduction of a property scope would have done the trick. Then for those variables that are ONLY used to track the contents of a property, you’d have this (note the _MyPropVar definition has moved to INSIDE the property declaration):

    {other code}

    Public Shared Property MyProp() As Boolean
        Private _MyPropVar As Boolean = True
        Get
            Return _MyPropVar
        End Get
        Set(ByVal value As Boolean)
            _MyPropVar = value
        End Set
    End Property

    {code continues}

Now there may be significant ramifications involved that prevented this change, and I’m certainly no expert at compiler design or implementation (though I have implemented a pseudo-code compiler scripting language used in a commercial product).

But this just doesn’t seem like all that big a deal to have implemented and would have cleanly resolved where to put variables of both persuasions (ie those that are used by ONLY a single property, and those that are truly class scoped and used my multiple properties/methods).

Personally, I think this was a bit of a “good enough” decision.

Practically, I think I’ll stick with locating truly class-scoped variables at the top of the class, and ONLY bury variables that really are only accessed by a single method/property.

Dynamically Enabling Access to the VBA Object Model in Office Apps

1
Filed under Uncategorized

Writing addins and macros for Office apps (specifically Word, but this includes Excel and Powerpoint) can be difficult enough as it is.

But when you throw security gotchas into the mix, things can get interesting quickly.

One thing that often hangs people up are the security settings.

There are several different security levels for macros, of course. And there’s also security that controls access to the internal VBA object model.

But what’s the “VBA Object Model”?

Essentially, it’s an object model (not unlike the Word object model that starts at the Word.Application object) that allows macro code (and COM add-in code as well) full access to all the macros written in VBA and stored within the actual document (or template) file.

For instance, you can actually print out all the VBA macro code in a document with a code snippet similar to the following:

For i = 1 to WordDoc.VBProject.VBComponents.Count
   Set vbcode = WordDoc.VBProject.VBComponents(i)

   C = vbcode.CodeModule.CountOfLines

   '---- retrieve the entire code block
   If C > 0 Then
      code$ = vbcode.CodeModule.Lines(1, vbcode.CodeModule.CountOfLines)
      Debug.print code$
   End if
Next

Depending on what you need to do with your code, this can be very very useful.

But…

It doesn’t work at all unless the user checks the “Trust Access to the VBA project object model” on the Macro Security screen (shown here from Word 2007, it’s essentially the same in Word 2000-2003).

image

Now, you might think that, hey, a potentially powerful security hole like that would be something that ONLY a user would be able to change. In other words, the setting wouldn’t be readily available directly through the operating system.

And you’d be right, and wrong.

That setting can be found, quite simply, in the HKEY CURRENT USER registry hive.

For Excel:

image

For PowerPoint:

image

and for Word:

image

However, that’s not the end of the story.

It is true that the setting is a PER USER setting, which means that your application would have to alter this setting for each user that logged onto a machine. But the current user generally has FULL RIGHTS to HKEY CURRENT USER hive, so why put a security setting like this there?

Because it’s not the only place you set it.

There are also keys like these (note the version of Office):

HKEY_LOCAL_MACHINE\Software\Microsoft\Office\12.0\Word\Security
HKEY_LOCAL_MACHINE\Software\Microsoft\Office\12.0\Excel\Security
HKEY_LOCAL_MACHINE\Software\Microsoft\Office\12.0\Powerpoint\Security

Each potentially contains a value named AccessVBOM as well.

If this value is defined and has a value of 0, the value in HKCU is essentially ignored, and the user cannot grant access to the VBOM, even if they manually enter a 1 for the value under the HKCU.

If the HKLM value doesn’t exist at all, or has a value of 1, then the user can set the HKCU value, or change the Trust Access checkbox manually in the application.

And since write access the HKLM is often restricted to local admins, this gives admins a way to lock down this setting on machines, which is a good thing.

Another important point; changing these settings while the Office app is already loaded, will not cause said app to change its behavior dynamically. Put another way, Word, Excel and Powerpoint appear to read these settings once, at load time, and then never read what’s in the registry again until all instances are unloaded and the app is loaded again.

Practically, this means that you can’t change these settings from within a true Office Addin (ie a COM addin or a VBA Macro).

But you CAN change them quite easily from other code. At least, it’s easy to change the HKCU value, and the HKLM value can be changed during your MSI based installation.

Now comes the ethical dilemma.

Your application won’t run (or won’t run in entirety) if access to the VBOM is not granted, and many people would find it difficult to change that setting, even through the UI. But that’s not the kind of setting that you want to change automatically  or surreptitiously without letting the user know you’re doing so. Or is it? Would typical users know what it meant anyway? And most Office macro viruses would be caught via other means now, right?

As a final note, googling “AccessVBOM” turns up plenty of pages describing these keys in various levels of detail, but interestingly, searching the Microsoft.com site comes up with very little on the topic.

Making Tivo Server Run as a Service

3
Filed under Tivo

I love Tivo. If you have a cable company DVR, my heart goes out to you. My 4 year old daughter can operate our Tivo to watch her favorite show. And she can easily pause the action to take those all important potty breaks! That’s not to say she watches a lot of TV, but hey, Mr. Roger’s rocks!

I don’t even mind the 13$ a month for the service (although now, I SOOOO wish I’d taken the blue pill gone with that lifetime subscription.

But one thing that has annoyed me since I first got the thing networked is the fact that the dang server software has to be run from a logged-in user account. Tivo sets up its “Beacon” service as a legitimate Windows Service, but there are three other programs that get run via the RUN key in HKCU, and, of course, those only get fired off after a user logs in.

Since my Tivo server software is actually running on a server, it’s a tad annoying to actually HAVE to login just to get the Tivo stuff running.

It hasn’t been a huge pain, but I finally got some time to experiment, and I’m happy to report, there does appear to be a solution.

The Goal

I should reiterate that the goal of all this is to get things set up such that powering up the “server” machine is enough to get the Tivo Server running and able to communicate with the Tivo. If you want to actually use the Tivo Desktop from the PC, then you’ll still have to login.

The Disclaimer

Before you start, be warned that mucking with your registry and with services can be dicey, especially when your setting up programs to run as services that weren’t originally intended for that purpose.

However, in reality, there’s really no need to directly fiddle with the registry using this technique. And converting an app to a service can be done for free, or done much more easily for the reasonably low cost of a simple utility.

What’s needed

  • A Tivo, and it really has to be networked for there to be much of a point in all this.
  • A “server” PC that is already running the Tivo Desktop and Server software. You absolutely MUST already have the Tivo software running and verify that it can connect to your Tivo, download shows, share music etc before even attempting any of this process.
  • A way to convert a standard app into a Windows Service. I use FireDaemon for this, simply because I already bought it for other purposes, and it’s a bargain at 40$, but there are free alternatives out there. One in particular is SRVANY.EXE. A good article about that approach is here, but just google for more.

First things First

As mentioned above, make sure that your Tivo Desktop software is already installed, running and can connect to your Tivo and at least download the list of recording available.

image

You’ll also want to share at least one MP3 track or one photo, so you can see them from the Tivo box. Using Tivo Desktop, setup music or photo sharing here:

image

You do this so that, once everything’s reset and running as a service, you can easily check, from the Tivo, whether it can still see your PC and the Tivo Server running on it.

Stopping the autoRun of the Tivo Background Apps

Technically, this step isn’t really necessary, but I’ll detail it anyway, for those interested parties out there.

As I said earlier, the Tivo Beacon is already configured as a service, so we don’t have to do anything to it.

However, a quick glance through the registry will reveal these keys:

image

To be technically correct, you should probably remove these keys from the registry (backing them up first!). Actually, you wouldn’t really want to remove the TivoNotify entry, since it really should be run when a user logs in. But the TivoTransfer and TivoServer entries could be removed.

However, from experiments I’ve done, it doesn’t seem hurt to leave them in place. If these programs are started as services, then running them again when you actually do login doesn’t appear to have any effect.

Setting Up the Tivo Transfer app as a Service

Open FireDaemon and select Services – New to create a new service definition. This one will be for the Tivo Transfer Service.

You’ll get the Edit Service Definition Dialog as below. Fill it in appropriately. Typically, if you perform a standard Tivo Desktop install, these paths will be the same for you.

image

Pay particular attention to the Executable name and the Parameters.

On the Setting page, make sure the Logon Account is set to a user with appropriate permissions and that you will normally logon to the machine as (usually, it’s the user under which you installed and setup the Tivo Desktop).

Also, make sure the Startup Mode is Automatic and disable program exit monitoring.

image

And finally, on the Dependencies Page, add a dependency to the “Tivo Beacon” service. Mine just happens to be named “Tivo Beacon2”. This guarantees that the Windows Service Manager won’t start this service until after the Tivo Beacon is running.

image

Setting Up the Tivo Server app as a Service

Create another Service Definition in FireDaemon.

image

Make sure the logon account, Startup Mode and program exit monitoring are set as in the Tivo Transfer Service above.

And finally, set the dependencies as above, but in this case, include both the TivoBeacon and the Tivo Transfer service (that you just created).

What About That Tivo Notify App?

Good question. It handles the little system tray icon, and as such, doesn’t need to be started as a service.

Restart

At this point, you should have created 2 services, one for the Transfer app, one for the Server app.

Use the TaskManager to kill off the two processes (TivoServer.exe and TivoTransfer.exe) if they’re running.

Then, use FireDaemon or the Windows Service Control panel to start the two services you just created. If everything went right, you should see them running in the Task Manager.

image

Restart your machine and DO NOT LOGIN.

The Wrap Up

Once your PC has restarted, use your Tivo to check that it can see your shared Music or Photos (from the Now Playing screen, select Music, Photos and More, and scroll down to find your PC’s shared music in the list (in my case, My Tivo Server runs as the Administrator and my server’s name is Olympus).

 image

If your Tivo can see those, and can browse through your music or photos, you know that the Tivo Server and Transfer services started properly without you actually logging into your PC, which is the whole point of this twisted exercise!

If not, go back and check to verify that everything is setup as above and that there are no errors logged in the Application Event Log.

Things to Watch Out For

From what I can tell, the Transfer Process, and to a lesser extent, the Server process, do some peculiar things when they start up (I believe they actually start up a second instance, then terminate the initially loaded instance).

Because of this, FireDaemon’s “Process Exit Monitoring” function really made a mess of things. Basically, the idea is that FireDaemon can monitor the process that it starts as a service. If that process terminate for some reason, FireDaemon can automatically restart it.

Under normal circumstances, this is a good thing because you’d want to service to be constantly available. This won’t work with the Tivo processes though. That’s why I disable this feature when setting these services up (see above).

It might be possible instead to increase the load delay or otherwise tweak FireDaemon’s settings, but I haven’t tried that yet.

I do know that if you don’t do something, though, the Tivo processes will just enter an endless cycle of starting, stopping, and FireDaemon restarting them, only for them to stop again, ad nauseam.

And yeah, my TV’s a 36″ tube set, hence the old school sexy curves in the Tivo screen shots<G>