Archive

Archive for January, 2008

Vista: Slow Start Menu

January 20th, 2008

I was surprised that vista seemed as if not more responsive than windows XP, that was until my start menu started lagging… ALOT!

Happily this is one of the issues that the oracle had an answer for on the first page here. Seems someone made a HUGE blunder and the feature that highlights new programs KILLS performance in the start menu. Thank you, V7 Network, and thank you Google!

So, go to properties for taskbar under start menu->customize and remove the highlighting feature at once!

felizk OS

Accessing Network Drive is Slow in Vista

January 20th, 2008

I have a fine little laptop with Windows XP installed running with a 1TB hd attached to it. It is shared and I want to connect to it and watch the stuff.

Problem is on vista listing the root directory of that network share is SLOOOW. I created a network drive mapped directly to the share \\192.168.30.31\e -> T: but it is still slow as ass compared to my brothers windows xp.

Turns out. For some unfathomable reason Vista looks up the DNS before connecting to the network drive. It looks up the ISP DNS before connecting to the network drive that is on a local network and referenced by IP! I was running OpenDNS and changing that to by ISP’s DNS server sped things up, but im still in the dark here about why it would connect to a DNS server in the first place.

felizk Personal

Disable PC-Speaker

January 20th, 2008

My newly installed Windows Vista insisted upon beeping when making a selection in some listboxes, so I had to put the PC-speaker down!

Found the instructions here Benchodroff:

  1. To test the problem, open a command prompt and try typing “echo “, then press ctrl and the ‘g’ key, then press enter. Beep!
  2. In the control panel, go into the System Device Manager.
  3. From the View menu, select “Show Hidden Devices”
  4. In the Non-Plug and Play devices, disable the “Beep” Device (Properties, “Driver” tab, Set the startup to disabled and stop it)
  5. To test the solution, open a command prompt and try typing “echo “, then press ctrl and the ‘g’ key, then press enter. No beep!

After a restart it worked flawlessly :]

felizk Personal

Back to Windows Live Writer + EjectDisk

January 16th, 2008

Lets try this once more, it looks snappier anyhow and (the defining point of me trying again) It has a plugin that allows me to paste code directly from Visual Studio highlighted and everything-

OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == DialogResult.OK)
{
    filePath = ofd.FileName;
    button1.Enabled = true;
    label1.Text = Path.GetFileName(filePath);
}

Works pretty nicely :) All I need now is a way for this program to upload a file as well.

I also installed Ben Hall’s Visual Studio Solution Uploader and the program below is a test of that:

Download EjectDisk

It is a libray for ejecting USB disks, it is based on UsbEject by Simon Mourier, the link is his CodeProject article. UsbEject has an error that makes it unusable when more than one disk is attached, it is detailed a little in the comments of Simon’s article, but it is basically that to know which volumes are attached to which harddisks an index is need for the harddisk, the index is readily available using WMI. I resolved it using WMI, regrettably I was unable to find a solution that doesn’t use WMI.

EjectDisk also has a command line utility that can eject a disk by volume name eg: Eject.exe g:

felizk Programming

More Network Drive Headache

January 6th, 2008

From the ashes into the fire! Yesterday I wanted to detect connection and disconnection of a network in order to have my program be aware if a network drive is available or not. Today, the networked computer is offline and my network drive therefore entirely unavailable. Problem is, every time I enumerate Drives with DriveInfo.GetDrives() and subsequently ask di.IsReady on the network drive, the program blocks for around 10 seconds while trying to asses if the Drive is available.

Unacceptable! So I need to know if the computer that has the network drive is actually available.

Step 1: Get the UNC Path for the network drive. More difficult than I thought but solved using some P/Invoke, found a managed library that wraps WNet functions on CodeProject at: http://www.codeproject.com/KB/dotnet/DotNetWrapperForWNet.aspx

Step 2: Get the host part of the UNC Path. Quickly done using a small Regex: @”^\\\\([^\\]+)\\” grab group 1.

Step 3: Attempt to create a connection to the host on the Windows Sharing TCP Ports 445 and 139  (found using the oracle) . The kicker here is that it will take, you guessed it, exactly as long as when trying to access the networked drive directly. Here is where we apply some restrictions. By adding a shorter timeout for the connection say… 1 second. This is done using the asynchronous function BeginConnect on a Socket.

If it fails to create a connection within the timeout, well, then we assume the network drive is not available. Just as with DriveInfo.IsReady but with a substantially shorter timeout.

If a connection is made, then we can call the IsReady function on it without fearing the dreaded 10+ second delay.

felizk Personal

New Article on CodeProject

January 5th, 2008

I posted an article on CodeProject about Type-Strong Asynchronous Execution which details a small static class of convenience. Check it out here.

felizk Personal

Detecting network connection / disconnection in C#

January 5th, 2008

While working on using Network Drives with my media center application, I needed a way to detect when a network card was connected and when it was disconnected. First off I thought WMI might be a nice way to do this. This lead me to the MSNdis classes. But I was only able to detect when cables we’re connected (or wireless found a network) and what I needed was an event when the net was ready for me to try to connect to a network drive. More searching brought me to the Win32_NetworkAdapter WMI class which is pollable to get the information I need. But not really a great solution.

Finally, as with so many other things, I found that the functionality is neatly managed within the .NET framework, in the System.Net.NetworkInformation.NetworkChange class. Which did exactly what I needed. It has a NetworkAddressChanged function which I used to get the functionality.

My MSNdis adventure lead to these two sites which helped me try out the features:

http://www.dotnet247.com/247reference/msgs/43/219074.aspx (in the very bottom there is a code snippet for C#)

http://www.microsoft.com/china/MSDN/library/enterprisedevelopment/softwaredev/art/ISmsdnmagissues0208senstocfig05.htm (describes a list of MSNdis events)

There are loads of info in Win32_NetworkAdapter on the net, try running it through google :)

felizk Programming