PInvoke, C#, Keyboard Settings, and My Manager (again)
If you have read my blog for a while, then you know about the app I wrote for my manager. There is an update to the story. He installed it, and it changed the Character Repeat as planned. However, it did not fix the problem.
Basically, my app changed a registry setting (KeyboardDelay). But, the change in the registry does not apply to currently open windows. If you have Control Panel open and make the change, you need to click Apply to apply the settings to all of the open windows.
Also, he may also need to have the KeyboardSpeed setting changed to solve his problem.
In either case, I needed to get the changes to apply to all open windows without doing anything ridiculous like a type of SendKeys call. This is the ultimate, definitive, worst kind of defeat.
Well, I figured out that SystemParametersInfo Win32 API function is exactly what I needed. This function accepts four parameters. The first is a numeric constant that specifies what setting is being changed. My need to change KeyboardSpeed is 11, and the constant is SPI_SETKEYBOARDSPEED. The second parameter is the speed (1-31), and the third and fourth parameters are 0.
Here's my insertion of the function for PInvoke:
[DllImport("user32.dll")] static extern bool SystemParametersInfo(uint uiAction, uint uiParam, object pvParam, uint fWinIni);
I can then call the function like this:
bool r ;
r = SystemParametersInfo(SPI_KEYBOARDSPEED, 31,0,0);
One modification I made is that the actual Win32 documentation shows that the third param is IntPtr, but I changed it to object. Sadly, we have no example anywhere I could find on MSDN (and I even manage the Office Developer Center on MSDN!) of setting the keyboard speed or delay using this API function. We show how to do a few of the other settings, but not these keyboard settings. I hope my blog helps some poor soul trying to figure it out.
I sent the .exe to my manager this morning, and I hope it works for him. I could use the positive points!
Finally, check out my latest posts about cycling on my personal blog. My co-worker and riding partner, Jeremy, also blogs about cycling.
Rock Thought for the day: My neighbor, Mike, handed over the Velvet Revolver CD, Contraband [clean version], this weekend and invited me to give it a listen. I have been wanting to evaluate this album since its release, but I had other album purchasing priorities. Now, I have been through each of the tracks, and here are my thoughts.
Scott Weiland has magnetic vocals with an unmistakable voice. His work in Stone Temple Pilots was first rate. It is never boring to hear Slash's chops with a carry-over of the distinctive effects from the GNR era. The Velvet Revolver album is likeable, but it is not ground-breaking in any way. The band of seasoned pro's prove that they can play it heavy and do a decent ballad. The last track, Loving the Alien, is the "anthem" song that I could easily imagine the crowd singing the chorus to at the end of a show (second encore, most likely). The strongest track was the first single from the album, Slither. It mixes the best of the talents from each band member into a diesel-powered monster tune. It's a great song.
However, I expected more. With all of the experience these guys bring to the table, they could have done more than be mostly conventional. Have a listen to The Smashing Pumpkins' first album, Gish, and you realize how much creativity these new-comers brought to the game. It's a stunning album in every way. Billy Corgan was a young kid really, and he pushed the boundaries in the right ways. Velvet Revolver colored well within the lines on their album. Relying on a muffled four-letter word to seem "edgy" is truly weak. The could have, should have done more with the songs and music.
Rock On
Comments
Anonymous
June 08, 2009
PingBack from http://hairgrowthproducts.info/story.php?id=7782Anonymous
June 15, 2009
PingBack from http://debtsolutionsnow.info/story.php?id=10447