Thursday, February 25, 2010

What to do when a Windows 7 desktop icon has the wrong image

We are in the middle of rebranding our applications and as part of the rebranding, the icons for each application have been updated.  We are having lots of fun cramming Vista styled icons through ancient resource compilers, but that’s another story.

We provided a rebranded application to our QA tem for testing.  The first thing the QA manager did was to drag the app to her Windows 7 desktop, replacing the previous version.   Oddly enough, the image appeared for the icon.  I went back and checked the build process, that image was no longer there.  yet, it appeared on her desktop.  It also occurs with Vista as well.

I had originally posted how to do this by deleting the iconcach.db, but that is such a crude hack that I have pulled it.  After posting this message, I came across a much simpler mechanism. 

If you call SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_IDLIST, 0, 0), from shell32.dll, this will cause the icon cache to be refreshed.  This happens in real time, no need to restart explorer or rebooting.  This is easy to call from just about every programming environment. If you need a stand alone app,  Helge Klien wrote a simple command line tool and posted it at Free Tool: Refresh the Desktop Programmatically.  I’ve added the SHChangeNotify() call to my installers, the users will never be bothered by this.

Sunday, February 14, 2010

This connection is Untrusted (another ID10T error)

The other day, my PC died.  After some angst, I was able to fix it by replacing the power supply.  After starting the PC, I fired up Firefox to check my email.  That’s when the first error message popped up.  I was presented with this lovely error dialog.

SecureConnectionFailed

Lovely.  This came from Xmarks, a browser add-in that I use to keep my browser books marks synchronized across multiple machines.  Which is a really cool thing to have, but I digress.  Still, check it out.

I didn’t play too much attention to it when I saw it.  I just figured it was a glitch on the Xmarks site and cancelled out of it.  I should have paid more attention to it, that dialog had the clue to explain what the problem was.

After cancelling that dialog, I went to my webmail account.  I host my rajapet.net email account through Google Apps and I have HTTPS url to get into the email.  That brought up the “This connection is Untrusted” dialog.

ThisCertificateIsUntrusted

Oh joy. I just figured that their SSL certificate had expired and I clicked through that one.  I went to my GMail account and the same thing happened.  I tried a few other sites, every site that used a SSL certificate did the same thing.  What did I break?

When I followed the motherboard vendor suggestion of resetting the bios, that included resetting the clock.  My PC date was set to January 1st, 2001.  That was causing the SSL certificate grief.  When you get a SSL certificate for your site, it has a starting and ending date.  Lets take a close look at the error message from the Xmarks add-in.

SecureConnectionFailedClip

The earliest date that this certificate would be considered valid for was 2/6/2009.  Had I paid closer attention to the error dialog, I would seen that my clock was off.  I went into the Windows clock applet and synched up with a time server and everything went back to normal.  Then I rebooted the machine and went into the BIOS settings to make sure everything was the way I liked.  File this as an ID10T error.

Saturday, February 13, 2010

What do you mean the computer wont turn on?

Last Monday, I came home from work and went to check my email on my home PC.  I went into my home office and sat down at the PC.  I turned on the monitors (I run two monitors on my main dev machine at home and at the office) and banged on the shift key to wake things up.

Nothing happened.  That was odd.  My PC was very quiet but you can usually hear a faint hum from the CPU fan.  Not this time.  This machine is on pretty much 24/7.  I leave it on overnight so that my Windows Home Server can back it up.  I also leave it on during the day in case I need to access it from work.

We had come contractors in the house for some home remodeling projects, one of them may have tripped a circuit breaker.  My PC is set not to reboot if the power comes back on after an outage.  If we have power outage from a storm, I don’t want my machine coming back online until I”m sure the power is staying on.

So I pressed the power button.  Nothing happening.  It’s a soft power button, it doesn’t stay pressed in.  I pressed it again.  More nothing.   I have a case where the side panel comes right off.  So I took it off and looked for the motherboard power LED.  Most motherboards have an LED to indicate the power supply is connected.

I could see that the light was on, so it looked like it was getting power.  I pulled the power cord from the PC and double checked all of the connecters.  Nothing appeared to be loose.  I plugged the cable back and tried the power.  Nothing.  I was starting to get a little nervous at this point.  This is my main home PC, I depend on it being in working order.  It’s a few years old, I had it custom built using parts that should last a while.

