Loading Generic Types with Assembly.LoadFrom

I thought I’d write up a question I posed today on StackOverflow here: Loading a generic type using Assembly.LoadFrom

I had a pre-existing method that I use to get a type based on a full assembly path and a class name. This resides in a Utils namespace.

Continue reading Loading Generic Types with Assembly.LoadFrom

Determining the state of modifier keys when hooking keyboard input

As part of a utility I was writing recently I wanted to hook keyboard input. In particular I was interested in global hooks (ie input to any program, not just mine), and I needed to handle complex key inputs, for example Ctrl-Alt-G, i.e. keys plus modifiers. The usual way to do this is to use SetWindowsHookEx.

Looking around I quickly found a class over on CodeProject here. The globalKeyboardHook class deals with the hooking, allows you to specify which keys you are interested in and disregards the rest. The events are raised using the delegate type KeyEventHandler. KeyEventHandler uses KeyEventArgs and has easily referenced properties for each of the modifier keys. So far so good.

However I found that the instance of KeyEventArgs I was receiving in my event handler never had the modifier properties set to true. Looking at the code for the class I couldn’t see anything there that would set the properties in the call back function for SetWindowsHookEx.

Continue reading Determining the state of modifier keys when hooking keyboard input

Crystal Reports – setting login credentials through code

I just answered a stackoverflow question regarding a common issue when using Crystal Reports as part of a wider application – setting login credentials through code. Its not as straight forward as it really ought to be.

Rather than simply setting the login/server/database details through a single call there are a number of things that are required:

Continue reading Crystal Reports – setting login credentials through code