Techie Talks

Friday, February 18, 2005

C# Arrays

Array handling in C# is different from that in C++ or C.

To declare a 1D array:

int[] test1DArray = new int[10]; // All arrays needs to be instantiated.

test1DArray[1] = 10; //To access

To declare a 2D rectangular array:

int[,] test2DRArray = new int[10,20];

test2DRArray[1,2] = 10; //To access

To declare a 2D jagged array (where each row can contain different no. of columns):

int[][] test2DJArray = new int[3][];

test2DJArray[0] = new int[1];
test2DJArray[1] = new int[2];
test2DJArray[2] = new int[4];

test2DJArray[2][3] = 10; //To access

Wednesday, February 16, 2005

Slow response on right clicks

The problem at hand is this: My PC at my lab, running Windows XP, was taking incruciatingly long time, at times around 30 seconds, to pop up the menu when right clicked on any "application" file, like doc, jpg, mp3 etc. However, it was working fine on exe files. Moreover, when double clicked on an application file, it was taking approximately the same long delay to launch the application.

I started the trouble shooting by first looking through the task manager to see what process moves up in CPU time / memory usage when I right click an application file. That provided me with no great information as "explorer.exe" got up the list, however not taking much resources. I did an antivirus check, a spyware check etc., as well, but did not help. Then, I tried disabling the firewall, uninstalling Norton Antivirus, stopping IIS etc, as mentioned in some other forums.

It was when I was about to give up and was thinking about backing the data and reformatting the computer that I learnt about a tool by name "FileMon.Exe" which monitors the files accessed by other files - didn't help! However, from the same site that provides FileMon, http://www.sysinternals.com/, I found a new utility called RegMon.Exe that monitors the activity on the registry and the various registry keys accessed by other programs. This one proved to be my saviour when I found that explorer.exe was the one taking too much time when I right click or launch an application file. However, explorer.exe was spending this time to probe the photoshop executable, may be to check file associations. This prompted me to uninstall Photoshop, but even after this, RegMon.exe continues to show that a registry key with the Photoshop executable as value was being probed and most of the time was spent there. Now, I did a search in registry using RegEdit and removed all values/keys that contains "Photoshop". I closed regedit, and, voila! the menus now pop-up with a bang!!

So... next time,some similar problem arises... RegMon is my man!

Monday, February 14, 2005

Passing by reference in C#

Here is the way to pass values by reference in C#.

Function Declaration
void myFn(int x, ref int y)
{
x = 5;
y = 10;
}

Function call

int i,j;
i = 2; j = 3;
myFn(i, ref j);


Here, i is passed by value to x and j is passed by reference to y.

Sunday, February 13, 2005

Some essential Type convertions in C#

To convert from numerical datatypes like int, short, float, double etc., to string, use the ToString method of the numerical classes.

Eg:-

int x = 10;
String S = x.ToString();

To convert string to numerical datatypes, use each class's Parse function.

Eg:-

String S = System.Int32.Parse("10");

Tuesday, February 08, 2005

Userlist Missing!!

The situation is this: Karthik's lab computer, with Windows XP installed, boots up normally. But when it reaches the Logon screen, it asks to click on any "listed" username... But to our great suprise, we see no users listed. We tried the double Ctrl+Alt+Del to login via the conventional, Windows 2000 style, "text-box" based logon screen... It kicked out Administrator as well as Karthik, two of the three users of the system.

Now, the regular troubleshooting sequence was tested... Restart... Safe Mode... Last Known Good Config... Naada! Nothing worked!! From the forum http://www.experts-exchange.com (Karthik paid 10 bucks for a 1 month membership!!!), the most important information I gained was abt the s/w Offline NT Password Registry Editor. http://home.eunet.no/~pnordahl/ntpasswd/. The software can be downloaded free of cost and can be burnt onto a CD which will be bootable. Once booted from the CD, it loads a linux kernal and asks a few questions, answering which one may alter tha password of any user of the system, including adminstrator. The gist of the s/w, I think, is that it knows how to decode the cryptic password information stored in the registry's SAM file (usually found in \winnt\system32\config and is a part of registry).