Since none of the obvious suspects appeared to be the root cause, I decided to see if the motherboard manual has a trouble shooting section.  It didn’t.  I went to the ASUS web site and drilled down through the support pages until I found a trouble shooting guide.  One of the things it suggested was to reset the BIOS settings by pulling the battery out and putting it back in upside down.

So I did that and nothing happened.   Usually when a PC wont come on, you usually see something on the screen or hear something from the hard drives.  Even if the machine wont boot, the disk drives will spin up.  That pointed the fickle finger of fate back to the power supply.  There is a power switch on the power supply.  This switch controlled whether or not the power supply provided any juice to the motherboard.

While looking at the motherboard, I flicked the power supply switch back on.  The motherboard light came on and then dimmed a bit.  It’s not supposed to do that.  That meant the power supply was most probably toast.  It was about 11pm at this point, and my nerves were shot.  But it meant I had a shot for getting this machine back online.

When I had this PC built, I had picked an Antec Sonata II case.  There were a couple of reasons.  It’s a very easy case to work with, no sharp edges on the inside.  It’s also designed to be a quiet case, which is nice for a home office.  Instead of 80mm case fan, it has a pair on 120mm fans to push the air through the case.  By being larger, they can run a lower speed and push more air with less noise.  It also came with a decent Antec 450 watt power supply.  Well, in my case, not so decent.  But the power supply could be easily removed.

So I needed a new power supply and I needed it ASAP.  Around here (Albany, NY), the options for locally obtained computer parts are slim.  It’s basically Best Buy.  So I went on their site and looked over their list of power supplies.  They actually had a decent selection.  I didn’t need anything crazy, but I wanted a good one.  I found one that had good reviews on Best Buy and a few other sites AND was in stock at the local Best Buy shop.  It was a Corsair 650 watt model.

So I dragged my PC into work to have our IT manager take a look.  He basically confirmed my suspicion that the power supply was shot.  At lunch time, I went over to Best Buy and bought the Corsair.  This was a 650TX, which is a non-modular power supply.  A non-modular power supply means that all of the cables are permanently attached.  It had many connectors.  It looked like a mechanical squid.  It would have been nice to get a modular supply and only attach the cables that I actually needed.  Unfortunately, I would have to order that online and I wanted to get this machine running right now.  We swapped the power supplies and my machine booted right up.

So my machine is back up and running.  It had some other issues, but I was able to resolve them.  I’m a bit disappointed with Antec.  That power supply should not have died.  If I were to build a new PC tomorrow, I would not use an Antec power supply.  I would get a current generation Sonata, like the Sonata Elite.  That model does not come with a power supply, you bring your own.  I’ll probably go with another Corsair.

Through out all of this, I was able to stay sane by the knowledge that I had a backup of everything on that machine.  If the power supply had not been the problem, I would have been getting a new PC.  Which is usually a good thing, but not when it’s not on the budget.  A couple of weeks ago, I bought a WIndows Home Server.  I bought a HP MediaSmart Server.  I got the EX495 and I’ve been very happy with.  It backs up all of the PC’s on my home network every night.  I was able to access the backups from another PC and I could easily access them.  I highly recommend having a WIndows Home Server at home.

Monday, January 04, 2010

Just watched a movie in HD using Amazon Video On Demand through my Tivo

I had some credits with my Amazon account so I decided to “rent” a movie through their Amazon Video On Demand program.  TiVo had offered the Amazon Video on Demand for while, I decided to see what the experience would be with a HD movie.

AmazonVOD2 From what I read on the TiVo site, HD movies from Amazon are only available through a select hardware devices, you can’t order them on through the Amazon site for a PC.  I have a TiVo HD, which is one of the approved hardware devices

I’m not sure why you can’t get HD movies on your PC.  It’s not a hardware limitation, you can download TV shows in HD through Amazon.com.  It must be a studio thing.  It’s not an issue for me, if I’m going to download a movie in HD, I’m going to want to watch it on my HDTV while sitting on my couch.

