winapi

How to recursively traverse directories in C on Windows

Ultimately I want to travel through a folder's files and subdirectories and write something to all files i find that have a certain extension(.wav in my case). when looping how do i tell if the item I am at is a directory? ...

How can I display the 'Send to' and 'Open With' context menus?

Some time ago I asked about how to pop up the Windows context (right-click) menu for a certain file in Delphi. However, even if everything works (almost) OK, the 'Send to...' and 'Open with...' submenus don't have any items, even if when I right-click in Explorer on the same file name they work OK. (For example, 'Send to...' has 'Desktop...

What does it mean: "A child-process can inherit the handle"?

There are some Win32 objects which according to the SDK can be "inherited" to the child-processes created by the given process. (Events, mutexes, pipes, ...) What does that actually mean? Let's say I have a named event object, created with CreateEvent, one time with bInheritHandle == true, and another time == false. Now I start a chil...

Connect wifi access points with Windows Native Wifi Functions

Windows provides Win32 Native Wifi Functions, but when I used WlanConnect to connect a access point what needs password, it will show a tip on the notification area, if I clicked the tip, the password input dialog will show. How can I show the password input dialog directly without click the tip on the notification area? Thanks in advanc...

Flags returned by OSVERSIONINFOEX.wSuiteMask

Does anybody know what the following constants (defined in WinNT.h) mean? #define VER_SUITE_COMMUNICATIONS 0x00000008 #define VER_SUITE_EMBEDDED_RESTRICTED 0x00000800 #define VER_SUITE_SECURITY_APPLIANCE 0x00001000 The values are returned in the wSuiteMask field of the OSVERSIONINFOEX struct. ...

Loading an exe from an exe

I am exporting a function [using _declspec(dllexport)] from a C++ exe. The function works fine when invoked by the exe itself. I am loading this exe (lets call this exe1) from another exe [the test project's exe - I'll call this exe2] using static linking i.e I use exe1's .lib file while compiling exe2 and exe2 loads it into memory on st...

adding win32 app icon to task bar

I want to add some simple win32 application's icon to task bar while app is running in background. During this time, i want to send some msgs to that icon so that it pops up as per my req. Unfortunately i know only c\c++ and i use visual studio8, is there a way or api to do this? example: outlook icon or wifi icon ...

Simplest way to play mp3 from Visual C++

A few years back, I wrote some util library around DShow/DSound to let me play MP3s in a Windows C++ application. Is that still the normal way to do it in a C++/MFC app, or is that an area of DirectX that has been subsumed into the general Windows APIs? The motivation is simply we use the standard Windows PlaySound method for WAVs, and ...

Programmatically determining space available from UNC Path

Is there a programmatic API for determining available space on NAS sotrage from a UNC path? I looked through the WMI documentation and it wasn't clear that this is possible. A code example and references to the relevant API calls would be much appreciated. ...

test whether a 2D transformation matrix is orthogonal

We have found that HP's printer drivers fail to handle PlgBlt()s properly for many of their printers. Our intention is to handle any orthogonal rotations ourselves, and only have the printer handle scale and translation (which it seems to handle correctly). I have a 2D matrix available to me at the point in code where I am about to "dr...

How can I locate a process' global and stack areas in Win32?

How can I locate which areas of memory of a Win32 process contain the global data and the stack data for each thread? ...

How to Launch an Exe at User Level from a Higher Level

I would like a process to always run at the user level. Either when it is launched by the installer (custom, not msi), which runs as at the administrator level, or when a user logs on. Looking around, I'm not sure this is possible. ...

How can I kill a program that might not exist from Perl on Win32?

I'm looking for a way to make Perl kill all firefox.exe processes on Win32, and not give an error if no process exists. I'm currently using: system('taskkill /F /IM firefox.exe'); which throws up a big "ERROR: No such process found", when firefox wasn't present. ...

How to gracefully terminate a process?

I want to terminate a number of processes, but I want to give each process the chance to save its data, ask the user about saving a file and even ignore the close request. So TerminateProcess is out of the question, because it kills the process instantly. Another way would be to use SendMessage/PostMessage to send a WM_CLOSE to the main...

Win32: How can i set the color of windows Title, Scrollbar etc.?

I am updating a GUI of a Win32 Application in white text on black background. Thats simple for my content. But how can i change also the color of my child windows (Titlebar, Scrollbar etc.). i Know there is WM_CTLCOLORDLG to set the color of Dialogs. I also know there is WM_NCPAINT, but that would leave all painting (i.e of Scrollbars) ...

How to mix std::string with Win32 functions that take char[] buffers?

There are a number of Win32 functions that take the address of a buffer, such as TCHAR[256], and write some data to that buffer. It may be less than the size of the buffer or it may be the entire buffer. Often you'll call this in a loop, for example to read data off a stream or pipe. In the end I would like to efficiently return a strin...

How to add an IP address to an existing network adapter in Windows?

I am trying to add a new IP address to a local network adapter in Windows using the Windows API. Are there functions to do this in the Windows API, and if so, what are they? I am not trying to create virtual network adapters, but simply trying to assign multiple IP addresses to the same adapter. ...

Contextual or Drop down window

I am elaborating on how to set the window style to behave like the context menu or the combo-box drop down list - to be able to close when user clicks outside the window area or presses Escape but I have found no clue. I have already used the ToolStripDropDownButton to simulate this behavior quite well but there is one big issue that th...

How to use previous count of semaphore in ReleaseSemaphore.

Looking for an example of how to read the last semaphore count from ReleaseSemaphore Having problems creating a basic local variable to store LPLONG lpPreviousCount into and print out. Looks like I need a pointer to the variable but not having much luck. If you can point me in the right direction, that would be greatly appreciated. ...

What is the best way to wait for a variable in a multithreaded application

I would like to do something like the below for a multi-threaded program: // wait for variable to become true but don't hog resources // then re-sync queues Is something like this a good solution? while (!ready) { Thread.Sleep(250); // pause for 1/4 second; }; ...