How to draw directly on the Windows desktop, C#?

Try the following: using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Runtime.InteropServices; class Program { [DllImport(“User32.dll”)] static extern IntPtr GetDC(IntPtr hwnd); [DllImport(“User32.dll”)] static extern int ReleaseDC(IntPtr hwnd, IntPtr dc); static void Main(string[] args) { IntPtr desktop = GetDC(IntPtr.Zero); using (Graphics g = Graphics.FromHdc(desktop)) { g.FillRectangle(Brushes.Red, 0, 0, 100, 100); } ReleaseDC(IntPtr.Zero, desktop); } }

How do I add exif data to an image?

You can save a large amount of space, especially if you have a large number of images.. Add the following to text.txt (format of the IPTC tags taken from here): 2#110#Credit=”My Company” 2#05#Object Name=”THE_OBJECT_NAME” 2#55#Date Created=”2011-02-03 12:45″ 2#80#By-line=”BY-LINE?” 2#110#Credit=”The CREDIT” 2#115#Source=”SOURCE” 2#116#Copyright Notice=”THE COPYRIGHT” 2#118#Contact=”THE CONTACT” 2#120#Caption=”AKA Title” Strip all existing exif data from the … Read more

Verbs that act after backtracking and failure

Before reading this answer, you should be familiar with the mechanism of backtracking, atomic groups, and possessive quantifiers. You can find information about these notions and features in the Friedl book and following these links: www.regular-expressions.info, www.rexegg.com All the test has been made with a global search (with the preg_match_all() function). (*FAIL) (or the shorthand … Read more

Why is the ELF execution entry point virtual address of the form 0x80xxxxx and not zero 0x0?

As Mads pointed out, in order to catch most accesses through null pointers, Unix-like systems tend to make the page at address zero “unmapped”. Thus, accesses immediately trigger a CPU exception, in other words a segfault. This is quite better than letting the application go rogue. The exception vector table, however, can be at any … Read more

How to set time to device programmatically

If you have the correct permission (see below), you can do this with the AlarmManager. For example, to set the time to 2013/08/15 12:34:56, you could do: Calendar c = Calendar.getInstance(); c.set(2013, 8, 15, 12, 34, 56); AlarmManager am = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); am.setTime(c.getTimeInMillis()); You need the permission SET_TIME to do this. Unfortunately, this is a … Read more