Add browser action button in internet explorer BHO

EDIT: https://github.com/somanuell/SoBrowserAction Here is a screen shot of my work in progress. The things I did: 1. Escaping from the protected mode The BHO Registration must update the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Low Rights\ElevationPolicy key. See Understanding and Working in Protected Mode Internet Explorer. I choose the process way because it’s noted as “best practice” and is easier … Read more

categories and standard/system error codes

I have to admit to a bit of surprise at the confusion regarding <system_error> given Chris summarised exactly how it works at http://blog.think-async.com/2010/04/system-error-support-in-c0x-part-1.html and I personally find the C++ standard text above perfectly clear. But to summarise in very succinct words: If on POSIX: generic_category => POSIX standard errno space system_category => Local POSIX errno … Read more

Windows API: ANSI and Wide-Character Strings — Is it UTF8 or ASCII? UTF-16 or UCS-2 LE?

Are those above all correct? Yes, if you don’t assume the existence of characters not encoded in Unicode (for most practical applications, this assumption is fine). Do the Windows “A” functions (like SetWindowTextA) take in ASCII strings? Or “multi-byte strings” (more questions on this below)? They take byte strings (i.e., strings whose code unit is … Read more

Can a Win32 console application detect if it has been run from the explorer or not?

See http://support.microsoft.com/kb/99115, “INFO: Preventing the Console Window from Disappearing”. The idea is to use GetConsoleScreenBufferInfo to determine that the cursor has not moved from the initial 0,0 position. Code sample from @tomlogic, based on the referenced Knowledge Base article: // call in main() before printing to stdout // returns TRUE if program is in its … Read more

Wiggling the mouse

for C# 3.5 without notifyicon therefore you will need to terminate this application in task manager manually using System; using System.Drawing; using System.Windows.Forms; static class Program { static void Main() { Timer timer = new Timer(); // timer.Interval = 4 minutes timer.Interval = (int)(TimeSpan.TicksPerMinute * 4 / TimeSpan.TicksPerMillisecond); timer.Tick += (sender, args) => { Cursor.Position … Read more

C++/Win32: How to wait for a pending delete to complete

There are other processes in Windows that want a piece of that file. The search indexer is an obvious candidate. Or a virus scanner. They’ll open the file for full sharing, including FILE_SHARE_DELETE, so that other processes aren’t heavily affected by them opening the file. That usually works out well, unless you create/write/delete at a … Read more

Find process id by window’s handle

You can use the following Windows API: [DllImport(“user32.dll”, SetLastError=true)] static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint processId); You pass in the HWND and use the out parameter to return the PID. You can read more on this function here on MSDN.

How to get screen resolution in C++? [duplicate]

#include “wtypes.h” #include <iostream> using namespace std; // Get the horizontal and vertical screen sizes in pixel void GetDesktopResolution(int& horizontal, int& vertical) { RECT desktop; // Get a handle to the desktop window const HWND hDesktop = GetDesktopWindow(); // Get the size of screen to the variable desktop GetWindowRect(hDesktop, &desktop); // The top left corner … Read more