How can I use EnumWindows to find windows with a specific caption/title?

Original Answer Use EnumWindows and enumerate through all the windows, using GetWindowText to get each window’s text, then filter it however you want. [DllImport(“user32.dll”, CharSet = CharSet.Unicode)] private static extern int GetWindowText(IntPtr hWnd, StringBuilder strText, int maxCount); [DllImport(“user32.dll”, CharSet = CharSet.Unicode)] private static extern int GetWindowTextLength(IntPtr hWnd); [DllImport(“user32.dll”)] private static extern bool EnumWindows(EnumWindowsProc enumProc, IntPtr … Read more

add elements to object array

You can try Subject[] subjects = new Subject[2]; subjects[0] = new Subject{….}; subjects[1] = new Subject{….}; alternatively you can use List List<Subject> subjects = new List<Subject>(); subjects.Add(new Subject{….}); subjects.Add(new Subject{….}); // Then you can convert the List to Array like below: Subject[] arraySubjects = subjects.ToArray<Subject>()

How to get current process name in linux?

If you’re on using a glibc, then: #define _GNU_SOURCE #include <errno.h> extern char *program_invocation_name; extern char *program_invocation_short_name; See program_invocation_name(3) Under most Unices, __progname is also defined by the libc. The sole portable way is to use argv[0]

How to create Select List for Country and States/province in MVC

public static List<SelectListItem> States = new List<SelectListItem>() { new SelectListItem() {Text=”Alabama”, Value=”AL”}, new SelectListItem() { Text=”Alaska”, Value=”AK”}, new SelectListItem() { Text=”Arizona”, Value=”AZ”}, new SelectListItem() { Text=”Arkansas”, Value=”AR”}, new SelectListItem() { Text=”California”, Value=”CA”}, new SelectListItem() { Text=”Colorado”, Value=”CO”}, new SelectListItem() { Text=”Connecticut”, Value=”CT”}, new SelectListItem() { Text=”District of Columbia”, Value=”DC”}, new SelectListItem() { Text=”Delaware”, Value=”DE”}, new … Read more

C++ How do I hide a console window on startup?

To literally hide/show the console window on demand, you could use the following functions: It’s possible to hide/show the console by using ShowWindow. GetConsoleWindow retrieves the window handle used by the console. IsWindowVisible can be used to checked if a window (in that case the console) is visible or not. #include <Windows.h> void HideConsole() { … Read more