30 June 2014

Solve Unknown Device Issue

f you are getting “Unknown Device“ issue.
Please follow the step by step procedure:
1) Go to Windows Registry.
2) Click “HKEY_LOCAL_MACHINE”
3) Click “SYSTEM”
4) Click “CurrentControlSet”
5) Click “Services”
6) Click “USBSTOR”
7) Check Data of “Start” (in the Right side of the Screen)
         Data is 0x00000003(3) -- USB Port works fine.
         Data is 0x00000004(4) -- USB Port doesn’t work fine.  

29 June 2014

keyword var and dynamic

A: Dynamic and var represent two completely different ideas.
var:
var essentially asks the compiler to figure out the type of the variable based on the expression on the right hand side of the assignment statement. The variable is then treated exactly as if it were explicitly declared as the type of the expression. For example the following two statements are equivalent
var a = "foo";
string a = "foo";
The key to take away here is that "var" is 100% type safe and is a compile time operation.
dynamic:
Dynamic is in many ways the exact opposite of var. Using dynamic is essentially eliminating all type safety for that particular variable. It many ways it has no type. When you call a method or field on the variable, the determination on how to invoke that field occurs at runtime. For example
dynamic d = SomeOperation();
d.Foo(); // Will this fail or not?  Won't know until you run the program
The key to take away here is that "dynamic" is not type safe and is a runtime operation.

28 June 2014

set the process priority

o set the process priority, we  can set the Process.PriorityClass property. PriorityClass is captured in the ProcessPriorityClass enumeration, which lets us set the process priority to Idle, Normal, High, AboveNormal, BelowNormal, or RealTime.   Process.BasePriority is an integer value property and is read-only.
The following table shows the relationship between the BasePriority and PriorityClass values:
BasePriority            PriorityClass
4 Idle
8 Normal
13 High
24 RealTime
Note:
In Windows 98, and the Windows Millennium Edition Platform, setting the priority class to AboveNormal or BelowNormal causes an exception to be thrown.
How do I capture a screenshot of a process’s main window?
Here is one method to take a process screenshot.  We will use the process “notepad” for this example.   Please follow these steps:

1.   Use System.Diagnostics.Process.MainWindowHandle to get the process information we require to take a screenshot.
2.   Use the Windows API, SetForegroundWindow, to activate the target process.
3.   Pass the window handle to the first parameter of the Windows API GetWindowRect, to get the location information of the target process.
4.   Define the coordinates of the process window on the screen with the location information in step 3.
5.   Use the coordinates in step 4 and Graphics.CopyFromScreen to take the screenshot.