The site says abt SAM:

"NT stores it's user information including crypted versions of the passwords in a file called 'sam', usually found in \winnt\system32\config. This file is a part of the registry, in a binary format previously undocumented, and not easily accessible. But thanks to a German(?) named B.D, I've now made a program that understands the registry. As far as I know, Microsoft provides no way of changing the password if you cannot log in as someone with appropriate privileges, except restoring the registry files from the rescuefloppy. "

However, in his case, it didnt work, because it found no users in the registry. That means that the users part of his registry might have been corrupted.

The next arrow in my quiver was to repair-intstall XP on his comp! But that too gave up on me, because it just restored the system files without touching the registry.

Finally, unfortunately, we had to use the pick-axe method - To format C: and reinstall windows!

The reason for the failure of userlist is still unknown. For me, it looks like something needs to be done regarding his power-supply, because power from it made my laptop touchpad go crazy, and this is the second time within a month where his system had to be restored this way. (The first time, it was some "security service failure" error even before it reached the login screen, which, again, remains anonymous to me till date).

Touch(me not?)pad Vs Laptop power

This happens on Monday, Jan the 6th, when I was at Karthik's lab to trouble shoot a problem (will post that abt interesting problem soon) with his comp... I was carrying my laptop with me , as usual, and started working on it from his lab to look up some info on google abt his comp probs.. Just then, my touch-pad was behaving like a touch-me not! It started to move my cursor erratically... And, the cursor behaved as if it were on an old car having starting problems... As always, with sleight of hand of an ex-IT help desk specialist of Chemical Engg dept (TTU), I did all troubleshooting I knew with Windows, including RESTARTING!!! Boy! Rarest ever, Windows was naughty with my mouse arrow, even after that..

However, the reason this time was "close" to restarting.. This time, surprisingly ever, the touchpad behaved properly when I unhooked the power from my laptop... Strange! Strange!

"Ok", I said.. Whatever, it work, alright.. so decided to listen to some songs via Karthik's speakers connected to my laptop (Scene unlimited!!).. and voila! the mouse arrow was mocking me again!! This time again, I guess the problem would be power itself, because the speaker was connected to the same outlet as to where I'd connected the power supply for my laptop...

Hmm.. that was a another great session with trouble shooting Karthik's Lab-top!

Aloha

A few days back, I was correcting my friend's use of "Chow" where she intended "Ciao", to say Good Bye.. From dictionary.com, I found out that "ciao" is of Italian origin and it means "I am your slave / servant". It also mentioned that a similiar term in Hawaiian is "Aloha"... As a reply to this message to my group (http://groups.yahoo.com/group/nsscse99), my buddy Arun replied that we have seen the word "Aloha" in the context of networking in the book "Computer Networks" by Andrew S. Tanenbaum, the "Networking Bhagavad Geetha" for me... The same was mentioned to me by my buddy ("buggy" ??) Karthik as well...

Back to Aloha, I havent paid much attention to it so far, but, when I googled for "Aloha networking", here is what I found from Webopedia.com:

"A protocol for satellite and terrestrial radio transmissions. In pure Aloha, a user can transmit at any time but risks collisions with other users' messages. "Slotted Aloha" reduces the chance of collisions by dividing the channel into time slots and requiring that the user send only at the beginning of a time slot. Aloha was the basis for Ethernet, a local area network protocol."

The other listing for this words in the site are as follows:

"Aloha Networks, Inc. -- A San Francisco-based company specializing in providing satellite-based Internet access to large Internet Service Providers. Founded by the inventor of the Aloha system, Norman Abramson.

@loha @home -- software from Media Synergy (www.mediasyn.com) that allows a user to add graphics, animation, and sound to e-mail messages. "

Now that I know what Aloha is, i think its time to say "Aloha"....