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 🙂
Tag: Development
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 🙂
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.
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.
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 🙂
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 % 🙂
Microsofts ActiveX Debacle
Funny, Microsoft had to change the way they handle ActiveX in the browser because they lost a patent…well, Outlook Web 2003 succumbs to the change, as in a new message, it asks you to hit enter or tab to activate the control. What a waste…you would think they could have a better workaround or just pay licensing on the patent.
I had a need to customize a cc.net project list, and if you install CCTray, in c:Program Filescctray you will see 3 dll’s.
ThoughtWorks.CruiseControl.CCTrayLib
ThoughtWorks.CruiseControl.Remote
NetReflector
Note: If you have the latest CCTray installed, then you will have to develop any custom application in .NET 2.0
So first this, you need to reference those 3 dll’s, and add a using statement to your code
.csharpcode { font-size: small; color: black; font-family: Courier New , Courier, Monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }
using ThoughtWorks.CruiseControl.CCTrayLib.Configuration; using ThoughtWorks.CruiseControl.CCTrayLib.ServerConnection; using ThoughtWorks.CruiseControl.Remote;
RemoteCruiseManagerFactory factory = new RemoteCruiseManagerFactory(); ICruiseManager manager = factory.GetCruiseManager("tcp://buildserver:21234/CruiseManager.rem"); ProjectStatus[] projectStatuses = manager.GetProjectStatus(); foreach (ProjectStatus status in projectStatuses) { //status.Name; = Project Name //status.WebURL; = Web URL for the cc.net project //status.BuildStatus.ToString(); = cc.net build status }
Well, I spent more time trying to format the code on this post than actually coding the program, so that stinks. I wish it wasnt such a pain to preserve formatting
Sounds like some dating gameshow, where you are of the winner..and the date you get is someone you just aren’t sure of. Anyways, if you see this error in VS2005 (asp.net), what I have seen it means is: you have some control variables decalred in your codebehind file, and they are also declared in the designer.cs file. To fix, just remove them from the codebehind file and it should build. If you are using Web Application Projects, I have also seen that using “CodeFile=” instead of “CodeBehind=” doesn’t work when you goto deploy. It seems that CodeFile wants the .cs file to be present, and I am guessing most people dont want to deploy their source code along with their aspx files. Happy Coding 🙂
If you are using VS2005, and using the add on for Web Application Projects, you probably have hit Scott Guthrie’s tutorial One tip I can share: turn off optimizations in your VS2003 project before upgrading, or before you try debugging once you have upgraded, it will throw up an error. Other than that, most of the issues you will see will be from Namespace conflicts, or file naming conflicts (Profile, Roles, etc).