Dan Mackey On ColdFusion Development

ColdFusion, Java, .NET, AJAX, DHTML development and general programming. Daniel is owner and Administrator of CFTagStore.com and works for an Application Development Company in Ireland called Digital Crew. His interests cover all areas of programming in multiple languages with a particular interest in Internet Technologies.

All Articles Posted In January 2007
2007-01-25 14:10:00.0

Annoying IE7 bug with window.opener.document.location

I hate these types of bugs.

I have just wasted an hour of my day trying to figure this out. It works in Mozilla as expected and I havent tried IE6 but IE7 threw a strange error.

I was trying to check if a certain string was in the url of the window that opened a pop-up.

The code I was using that failed was:

I tried everything I could think of to try and test and re-check my code etc. I stripped it all back and thought maybe it was to do with string types so did the following:

Bingo...it worked. Turns out when I concatenate the str variable with an empty string, it solved the problem.

BTW, the code above is taken from the updates I am making to CF_FileManager to allow it to use CF_ProFlashUpload if you have that component in your dcCom folder.

Working pretty well right now!

Add to your del.icio.us    DIGG This!    Technorati Cosmos Link    Post to Reddit    Add to your Furl    Add to Blinklist
Comments [5] - Leave a comment
2007-01-24 20:48:00.0

Two ColdFusion Things I Love

  1. REQUEST Scope
  2. Query Of Queries

Lately, while working on new interfaces for UDI - Digital Crews Database Interface custom tag (written by Peter www.cftopper.com) I was in the need for a simple method of querying a database using recursion with little overhead on the database.

I needed this to build up the path of a node in a { PARENTID, ID, NAME } type table. For instance, if it was a breadcrumb navigation and I wanted a page 4 levels deep, I wanted to know that the path was : Home » About Us » History » Overview when all I had to work with was the ID of the Overview page.

Before the REQUEST scope (CF 4.5 / 5 and earlier) I would possibly have used a SESSION or passed the data all around the shop. Now, I just pop my data in the REQUEST scope and can access it in the recursive custom tag.

Another issue I had was solved by Query Of Queries. I only wanted to hit the MySQL database once and in my example above, before Query Of Queries, I would have hit the database 4 times in a loop. Not good. Now, I do one query against the database and pass the resultant query into the custom tag (or function) recursively. Far more efficient!

One snag was if I passed the query as follows : <cf_myCustomTag query="#myDBSQuery#"> and tried to use it in the myCustomTag.cfm page as follows <cfquery name="QOQQuery">SELECT * FROM #ATTRIBUTES.query#</cfquery> I got an error saying the query wasnt in memory.

To solve it, I created a temp variable called cQuery and set it to ATTRIBUTES.query using <cfset cQuery=ATTRIBUTES.query> and called <cfquery name="QOQQuery">SELECT * FROM #cQuery#</cfquery>

Tags: ColdFusion | Tips
Add to your del.icio.us    DIGG This!    Technorati Cosmos Link    Post to Reddit    Add to your Furl    Add to Blinklist
Comments [0] - Leave a comment
2007-01-24 20:01:00.0

Retrieving Non-Volatile USB Serial Number Using C# .NET

This is something I meant to post up ages ago as information and solutions are hard to come by on this specific topic.

The problem all stems from the fact that the USB specification does not require a hard coded serial number as mandatory for USB devices, especially memory sticks although in my tests 99% of sticks did in fact have an OEM serial number.

Windows secifies its own serial number for each device which is volatile meaning the serial number is erased and renewed everytime the USB stick is formatted. This causes problems when your using your stick as a security device or dongle. Basically, in Windows if you get 2 devices from the same manufacturer without OEM numbers, it gets confused. Not sure about a Mac or Linux.

Anyways, to the point of this article.....how do we actually get the OEM serail so a device can be formatted over and over again and you can still tell the drive apart from another one?

Well, there are 2 ways. Using the registry or using something called a Win32 WMI Provider. WMI is a database of all aspects of your operating system and hardware and is used by Windows to hold everything together. Infact the WMI is a all held in the regisrty but the provider using management classes lets you query it using SQL.

You need to add a reference to your C Sharp program to SYSTEM.MANAGEMENT.

Step 1 is to query the Win32_LogicalDiskToPartition section and get all the logical disk names e.g: F:\ and mapped enumeration which have a big long string attached like so : 000000001

This will give us the enumeration of the drive so we can then strip off the int at the end and query the Win32_DiskDrive. The drive we are looking for will be in the form \\\\.\\PHYSICALDRIVE(enumeration(enumeration) where (enumeration) is the bit we found out above. The PNPDeviceID is the full non-volatile serial number which with a bit of parsing we can retrieve the actual serial number.

It may sound confusing reading the above so the best thing to do is look at the attached source. I have wrapped it all up into a class that can be called as follows:

USBSerialNumber usb = new USBSerialNumber();
string serial = usb.getSerialNumberFromDriveLetter("f:\"Wink;
MessageBox.Show(serial);

You can download the class by clicking the image below:

Download USBSerialNumber Class

Hope you like it and it saves you some time!

UPDATE Thursday 10th May 2007
You can download a test project from here : USBSerialNumberTest.zip

Tags: .NET | My Work
Add to your del.icio.us    DIGG This!    Technorati Cosmos Link    Post to Reddit    Add to your Furl    Add to Blinklist
Comments [22] - Leave a comment
2007-01-19 13:16:00.0

Free Remote Help Applications

Frequently we get alot of requests for help from customers and friends in the ColdFusion Community. Alot of the time their applications are behind firewalls and the problem cant be recreated our side so remote desktop type applications really are a huge help and time saver.

I used to use MS Messenger Remote Assistance but lately it is so unreliable and for months now I havent been able to connect to a single remote user.

Co-Pilot (www.copilot.com) is good but I found 2 free alternatives today that may help other companies in the same boat as us.

I am sure there are more out there and would love to hear other peoples suggestions and solutions.

I will post up my experiences with both these apps in time.

Tags: Tools
Add to your del.icio.us    DIGG This!    Technorati Cosmos Link    Post to Reddit    Add to your Furl    Add to Blinklist
Comments [8] - Leave a comment