winapi

How could get scsi HDD serial number?

I wanna get the serial number of a scsi harddisk, but it makes an error! I work with VC++ on Microsoft Windows XP. What must i do for that? ...

WM_NCHITTEST, HTCAPTION and maximized window

I'm creating a custom drawn window by specifying border style NONE and custom processing of WM_NCHITTEST. I've defined some area as 'my window caption' and returning HTCAPTION result for WM_NCHITTEST in this area. When window is in normal state the behavior is expected by me. The window can be moved by dragging 'my window caption' and ca...

error 1202 - ERROR_DEVICE_ALREADY_REMEMBERED in WNetAddConnection2A

I used the function - WNetAddConnection2A(n, UserName, Password, dwFlags) to programmatically map a drive and read the drive info out, and then used WNetCancelConnection2A(DriveLetter, dwFlags, ForceDisconnect) to unmap the drive. The first map and unmap were fine. But the next map will bring me the error 1202 - ERROR_DEVICE_ALREADY_RE...

On Windows, how does console window ownership work?

When a console application is started from another console application, how does console ownership work? I see four possibilities: The second application inherits the console from the first application for its lifetime, with the console returning to the original owner on exit. Each application has its own console. Windows then someho...

RichEdit, winapi - paragraph aligment

Hi, I would like to have a line aligned in such way, that some first words are aligned left and some last words are aligned right, but all are in the same line: | text 1 text2 | | Lorem ipsum dolor sit amet | Is that possibile? How can I do that? ...

Impossible to remove directory

Evidently I've never had to delete a directory using win32 sdk before, because its apparently an impossible task. I've tried anything and everything - RemoveDirectory, SHFileOperation with FO_DELETE, etc. Currently I call CreateDirectory in one thread, start another thread, copy some files to this directory in the new thread, then delet...

How to detect popup of a sub-menu of a popup menu (and how to populate it dynamically)?

Hi everyone, I have a popup menu which contains several menu items and one of them can have child items. This entry has a little arrow on the right and when you hover your mouse over it, a sub-menu will open (without clicking). Now I want to populate this sub-menu at runtime, but only if the user actually opens it. If the user never ope...

Bring up the printer settings dialog and have the changes saved

This is the same as this question, with one remark: We manage to get the printerSettings modified, but how can we save them back as the default printer settings? (the original question does not post/answer this) The code I'm using right now: <DllImport("winspool.Drv", EntryPoint:="DocumentPropertiesW", SetLastError:=True, _ ExactSp...

Check if line Index was changed in edit control

Can i know or create a message which tells if the cursor moved to up or down a line in edit control? ...

Win32 Event vs Semaphore

Basically I need a replacement for Condition Variable and SleepConditionVariableCS because it only support Vista and UP. (For C++) Some suggested to use Semaphore, I also found CreateEvent. Basically, I need to have on thread waiting on WaitForSingleObject, until something one or more others thread tell me there is something to do. In...

terminating thread gracefully on main app termination.

I have a modelless dialog that creates a thread, and if the cancel button in the dialog is hit, a variable bCancel is set which the thread in question periodically checks, and then immediately jumps to its clean up code. It works fine. I can even send a WM_COMMAND...ID_CANCEL to the dialog from other places and it works the same. But ...

Destroy process-less console windows left by Visual Studio debug sessions

A known bug with a Windows XP security update KB978037 can occur with Visual Studio 2005 (and 2008) where sometimes if you restart a debugging session on a console app then the console window doesn't get closed even though the owner process no longer exists. The problem is discussed further here: http://stackoverflow.com/questions/24028...

[MFC] Emulating 'delete' key-press from context menu

I added a context menu to a MFC CRichEditCtrl, it includes a delete option which does: ReplaceSel("",TRUE); It appears to work but when I look at the undo log, it's not the same... we end up with characters being lost at the end of the sequence. Any ideas how I can make my code be the same as what happens when you press DELETE? Or even...

Clicking mouse by sending messages

I'm trying to send mouse clicks to a program. As I don't want the mouse to move, I don't want to use SendInput or mouse_event, and because the window that should receive the clicks doesn't really use Buttons or other GUI events, I can't send messages to these buttons. I'm trying to get this working using SendMessage, but for some reason...

Windows thumbnail preview with JNA (Java)

W32API.HWND targetHwnd = User32.INSTANCE.FindWindow('SunAwtFrame', 'Frame') W32API.HWND sourceHwnd = User32.INSTANCE.FindWindow('triuiScreen', 'EVE') W32API.HANDLE thumbnailH = new W32API.HANDLE() NativeLibrary dwm = NativeLibrary.getInstance('dwmapi') dwm.getFunction('DwmRegisterThumbnail').invoke(targetHwnd, sourceHwnd, thumbnailH) ...

Delphi: How to respond to WM_SettingChange/WM_WinIniChange?

i need to know when my application recieves a WM_SETTINGCHANGE message (formerly known as WM_WININICHANGE). Problem is that the message pump in TApplication sends it down a black hole (default handler) before i can get a chance to see it: procedure TApplication.WndProc(var Message: TMessage); ... begin Message.Result := 0; for I...

Change default Console I/O functions handle.

Hello. Is it possible to somehow change standart I/O functions handle on Windows? Language preffered is C++. If I understand it right, by selecting console project, compiler just pre-allocate console for you, and operates all standart I/O functions to work with its handle. So, what I want to do is to let one Console app actually write in...

How can I make a child window topmost?

Hi, I have a parent form, with some child windows (not forms - just windows, for example label controls) inside it. Under certain circumstances, I want one of those child windows to be drawn "above" the others, to display a message over the entire main form. I've tried setting HWND_TOPMOST and HWND_TOP on the child windows, but it does...

How can I make one child window draw over another within the same form?

Let's say I have ten child windows within a form. How do I make sure one of those windows is drawn over all the others? For example, how do I make sure that window 6 always overdraws windows 1-5 and 7-10? I don't want the window to be drawn over everything else on the screen, just everything else within that form. I've already tried usi...

[MFC] Weird scrolling in custom-draw CListBox with irregular item heights

I did a little digging and found stuff like this. However the advice to switch to LBS_OWNERDRAWFIXED style wouldn't work if the Listbox items don't all have the same height, would it? Is there any fix to this? ...