winapi

What is the default buffer size of CreateFile in Windows?

When CreateFile Function is called without the flag FILE_FLAG_NO_BUFFERING, what is the size of the inner buffer of operating system? If my buffer size is larger than the inner buffer of Windows, can I fully use up the throughput of disk? ...

Windows API to extract zip files?

In Windows Explorer you can extract a compressed folder (a zip file) Is there an API or command line to extract a zip file using the same method programatically? ...

Get the domain name of a computer from Windows API

Hi, In my application I need to know if the computer is the primary domain controller of a domain, so I need to know the domain of the computer to call NetGetDCName function. Thanks. EDIT: The problem is related with the DCOM authentication so I need to know the domain to use the DOMAIN\USERNAME in case of a PDC or COMPUTER\USERNAME ...

Pure win32 cross-process child windows

Hello, I need to create a transparent overlay window, that goes above another window. The other window is from another vendor. And when the user drags that window mine needs to follow. WS-CHILD seems like a nice idea but it cannot be combined with WS-EX-LAYERED, which I really need (for transparency). But I still can set a parent witho...

Convert short (8.3) paths to long?

In a Win32/WTL/C++ app, I need to convert some 8.3 paths to their true file names. How do I do it? Thanks, ...

closesocket() fails with WSAEOPNOTSUPP

I've got an application using sockets (which I did not write, so bear with me) and when I try to close a socket, closesocket() fails with error WSAEOPNOTSUPP and the socket sticks around...as in, it is not fully deleted. The socket is created as follows: bool Socket::CreateConnection() { int error; struct addrinfo hints; struc...

Convert BITMAP to PNG using IImage interface on Windows Mobile

I've got a handle to a BITMAP structure (HBITMAP) in a Windows Mobile application -- I'd like to save the bitmap as a PNG file, using the IImage interface if possible. (There's no BMP file in this situation, the BITMAP is only in memory). It looks like I could use IImagingFactory's IImagingFactory::CreateImageEncoderToFile method to sav...

How do I monitor the lock on a file to see when it is released? [C++]

Hello all, I am looking for a way to create a program in unmanaged c++ that waits until a file is unlocked (as in it is no longer in use) and than does something. I have had no luck locating how to do this, any help would be appreciated! UPDATE: I may have answered my own question, see below and tell me what you think.. UPDATE: All th...

Low-overhead I/O monitoring on Windows

I would like a low-overhead method of monitoring the I/O of a Windows process. I got several useful answers to http://stackoverflow.com/questions/864839/monitoring-certain-system-calls-done-by-a-process. The most promising was about using Windows Performance Toolkit to get a kernel event trace. All necessary information can indeed be pu...

Get window handle of last activated window

I am developing an application that sits in the system tray and can perform actions on the active window. But when the icon in the system tray is clicked, GetForegroundWindow() returns the taskbar. I need to get the window that was active before the taskbar was. I've tried enumerating the desktop window with EnumWindows and GetWindow, b...

Get the complete username a new username

Hi, when using NetUserAdd the user will be created on the local computer or as a domain account depending the role of the server where you used this function. I want to retrieve the complete username (LOCALCOMPUTER\USERNAME or DOMAIN\USERNAME) to use it remotely. Is there a function to do this? Thanks ...

"Correct" way to send a sequence of UDP datagrams?

I was under the impression that the instability of UDP is a property of the physical layer, but seems that it isn't: I am trying to send a message over UDP, which is divided into a sequence of packets. Message identification and re-ordering is done implicitly. I tested this method over two apps that run on the same computer, and expect...

Problem using AddIPAddress when impersonating an Admin User

I am attempting to add a temporary IP address to a NIC using AddIPAddress when logged in as a non-admin user. The MSDN documentation for AddIPAddress states that ERROR_INVALID_HANDLE is returned as as error if the function is called by a non-admin user. Given that I have preceeded the call to AddIPAddress with API calls to LogonUser() a...

Can users interact with services directly on Microsoft Vista?

From the Microsoft website (see msdn.microsoft.com/en-us/library/ms683502(VS.85).aspx) it clearly says "Services cannot directly interact with a user as of Windows Vista". So I decided to test this by using "psexec -s cmd.exe". As far as I know, "psexec" creates a service in order to open a command prompt. Needless to say it worked. I ...

Get a screenshot of a specific application

I know I can get the screenshot of the entire screen using Graphics.CopyFromScreen(). However, what if I just want the screenshot of a specific application? ...

Parenting a .NET form to an HWND.

I'm developing a plugin (C++/CLI DLL) that runs inside of an certain applications, about which I only know the HWND. My plugin shows various .NET forms that I'd like to behave as children of the main application (e.g. centered to the main window, etc). Here's what I've tried: // MyDialog.h public ref class MyDialog : public System::Wi...

c++ win32 popup animation

Hello, I am creating an application that uses popups. However, I would like to animate this popup (a win32 window, a HWND), for example having it slowly extend from the bottom of my screen, moving upwards. Should I make a few dozens of calls to the SetWindowPos function with a small pause in between, or is there a better way to do this, ...

Win32 function for scheduled tasks in C++

I have a function in C++ that needs to be called after a period of time and this task is repeated. Do you know any built-in function or sample code in Win32 or pthread? Thanks, Julian ...

Timeout resolution of WaitForSingleObject

When I wait on a non-signaled Event using the WaitForSingleObject function, I find that in some cases the call will return WAIT_TIMEOUT in less than the specified timeout period. Simply looping on the call with a timeout set to 1000ms, I've seen the call return in periods as low as 990ms (running on WinXP). I'm using QueryPerformanceCo...

Create a Program that Sits in The Windows Taskbar and, When Activated, Stops the Screensaver From Starting

I don't really know where to begin. Let's start with the stupid questions: What language should I use for this? What is suited for the task at hand? Next, the real ones: Is there a way to stop the screensaver from starting, short of changing the cursor position? If not, will changing the cursor position even work? ...