Categories
Geeky/Programming

Revenge on Numlock!

Well, since I didnt want to page the IT Department, instead, I just wrote a program to handle my problem. Code around IT I always say. .NET 2.0, created a small program to watch keyboard strokes, and if NumLock is on, put a systray icon down there, lime green with a big N. Set it up to run when I login, so I should be good to go. The code is not pretty at all, so I’m not going to post it, but if someone wants to see, let me know and I will share, maybe you can even improve it 🙂

Categories
Geeky/Programming

Numlock on a Laptop

I use a laptop day to day, and when I have it docked, I use a keyboard, that I turn numlock on. When I undock and start using my laptop again, numlock is on, and its hard to tell it is, about the only way I can is by typing and seeing that letters are turning into numbers. I think there almost needs to be an on-screen notification that numlock is on, or something, because I have been foiled by the numlock gods too many times, I couldnt login to VPN tonight for a while because it wouldnt take my password, well, it would, but I had numlock on. I guess I could make my passwords to be out of the range of the laptop numlock keys, right 🙂

Categories
Geeky/Programming

SHGetFolderPath on Windows 98

SHGetFolderPath doesn’s seem to work on Windows 98. If you use it to try  to find like the “My Pictures” directory,  it will error out.  I have read that some versions of Win98 do work, depends on the version of shell32.dll (5 and greater). A workaround that you can use , which probably isn’t 100%  good, but works is looking for the My Pictures path in the registry  (HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerShell Folders). Just another quirky thing with the different Microsoft OS’s.

Categories
Geeky/Programming

strcpy vs. strncpy

strcpy – Copies the content pointed by src to dest stopping after the terminating null-character is copied.
dest should have enough memory space allocated to contain src string.

strncpy – Copies the first num characters of src to dest.
No null-character is implicitly appended to dest after copying process. So dest may not be null-terminated if no null-caracters are copied from src.
If num is greater than the length of src, dest is padded with zeros until num.

Now, maybe I just dont know, but why would you use strcpy when strncpy is available? I guess I really havent found a solid answer. I mean what were they thinking with strcpy? Were they just trying to create an easy way to have buffer overflows all over? (Same goes for strcat and strncat). I guess I am glad now to use C# and VB.net the majority of the time when you really don’t have to worry about this stuff. With C/C++ its all over the place, and you can tell, just look at all the buffer overflow vulnerabilites withing Microsoft products.

Categories
Geeky/Programming

Kill.exe and EnableDebugPriv()

The last few days, I have been looking into a solution to kill a process in c/c++ – but not just any process, a ScreenSaver running while the computer is locked. Most examples on MSDN and such terminiate processes by sending close messages to them, and 99% of the time that works. It even works for ScreenSavers that are running while the computer is locked. Thing is, I didnt want to bundle kill.exe that comes on the Windows NT Resource kit. Off to search google, pskill by sysinternals works too, but again with the bundling. Search the net some more, I found a link to the kill.exe source code from MSDN. The big difference in this code compared to all other kill examples, is this

//
// Obtain the ability to manipulate other processes
//
EnableDebugPriv();

That opened the door for the kill.exe to stop a process when the computer was locked 100% of the time. Im sure there is some long explination dealing with user mode and kernel mode code, maybe someone can comment on and shed some more light on the subject. I have attached the source code that I found here just in case the site it was on goes down. Well, in the end, we ended up getting the program to kill the process while the computer was locked, so it worked out well 🙂

Categories
Geeky/Programming Product Reviews

ScaleOut StateServer

ScaleOut Software has a product to manage sessions on a web farm. I have tried this product and have had nothing but issues. I did actually end up getting it working once, but it turns out, even when it does work correctly, it gives your network problems

It seems that the fix for any issue is “You arent running the latest version” – which might be true, but many times, we would be running version 1.3.2 for example that we downloaded two days ago, and then they release 1.3.2.1 the day after we downloaded 1.3.2 – this is a cop out in saying that its on our end, when in reality it is just buggy software that has releases every other day to fix bugs. I dont know if there is any other competing product in the market right now though, so they kind of have it locked. You can use Microsoft’s ASP.Net Session provider, but that is limited when in a farm scenario. Using MSSQL for your sessions has performance issues. I have heard that ex-microsofties tell people to just roll their own, but that seems too much, especially in a small shop. Hopefully ScaleOut gets more stable, because it could be a good product, if it just didn’t cause issues 🙂

Categories
Geeky/Programming

Vista Beta 2

Well, tonight I took the plunge and installed Microsoft Windows Vista Beta 2 on my Dell PC at home. I am liking it so far. Alot of security alerts. Its always nice to start digging into the new technology as soon as you can. I have tried a few programs and found they don’t work, you would think that software makers would be starting to test and have updates, etc. Hopefully by the time of launch we will see more app compatability, etc. It is a memory hog (runs at 800 mb constant), but I guess that is expected with the video/display changes (Aero). I’m actually going to try to use IE7 and see how well it works, instead of Firefox, until I can’t stand it anymore. Anyone know of any cool tricks in Vista that arent there in XP?

Categories
Geeky/Programming

Office 2007 Beta 2

I installed Office 2007 Beta 2 – seems like some things are not there, but expected for a beta. The new categorizations are cool, but the search folder for them doesnt work. Also, RSS Feeds folder is cool, but my opml from newsgator online wont import, dont know why either. Dug through the help, but didnt find anything that said why it might not insert…but I am liking it so far..

Categories
Geeky/Programming

Pocket PC and GPS

For my birthday, I got Microsoft Streets and Trips 2006 with GPS Locator and I also then bought a Pharos Bluetooth GPS Dock to use with my Sprint Audiovox PPC 6700. I tested it out yesterday and it works great. Now I have GPS location capablities with my phone, in my car, etc. My next step is to write an app for the phone to save up the coordinates to a web service, and map it out, so I can track where I have been, my routes, etc. I can also have a “Where is Steve?” page 🙂

Categories
Geeky/Programming

VS2005 Unit Testing HttpContext Cache

been searching for a while on how to test HttpContext and Cache in VS2005 Unit Tests, using the built in unit testing suite. Found this today..just add

TextWriter tw = new StringWriter();
HttpWorkerRequest
wr = new SimpleWorkerRequest(“/webapp”, “c:inetpubwwwrootwebapp”, “default.aspx”, “”, tw);
HttpContext
.Current = new HttpContext(wr);

to you test method and the correct “using” statements, and boom – it works – up goes your code coverage % 🙂