winapi

What happens if I ReleaseMutex() twice?

The Microsoft documentation is silent about what happens if I mistakenly call ReleaseMutex() when the mutex is already unlocked. Details: I'm trying to fix up some Windows code without having access to the compiler. I realise that WinApi mutexes are all recursive, and reference-counted. If I were making use of that feature, it's obvi...

How to get/set the console cursor position in Ruby (Windows)

I'm trying to write a shell in Ruby, and to implement tab completion I am using the WinAPI function getch to read in a character at a time from the user, checking for tabs. The problem with this is the backspace key: It moves the cursor further back than the prompt (eg, with prompt hello> , the user can backspace the cursor on to the...

Performance issues with hard disk reading

I have a C++ program which reads files from the hard disk and does some processing on the data in the files. I am using standard Win32 APIs to read the files. My problem is that this program is blazingly fast some times and then suddenly slows down to 1/6th of the previous speed. If I read the same files again and again over multiple run...

Monitioring running application

Hi! I want to monitor all running applications, get events of application main window or child windows. How can I do it? ...

What does ERROR_FILE_NOT_FOUND mean from SendMessage?

SendMessage returning 0 and GetLastError returning 2 (ERROR_FILE_NOT_FOUND). ERROR_ACCESS_DENIED is documented but not this. Anyone have any idea what this means? ...

MS Access VB call to Lib "kernel32" fails to stop a process

In the book SQL Hacks from O'Reilly, Hack 44 shows how to tunnel into MySQL from Microsoft Access. I can't get the code that stops the tunnel to work. This is the example code that starts the tunnel: Dim plink As Long Private Sub StartTunnel_Click( ) 'Run plink. Use Linux account details to establish tunnel. plink = Shell("c:\Docu...

GetPixel always returns CLR_INVALID

I'm trying to read the pixel color of a given window. The window is not mine. The window may not have focus or be at foreground. I don't know if it matters, does it? I have the window handle, so I do: HDC hdc = GetDC(m_window); if (hdc) { COLORREF color = GetPixel(hdc,x,y); if(color == CLR_INVALID) { wxLogDebug...

OpenSSL error preventing Apache2.2 startup on win32

So I go to start my Apache2.2 service, which uses mod_ssl, from the command line with "-k start -e debug". It shows all the modules loading, waits a second or two, then returns me to the command prompt without error. The service, however, is no longer running. In the error log, there's this text: Starting the Apache2.2-ssl service Th...

How to obtain Windows special paths for a user account from a service

I want to be able to retrieve Windows "special paths" (e.g. temporary files folder, desktop) for user accounts, but from a service. I know the normal way to do this is by using SHGetFolderPath with the appropriate CSIDL for the folder type. Is there any way to get this type of info for each user without the service having to log in as ...

Why can my property sheet, shown from a system tray icon, lock up the taskbar?

Note: code samples have been simplified, but the overall structure remains intact. I am working on a Win32 application whose main interface is a system tray icon. I create a dummy window, using HWND_MESSAGE as its parent, to receive the icon's messages: WNDCLASSEX wndClass; wndClass.lpfnWndProc = &iconWindowProc; // ... iconWindowHandl...

How to respond to a PropertySheet's OK or Apply button after the pages have processed it?

The PropertySheet API lets you define a PropSheetProc that can (on Windows XP and above) receive messages when the OK or Apply button is pressed. This lets you do processing when one of these buttons is clicked. However, this handler is called before the individual property pages receive the PSN_APPLY notification through their respecti...

Why am I not receiving either WM_GESTURE or WM_TOUCH?

My window is not receiving WM_GESTURE messages, nor WM_TOUCH messages. According to the msdn touch troubleshooter, I ought to be receiving WM_GESTURE messages unless I have called RegisterTouchWindow, which I have not. My code calls GetSystemMetrics as described in the help page for "Getting started with Windows Touch", and it tells me t...

LogonUser, LOGON32_LOGON_INTERACTIVE and LOGON32_LOGON_NETWORK

Can anyone provide a clear explanation of the difference between LOGON32__LOGON_INTERACTIVE and LOGON32_LOGON_NETWORK when used with LogonUser? The MS documentation is here. But I'm not clear what should be used. The scenario is similar to a telnet server that Windows users (local to the server, and domain users) are logging into - I ...

How to know what amount of memory I'm using in a process? win32 C++

Hi, I'm using Win32 C++ in CodeGear Builder 2009 Target is Windows XP Embedded. I found the PROCESS_MEMORY_COUNTERS_EX struct and I have created a siple function to return the Memory consumption of my process SIZE_T TForm1::ProcessPrivatBytes( DWORD processID ) { SIZE_T lRetval = 0; HANDLE hProcess; PROCESS_MEMORY_COUNTERS_EX...

Mysterious verifier.dll

While debugging the crash on customer's machine we noticed that our application runs under verifier.dll. e.g each thread stack starts with verifier.dll and every system function is intercepted with verifier.dll stub. Common sense and running Google search for "verifier.dll" clearly indicates that this dll belongs to Application Verifier...

How to turn off pc via windows API?

Hello all I never programmed a winapi so i have a little problem here . I need turn off my pc from my application . I found this example link text then i found this example how to change privileges link text But i have problem how to get that parameter HANDLE hToken // access token handle I think i need to make it in the next orde...

Finding a handle that persists when relaunching parent

I need to interact with 3'rd party applications by knowing the handle of certain text fields, but the hWnd always changes when that window is recreated. Is there any method that would allow me to identify a window and repeatedly be able to access that window (even after it is closed and then reopened) without having the user manually ide...

What is the lifetime of a CWnd obtained from CWnd::FromHandle?

According to msdn, when I get a CWnd* with CWnd::FromHandle, The pointer may be temporary and should not be stored for later use. What is meant by "later use" is not clear to me. Is it only the scope of the current method? As far as I know, there is no GC in Win32! ...

Python as a Windows Watchdog

Hi I'm considering using Python to make a watchdog app on Windows XP that will perform the following actions: Restart Windows at a given time. Start an exe application. Run a timer to check: is an application still running I know of the existence of PyWin32, but I hear that the API is not complete. So my question is can Python perfor...

How to launch proccess with limited memory?

How does one create and launch process (i.e. launch an .exe file) with RAM limitation using c++ and the win32 API? Which error code will be returned, if the proccess goes beyond the limit? ...