With Amazon Video on Demand, you can buy a movie outright or you rent it.  If you buy it, it’s downloaded to your device and you can watch it as often as you like.  You can download it to 2 locations (like a TiVo and a Windows PC), plus two portable devices.  The portable devices must be “Play for Sure” compliant, which rules out anything designed at One Infinite Loop.

With a rental, you have up to 30 days to watch the movie once it starts downloading.  Once you start watching, you have 48 hours to watch it.  Within that 48 hours, you can watch it as many times as you want, but then it’s gone.  Which is just as well, a full length HD movie is going to take a chunk out of the available space on a TiVo.

I decided to rent a movie.  I wanted to see Terminator Salvation and the rental price was $2.99.  The purchase price for download was $11.99, but if I wanted to own it, I think I would just get the DVD for $15.99.  I don’t own a Blu-Ray player yet, so the Amazon download would be at a higher resolution than DVD.

TerminatorSalvation

So I selected Terminator Salvation in HD from the Amazon Video on Demand list on my TiVo.  I already synced up my Amazon account with my TiVo so I only needed to enter my 5 digit pass code to complete the purchase.  It then displayed a screen that said that download would start within 30 minutes. It was a pretty easy process.

Sure enough with 15 minutes, the little blue light on my TiVo came on.  That was the signal that the TiVo was downloading content from the Internet.  I gave it a 20 minute head start and then started watching the movie.

I don’t know how it works on other devices, but with Amazon Video on Demand on the TiVo, it’s streaming at a fixed bit rate.  It doesn’t scale the quality based on the bandwidth of the Internet connection.  I have a decent download pipe, 20 Mb/s through Verizon FiOS.  My TiVo has a wired connection to my router, so I don’t have to deal with the general vagueness of 802.11g wireless.  So that means I can start watching while it was still downloading.  If my TiVo was going through a wireless connection, I think I would have waited until the movie had been completely downloaded before starting to watch it.

The quality was very good.  The bitrate was 2800 kbps and the resolution was 1080i.  That beats what I would get from the DVD version.  Amazon Video on Demand to the TiVo only supports stereo sounds, but I don’t have a true 5:1 surround sound setup yet and that loss didn’t really affect me,  The movie was downloading at roughly the same rate I was watching it, with the 20 minute head start, I was able to watch from start to finish with out any hiccups.

The experience was very good.  $2.99 seems like the going rate for movie rentals.  I’m not sure what my cable company charges, but since they have a “$2.99 value section”, I would assume that new HD releases would cost more.  Plus, my TiVo can’t access the cable company’s VOD, so it’s a moot point.

As for the movie itself?  Terminator Salvation was fun.  I think it was better than the reviews that it got.  I thought the ending was a hokey, but I got my money’s worth out of it.  I would do this again with another movie.

Thursday, December 24, 2009

There is no sense of humor on the North Face

I was just read about how the North Face is suing the South Butt. The South Butt is a parody line of clothing started by Jimmy Winkelmann, a college freshman at the University of Missouri.  The South Butt clothing line features a logo that is a clever spoof of the ever present North Face logo.

I’m not a lawyer and nor do I play one on TV, but it sounds the South Butt was a clear and obvious parody and would be protected by the fair use laws.  Parody is a fair use, even when done as a commercial venture.  That has been taken all the way to the Supreme Court.  In Campell v. Acuff-Rose Music, Roy Orbison’s publishers tried to sue 2 Live Crew for their song “Pretty Woman”, which parodied Orbison’s “Oh, Pretty Woman”.  The Supreme court ruled that the 2 Live Crew song was protected by § 107 of the Copyright Act of 1976.

This is just a dumb move on the part of North face.  I don’t know how Winkelmann’s venture crossed the North Face radar, but I’m sure it didn’t much exposure until the North Face lawyers got involved.  That caused a Streisand Effect, generating tons of publicity for the Butt Face.  Now the North Face looks like a bully with no sense of humor.

When you compare the two logos, you can clearly see the difference.

NorthFaceLogo

versus

SouthFaceLogo

