[-+]?[0-9]*\.?[0-9]+ This is to get double value
http://www.regular-expressions.info/floatingpoint.html
Thursday, February 9, 2012
Tuesday, January 31, 2012
Elevate the process to run with admin mode
http://msdn.microsoft.com/en-us/library/bb756929.aspx
Create an name.exe.manifest
level="requireAdministrator"
uiAccess="false"/>
VS Command prompt : mt.exe -manifest menu.exe.manifest -outputresource:menu.exe;#1
Post build event:
"$(DevEnvDir)\..\Tools\Bin\mt.exe" -manifest "$(ProjectDir)$(TargetName).exe.manifest" -outputresource:"$(TargetDir)$(TargetName).exe;#1"
For VS2010,
Project Properties > Configuration Properties > Linker > Manifest File
Change the 'UAC Execution Level' to the desired value.
Pasted from
Create an name.exe.manifest
level="requireAdministrator"
uiAccess="false"/>
VS Command prompt : mt.exe -manifest menu.exe.manifest -outputresource:menu.exe;#1
Post build event:
"$(DevEnvDir)\..\Tools\Bin\mt.exe" -manifest "$(ProjectDir)$(TargetName).exe.manifest" -outputresource:"$(TargetDir)$(TargetName).exe;#1"
For VS2010,
Project Properties > Configuration Properties > Linker > Manifest File
Change the 'UAC Execution Level' to the desired value.
Pasted from
Thursday, January 12, 2012
C# friendly user app
Place the cursor to the box that user want by setting tab order correctly
hit enter to do some default value by handling control key press event
use this.width, this.height to get window position
//to get active window size
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern IntPtr GetForegroundWindow();
private static IntPtr GetCurrActiveWindow()
{
IntPtr handle = IntPtr.Zero;
return GetForegroundWindow();
}
[System.Runtime.InteropServices.DllImport("user32.dll")]
[return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
private static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}
public static RECT GetCurrActiveWindowSize()
{
RECT size = new RECT();
try
{
GetWindowRect(GetCurrActiveWindow(), out size);
}
catch (Exception ex)
{
TraceMessage.Write("QTMUtility.GetCurrActiveWindowSize", ex.Message, TraceMessageType.Exception);
}
return size;
}
hit enter to do some default value by handling control key press event
use this.width, this.height to get window position
//to get active window size
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern IntPtr GetForegroundWindow();
private static IntPtr GetCurrActiveWindow()
{
IntPtr handle = IntPtr.Zero;
return GetForegroundWindow();
}
[System.Runtime.InteropServices.DllImport("user32.dll")]
[return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
private static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}
public static RECT GetCurrActiveWindowSize()
{
RECT size = new RECT();
try
{
GetWindowRect(GetCurrActiveWindow(), out size);
}
catch (Exception ex)
{
TraceMessage.Write("QTMUtility.GetCurrActiveWindowSize", ex.Message, TraceMessageType.Exception);
}
return size;
}
Tuesday, November 1, 2011
Access command line arguments in C#
There are two common ways to read command line arguments in C#. First, you can override the Main method with an array of strings, which are command line arguments. For example, the following code loops through the command line arguments and print them on the console.
static void Main(string[] args)
{
foreach(string arg in args)
{
Console.WriteLine(arg);
}
Console.ReadLine();
}
You can do so using the Environment class, which has a static method called GetCommandLineArgs, which returns an array of strings containing the arguments. The following code reads the command line arguments using Environment.GetCommandLineArgs method.
foreach (string arg in Environment.GetCommandLineArgs())
{
Console.WriteLine(arg);
}
static void Main(string[] args)
{
foreach(string arg in args)
{
Console.WriteLine(arg);
}
Console.ReadLine();
}
You can do so using the Environment class, which has a static method called GetCommandLineArgs, which returns an array of strings containing the arguments. The following code reads the command line arguments using Environment.GetCommandLineArgs method.
foreach (string arg in Environment.GetCommandLineArgs())
{
Console.WriteLine(arg);
}
Tuesday, October 25, 2011
Run the application in admin mode
You'll want to modify the manifest that gets embedded in the program. Works on VS2008 + 2010: Project + Add New Item, select "Application Manifest File". Change the element to:
Adding a requestedExecutionLevel element to your manifest is only half the battle, you have to remember that UAC can be turned off, if it is, you have to perform the check the old school way and put up a error dialog if the user is not admin (Call IsInRole(WindowsBuiltInRole.Administrator) on your threads CurrentPrincipal)
http://msdn.microsoft.com/en-us/library/bb756948.aspx
Adding a requestedExecutionLevel element to your manifest is only half the battle, you have to remember that UAC can be turned off, if it is, you have to perform the check the old school way and put up a error dialog if the user is not admin (Call IsInRole(WindowsBuiltInRole.Administrator) on your threads CurrentPrincipal)
http://msdn.microsoft.com/en-us/library/bb756948.aspx
Thursday, September 22, 2011
Wednesday, September 14, 2011
Subscribe to:
Posts (Atom)