Thursday, January 28, 2010

Misc tricks on Windows Development

Another two trick I discovered recently:

1. How to unlock a file/directory that is locked by a unfriendly process?
On Windows, you cannot delete or rename (move) a file/directory if it is
locked by a process. There is a way to do it (CreateRemoteThread). See
http://social.msdn.microsoft.com/Forums/en-SG/csharpgeneral/thread/9e2044c5-ae5d-4552-a335-01cc567dfc58. But if I want a tool to do it, then,
Unlocker is all you need.

2. How to check memory leak on Windows?
Well, using MSVC runtime, you can use the crtdbg interface. The post is here:
http://msdn.microsoft.com/en-us/library/e5ewb1h3%28VS.80%29.aspx

NTP on Windows

Time is important. Very! Few Windows users really care about
whether there computer clock is right or not. But as an IT professional,
we all know very well that. The time is IMPORTANT.

Recently, I have been annoyed by the fact that my Thunderbird order
my emails wrongly because of my local Windows machine's time is not
correct. Well the time stamp in the email is the client-side's time stamp,
not the server-side one. What can I do? I think I can just ensure that
at least, my machine has the correct time. I know very well how to set up
a NTP client in the *NIX world. But how to do it on Windows? I didn't find
a way from the GUI (Control Panel). So I Google researched a bit.
Below is the excerpt from the Microsoft site:

To configure a client computer for automatic domain time synchronization
  1. Open a Command Prompt.

  2. Type the following command and then press ENTER:

    w32tm /config /syncfromflags:domhier /update

  3. Type the following command and then press ENTER:

    net stop w32time

  4. Type the following command and then press ENTER:

    net start w32time

This way, your Windows machine get the time from the domain controller.
You can also get the time from specified NTP server. Just need to change
to :
w32tm /config /syncfromflags:manual /manualpeerlist:servername /update

I love command line.