The South Butt logo is clearly parodying the North Face logo.  I can see the need for the North Face to protect their logo.  That logo is the identifying marker for their product line.  When someone is wearing a North Face jacket, you are aware of the brand from 30 feet away.  The South Butt does not dilute the North Face brand.  It make fun of it, but that is protected by law.  There is no upside for North Face with this suit.  They will most likely lose their case and will ahve wasted time on and money on a pointless venture.  If by some bizarre luck they actually win, then they will look like bullies.  Either way, lots of bad publicity for them.

My daughters wear North Face jackets.  It’s a status symbol for their age group.  If the North Face continues with this suit, I’ll think twice before I buy anymore.  I may just buy a Butt Face jacket for my own amusement.  I’ve already become a fan of their Facebook page.

Friday, December 18, 2009

Getting the list of databases that a user has rights to from SQL Server

We have a few applications that let the user select the database connection details.  It’s for SQL Server 2005/2008 and they can pick the server protocol, server name, and the database.  Once they select a database server, the user selects the database from a pick list selection.  We filter that list to only show the databases that are applicable for that user and application.

The first thing we do is get the list of databases.  We want to only display the databases that user can access and filter out the system databases.  There are a few ways to get the list of databases from SQL Server.  There is a system stored procedure named sp_helpdb or you can go right to the same tables and views that sp_helpdb uses.  The latter matter is more efficient, but you want to make sure that you are using the system views instead of the system tables.  Microsoft has deprecated access to the system tables and has published a list that maps the system tables to the system views on this MSDN page.

The system view that we want to uses is sys.databases.  This view will give us a list of all (well nearly all and close enough for our purposes) of the mounted databases.  This includes the system databases and databases that the user may not actually have rights to.  We can filter out the system tables by excluding them by name,  We can use the has_dbacesss() function to filter out the tables that we don’t have access to.  The has_dbacess('databasename') function will return 1 for databases that the current connection has access to, or 0 for no access.  That give us the following T-SQL for getting the list of databases:

select Name 
from sys.databases
where (has_dbaccess(name) > 0)
and name not in ('master', 'tempdb', 'model', 'msdb')
order by 1

If your user account has access to different types of databases and you want to filter the list to provide only the databases that your application supports, then you can go one step further.  Find a table or view in your database that is fairly unique.  If all of the table names are pretty generic, just create with unique name and make a use for it later.

The following SQL statement can be executed from an application to get a filtered list of databases in one call to the server.

create table #TempTable(dbname nvarchar(128));
declare @AppDatabase nvarchar(128);
declare cr cursor for select Name from sys.databases where (has_dbaccess(name) > 0)

open cr;

fetch next from cr into @AppDatabase;

WHILE @@FETCH_STATUS = 0 begin;
execute (' insert into #TempTable(dbname) select Table_Catalog from [' + @AppDatabase + '].INFORMATION_SCHEMA.TABLES where TABLE_NAME = ''GeoZoneEdge''');
fetch next from cr into @AppDatabase;
end;

deallocate cr;

select dbname from #TempTable

drop table #TempTable


The use of semicolons makes it easy to send the set of the t-sql commands as one command to the server.  you would replace the string “yourtablenamehere” with the name of the actual table or view you were trying to match.   By sending a set of commands as a single batch, we get the power of a stored procedure with actually having to have a stored procedure.  The blank lines are there for readability, you can run that as a single execute command and get back a result set.

The first few lines create a temp table to store the database names collected from sys.databases.  We use a cursor to iterate through result set from sys.databases so that we can check each database for the existence of a table that we know will be in our application’s database.   For each database name in that result set, we use the INFORMATION_SCHEMA.TABLES view to check for the existence of a specific table in that table.  Since we doing that lookup for each database, we need to construct the SQL statement at runtime, as shown in line 10 in the listing above.  Each select statement the produces a result, logs the database name into the temporary table.  Then we just return the results of the temporary table.

It looks involved, but it executes fast and the calling application only needs to make one call to the SQL Server to collect the data.

Monday, November 09, 2009

This Day in Epic Fail: November 9th, 1876

This Day in FAIL

Lloyd Header of Cleveland Ohio discovered that he needed at least one more lesson in riding his High Wheel bicycle.  The term “taking a header” was named after him.

image courtesy of Do-While.com