winapi

Windows - CPU power management APIs

What APIs are provided by Windows for CPU power management (I'm interested in CPU frequency scaling, setting min and max CPU frequency - similar to what you can do in Control Panel in power plans, but in a programmatic way). I'm also interested in .Net APIs. (It is not something I intend to use in a production environment, but rather as ...

Windows - put HDD stand-by and sleep mode

How can I put a hard disk drive in stand-by or sleep mode in Windows, in a programmatic manner. Does the Windows API or any .Net libraries provide any functions to achieve this? (I am aware that I should probably not interfere with Windows's power management mechanism, but this is not something I intend to use in a production environme...

LsaCallAuthenticationPackage returns ERROR_INVALID_PARAMETER 87 (0x57) when trying to purge a specific ticket

Hi, I'm trying to purge a specific ticket from the cache,using LsaCallAuthenticationPackage. I always get ERROR_INVALID_PARAMETER 87 in the package status. What could be the reason? Here is my code (All other steps succeeded): KERB_QUERY_TKT_CACHE_REQUEST tktCacheRequest = { KerbQueryTicketCacheMessage}; void* pRep; DWORD ...

Win32: edit control selection in dialog-based app

I have a dialog-based app with an edit-control in it. When I minimize / restore the app, everything's ok. But when I hide all the windows with holding down that Windows-logo-key and pressing "D" and then I restore the app, the edit-control selects everything inside it. How to make it not to select the text on restore? ...

Extracting Window Contents

I need to extract window content if this is based on text, or at least the file path associated to that window. To-date, I have considered: 1. win32api 2. 3rd party libraries 3. wrapper classes However, I am not satisfied with the solutions. So any ideas how this can be done in a clean way? ...

SetParent() on a VB6 application from a C# app

Aloha all! I am trying to use the win32 API to set the parent of an application to a panel in my C# application. I can get most applications to work... However I have one application which was written in VB6 which I am having problems with... When I inspect it using spy++ the application loads in 2 main forms 'ThunderRT6Main' and 'Thu...

Is there any simple way to determine when the popup menu was dismissed?

I'm displaying a popup menu using TrackPopupMenu and would like to know when it is dismissed via clicking outside of it. I've looked through all the menu functions but didn't find anything useful in this regard. Spy++ told me that no window message is sent in this case. So, is there an easy way to do it without installing a mouse hook? ...

Why does GetWindowThreadProcessId return 0 when called from a service

When using the following class in a console application, and having at least one instance of Notepad running, GetWindowThreadProcessId correctly returns a non-zero thread id. However, if the same code is included in a Windows Service, GetWindowThreadProcessId always returns 0 and no exceptions are thrown. Changing the user the service...

How can one get the value from SystemInformation::KeyboardSpeed (Windows API) in c code?

Is there a simple way? ...

Is UTC or local time used with time-based notifications?

I have a time in the future when I want a notification to occur and need to know if ::CeSetUserNotificationEx expects UTC or local time in the stStartTime field of the CE_NOTIFICATION_TRIGGER structure if the dwType field is set to CNT_TIME? ...

Is Export table contains all entries of Win32 Exe functions?

Hello, I need to know that all Win32 Exe functions or class's member functions contained inside Export table of that Win 32 exe(PE File)? If not then from how and where I would be able to get all these information? (I know PE file format and all sections of it and know what those sections contained but still help required how to procee...

screenshots of covered/minimized windows

Hi, I have the following code to take screenshots of a window: HDC WinDC; HDC CopyDC; HBITMAP hBitmap; RECT rt; GetClientRect (hwnd, &rt); WinDC = GetDC (hwnd); CopyDC = CreateCompatibleDC (WinDC); hBitmap = CreateCompatibleBitmap (WinDC, rt.right - rt.left, //width rt.bottom - rt.top);//height SelectObject (CopyDC, hBitmap); //C...

Cannot call DLL import entry, C# -> C++, EntryPointNotFoundException

I'm trying to call from C# a function in a custom DLL written in C++. However I'm getting the warning during code analysis and the error at runtime: Warning: CA1400 : Microsoft.Interoperability : Correct the declaration of 'SafeNativeMethods.SetHook()' so that it correctly points to an existing entry point in 'wi.dll'. The ...

Restart a windows 7 machine programmatically.

I have a requirement to trigger a reboot on a windows7 machine programmatically. This is to support a scenario for customers where when they log out of an intenet kiosk machine the machine reboots. On XP this was achieved using WTSSystemShutdown but Im wondering if theres another way. Any pointers greatly appreciated. ...

Windows API: Is it possible to know if an icon in system tray is hidden by the user?

I need to know if the user has hidden an icon added by my program to the system tray area. Is it technically feasible? UPDATE My program - yowindow displays the current temperature in the system-tray icon. I want to spare the server load by not auto-updating the weather for the users who don't see the tray-icon. ...

Detecting Drag/Drop Operations on CRichEditCtrl

I've had loads of problems detecting copy/paste operations in my custom subclass of CRichEditCtrl (WM_PASTE,etc don't get received) but got a working solution which traps paste events and removes formatting on pasted text. Now I realised that CRichEditCtrl supports drag & drop by default and this bypasses my custom code. Are there easy ...

CFileDialog - Selected filter and "Hint" showing all files

I have CFileDialog and set filter for it (Text files *.txt). When it opens, I see only TXT files, thats right. But! when I'm typing text into filename, the hint (under filename field) is showing all files (files with any extension). Can be this behavior changed by some flag? I want force hint to show only TXT files. ... CFileDialog f(TR...

Not able to get IME Input Context through C++ (ImmGetContext)

Hi I am trying to disable the IME on notepad using the following psuedo code: MakeNotepadActiveWindow();//Notepad is already open and set to Japanese IME HWND hwnd = GetTheHWNDForNotepad(); HIMC context = ImmGetContext(hwnd); if(context == NULL) printf("context is null %d ",GetLastError()); and the above code is always giving me the...

How can I detect message boxes popping up in another process?

I'd like to execute some code whenever a (any!) message box (as spawned by the MessageBox Function) is shown in another process. I didn't start the process I'm monitoring. I can think of three approaches: Install a global CBT Hook procedure which tells me whenever a window is created on the desktop. Then, check whether the window belo...

According to MSDN ReadFile() Win32 function may incorrectly report read operation completion. When?

The MSDN states in its description of ReadFile() function: If hFile is opened with FILE_FLAG_OVERLAPPED, the lpOverlapped parameter must point to a valid and unique OVERLAPPED structure, otherwise the function can incorrectly report that the read operation is complete. I have some applications that are violating the above recommend...