winapi

Side effects of calling RegisterWindow multiple times with same window class?

I'm working on a little test application at the minute and I have multiple window objects floating around and they each call RegisterWindowEx with the same WNDCLASSEX structure (mainly because they are all an instance of the same class). The first one registers ok, then multiple ones fail, saying class already registered - as expected. ...

Get other running processes window sizes in Python

This isn't as malicious as it sounds, I want to get the current size of their windows, not look at what is in them. The purpose is to figure out that if every other window is fullscreen then I should start up like that too. Or if all the other processes are only 800x600 despite there being a huge resolution then that is probably what t...

Which are the differences between dialog|main/child/mdi windows ?

I need to understand the differences between windows main/mdi/child/dialogs.... how win32 messages should be propagated... why some messages are present in one type and not other... ...

Random MoveFileEx failures on Vista (access denied, looks like caused by search indexer)

I noticed that writing to a file, closing it and moving it to destination place randomly fails on Vista. Specifically, MoveFileEx() would return ERROR_ACCESS_DENIED for no apparent reason. This happens on Vista SP1 at least (32 bit). Does not happen on XP SP3. Found this thread on the internets about exactly the same problem, with no re...

Managing Window Z-Order Like Photoshop CS

So I've got an application whose window behavior I would like to behave more like Photoshop CS. In Photoshop CS, the document windows always stay behind the tool windows, but are still top level windows. For MDI child windows, since the document window is actually a child, you can't move it outside of the main window. In CS, though, you ...

ChangeServiceConfig problem setting logon credentials

I've got this weird problem - I'm calling ChangeServiceConfig on a newly installed service (I CreateService it myself) to supply the logon credentials, but while the function succeeds (returns TRUE), if I try to start the service, it fails with a 1069 (logon failed). If I go into the service manager and modify credentials by hand (I can ...

Borderless Taskbar items: Using a right click menu (VB6)

Even when BorderStyle is set to 0, it is possible to force a window to show up on the taskbar either by turning on the ShowInTaskbar property or by using the windows api directly: SetWindowLong Me.hwnd, GWL_EXSTYLE, GetWindowLong(Me.hwnd, Win.GWL_EXSTYLE) Or Win.WS_EX_APPWINDOW. However, such taskbar entries lack a right-click menu in ...

Best UI development framework on windows?

I have been developing UI in Win32/MFC, but developing cool UI in Win32/MFC is very difficult and time consuming. Please note, I always want my code to be platform independent, So I prefer programming back-end (Business logic) in C++. Which is the best framework for developing cool UI on windows platform? I heard of quite a few, like Q...

PrintDialog filter list of printers

I need to, preferably in C# - but c++ will do, find a way to filter the list of printers in the windows print dialog for any windows printing. I have come across WinAPIOverride and have figured I am going to have to write my own dll which overrides the method to get the printers list, then filter it and return it. I would then have to i...

Synchronized ListViews in .Net

I'm working on a control to tie together the view from one ListView to another so that when the master ListView is scrolled, the child ListView view is updated to match. So far I've been able to get the child ListViews to update their view when the master scrollbar buttons are clicked. The problem is that when clicking and dragging t...

How to execute GetLastError() while debugging in Visual Studio

You're stepping through C/C++ code and have just called a Win32 API that has failed (typically by returning some unhelpful generic error code, like 0). Your code doesn't make a subsequent GetLastError() call whose return value you could inspect for further error information. How can you get the error value without recompiling and repro...

How to remotely Start/Stop SQLServer services kicking off existing connections?

I know there is already a question about this but my issue is more oriented to remote scenarios. With net start/stop you can specify a /y parameter to bounce users off current sessions but you cannot start/stop remotely. With sc you can start/stop remotely but if the SQLServer instance is being used it won't let you stop the service (w...

How to launch a Windows process as 64-bit from 32-bit code?

To pop up the UAC dialog in Vista when writing to the HKLM registry hive, we opt to not use the Win32 Registry API, as when Vista permissions are lacking, we'd need to relaunch our entire application with administrator rights. Instead, we do this trick: ShellExecute(hWnd, "runas" /* display UAC prompt on Vista */, windir + "\\Reg", "add...

Extracting Autocomplete Emails from Outlook 2007

Hello, I need to extract all the emails that show up as autocomplete entries in Outlook 2007. I mostly need to create a list of all the email addresses which I have sent emails to in the past and dump them into excel. Should I be connecting to Outlook through COM somehow? Thanks. ...

On Win32 how do you move a thread to another cpu core?

I'd like to make sure that a thread is moved to a specific cpu core & can never be moved from it by the scheduler. There's a SetThreadAffinityMask() call but there's no GetThreadAffinityMask(). The reason I need this is because high resoultion timers will get messed up if the scheduler moves that thread to another cpu. ...

Docking a CControlBar derived window

How can I dock a CControlBar derived window to the middle of a splitter window (CSplitterWnd)? I would like the bar to be repositioned whenever the splitter is moved. To make it a little clearer as to what I'm after, imagine the vertical ruler in the Dialog Editor in Visual Studio (MFC only). It gets repositioned whenever the tree vie...

Overcoming Windows User Object Handle Limit

I'm looking for advanced strategies for dealing with User Object Handle limits when building heavy-weight windows interfaces. Please explain how you overcame or bypassed this issue using SWT or direct Windows GUI APIs. The only thing I am not interested in is strategies to optimize widget usage as I have done this extensively and it do...

UTF-8 in Windows

How do I set the code page to UTF-8 in a C Windows program? I have a third party library that has uses fopen to open files. I can use wcstombs to convert my Unicode filenames to the current code page, however if the user has a filename with a character outside the code page then this breaks. Ideally I would just call _setmbcp(65001...

Reuse Edit Control as Command Window

This is a GUI application (actually MFC). I need a command window with the ability to display a prompt like such: Name of favorite porn star: The user should be able to enter text after the prompt like such: Name of favorite porn star: Raven Riley But I need to prevent the user from moving the cursor into the prompt area. Use...

Is an atomic file rename (with overwrite) possible on Windows?

On POSIX systems rename(2) provides for an atomic rename operation, including overwriting of the destination file if it exists and if permissions allow. Is there any way to get the same semantics on Windows? I know about MoveFileTransacted() on Vista and Server 2008, but I need this to support Win2k and up. The key word here is atomic....