winapi

How do I intercept a paste event in an editbox?

How do I intercept a paste event in an editbox, possibly before the value is transferred to the object? ...

C++: Step 1: ExtractIconEx. Step 2: ??? Step 3: SetMenuItemBitmaps

I'm experimenting with adding icons to a shell extension. I have this code (sanitized for easy reading), which works: InsertMenu(hmenu, index, MF_POPUP|MF_BYPOSITION, (UINT)hParentMenu, namestring); The next step is this code: HICON hIconLarge, hIconSmall; ICONINFO oIconInfo; ExtractIconEx("c:\\progra~1\\winzip\\winzip32.exe", 0, &hI...

Highest resolution "Sleep" for IA32/Wintel?

Howdy Overflowites, I'm looking to see if anyone knows of a higher-resolution "Sleep" API than can be achieved using the following code block: ::timeBeginPeriod( 1 ); ::Sleep( 1 ); ::timeEndPeriod( 1 ); I'm trying to accomplish some "process balancing" work, and after some experimenting, find I need finer grain control than the...

Windows XP - Create Shortcuts on Desktop and controll their placement

In any language really, im looking for a simple (very simple) way to control the position of a shortcut on the users desktop. I already make the assumption that Auto Arrange and Align to Grid are unchecked. Ex: The program creates the shortcut to the desktop than places it at position (450,302) on the desktop. I know how to create sho...

Retrieving multiple rows into a listview control from an ODBC source works well for simple SELECTs with a statement attribute of SQL_SCROLLABLE. How do I do this with a UNION query?

I am retrieving multiple rows into a listview control from an ODBC source. For simple SELECTs it seems to work well with a statement attribute of SQL_SCROLLABLE. How do I do this with a UNION query (with two selects)? The most likely server will be MS SQL Server (probably 2005). The code is 'c' for the Win32 API. This code sets (wha...

Generating a unique machine id

I need to write a function that generates an id that is unique for a given machine running a Windows OS. Currently, I'm using WMI to query various hardware parameters and concatenate them together and hash them to derive the unique id. My question is, what are the suggested parameters I should use? Currently, I'm using a combination of...

What can be the reason for BeginPaint() always generate a WM_NCPAINT?

I'm facing a problem on Win32 API. I have a program that when it handles WM_PAINT messages it calls BeginPaint to clip the region and validate the update region, but the BeginPaint() is always generating a WM_NCPAINT message with the same updata region even if the touched part that need repaint it's only inside the client region. Do an...

Per-process CPU usage on Win95 / Win98 / WinME

How can you programmatically measure per-process (or better, per-thread) CPU usage under windows 95, windows 98 and windows ME? If it requires the DDK, where can you obtain that? Please note the Win9x requirement. It's easy on NT. EDIT: I tried installing the Win95/98 version of WMI, but Win32_Process.KernelModeTime and Win32_Process....

::SendMessage( )

LRESULT result = ::SendMessage(hWnd, s_MaxGetTaskInterface, (WPARAM)&pUnkReturn, 0); The value of result after the call is 0 I expect it to return with a valid value of pUnkReturn , but it returns with a NULL value . Necessary Information before this call : const UINT CMotionUtils::s_MaxGetTaskInterface = RegisterWindowMessage(_T("...

Subclass a MonthCal control in Win32

Objective: use the standard Win32 MonthCal control, and paint days such as holidays in RED. It seems like the Win32's native approach would be use the MCN_GETDAYSTATE notification, which seems to allow only painting specific days in Bold. Possible (but declined) solution would be to write my own painted-at-will MonthCalendar, driving m...

Win32 TreeCtrl TVN_ENDLABELEDIT memory allocation

I have a Win32 TreeCtrl where the user can rename the tree labels. I process the TVN_ENDLABELEDIT message to do this. In certain cases I need to change the text that the user entered. Basically the user can enter a short name during edit and I want to replace it with a longer text. To do this I change the pszText member of the TVITEM s...

Windows API Programming

I found this site, http://www.apitalk.com/document.php?id=1184207999_1 and I'm not sure if this site is using ATL, STL, MFC, or just calling API functions directly. I have done console programming with C++ and graphics programmign with C++ in Borland, but I've have never done Win32 C++ programming and I'm curious if anyone knows of a go...

How to draw custom button in Window Titlebar with Windows Forms?

How do you draw a custom button next to the minimize, maximize and close buttons within the Titlebar of the Form? I know you need to use Win32 API calls and override the WndProc procedure, but I haven't been able to figure out a solution that works right. Does anyone know how to do this? More specifically, does anyone know a way to do ...

How can i temporarily load a font?

I need to load some fonts temporarily in my program. Preferably from a dll resource file. ...

RSA encryption library for c++

Hello I am developing a win32 application and I would like to use an RSA encryption library. What Library would you reccomend? ...

Closing a minimized/iconized process from C#

Hi! Here's my issue: I need to close a process, already running, from a C# program. The problem is that the process now runs as an icon (minimized to taskbar), and unless the user opens it at least once (which will never happen on unattended machines), it'll never have a main window. The other requirement that I have is that the appli...

How to capture PCM data from Wave Out

Hello, How would it be possible to capture the audio programmatically? I am implementing an application that streams in real time the desktop on the network. The video part is finished. I need to implement the audio part. I need a way to get PCM data from the sound card to feed to my encoder (implemented using Windows Media Format). I...

Using the Window API, how do I ensure controls retain a native appearance?

Some of the controls I've created seem to default to the old Windows 95 theme, how do I prevent this? Here's an example of a button that does not retain the Operating System's native appearance (I'm using Vista as my development environment): HWND button = CreateWindowEx(NULL, L"BUTTON", L"OK", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, ...

Multiple services from the same executable

Hello all, I've written a small service (plain Win32) and I'd like to know if it's possible to run multiple instances of it when multiple users are logged on. Basically, let's say we've got UserA and UserB for UserA the service would log on as "domain\UserA" and for UserB the service would log on as "domain\UserB" - this is from the sa...

Getting user name/password of the logged in user in Windows

Hello all, Is there any API to get the currently logged in user's name and password in Windows? Thank you in advance. ...