winapi

ReSharper (or something like it) for Visual C++ ?

I've seen ReSharper recommended a lot Unfortunately, it doesn't support C++ in Visual Studio. Is there anything out there you can recommend? I already use Visual Assist, and it does its job very well, but it's quite limited in comparison with ReSharper. Any suggestions? ...

Getting DNS servers on Windows

I'm using the DnsQueryConfig Win32 function to get the DNS servers used by Windows. This works fine for IPv4 addresses, but what if the DNS servers have IPv6 addresses? ...

Building libcurl with SSL support on Windows

Hi, I'm using libcurl in a Win32 C++ application. I have the curllib.vcproj project added to my solution and set my other projects to depend on it. How do I build it with SSL support enabled? ...

How do I determine number of window handles an application is using?

What is the best way to determine how many window handles an application is using? Is there a tool or a WMI performance counter that I could use? I would like to run up an app and watch a counter of some sort and see that the number of window handles is increasing. for (int i=0; i < 1000; i++) { System.Threading.Thread.Sleep(1000...

How can I get the path of a Windows "special folder" for a specific user?

Inside a service, what is the best way to determine a special folder path (e.g., "My Documents") for a specific user? SHGetFolderPath allows you to pass in a token, so I am assuming there is some way to impersonate the user who's folder you are interested in. Is there a way to do this based just on a username? If not, what is the minim...

Is there a .NET namespace where I can find the WIN32 API message-related #defines, like WM_COMMAND, etc

I'm overriding WndProc, so I want to write code like if (m.Msg == WM_COMMAND) my special stuff else base.WndProc(ref m) ...

C++: What's the simplest way to read and write BMP files using C++ on Windows?

I would like to load a BMP file, do some operations on it in memory, and output a new BMP file using C++ on Windows (Win32 native). I am aware of ImageMagick and it's C++ binding Magick++, but I think it's an overkill for this project since I am currently not interested in other file formats or platforms. What would be the simplest way ...

In C#, I have a IntPtr to a WIN32 WndProc. What is the syntax for calling it?

I'm subclassing a native window (the edit control of a combobox...) oldWndProc = SetWindowLong(HandleOfCbEditControl, GWL_WNDPROC, newWndProc); In my subclassing wndproc, I'll have code like this, right, but I can't figure out the syntax for calling the oldWndProc. int MyWndProc(int Msg, int wParam, int lParam) { if (...

What is the WIN32 API WM_REFLECT message for?

I can't find documentation for it, even on MSDN... ...

Using SHFileOperation within a Windows service

It's possible, but is it appropriate to use SHFileOperation within a Windows service? All those SHxxx API functions in shell32.dll seem to have been written with user level programs in mind. Can I be certain SHFileOperation won't display GUI ever? ...

What's a nice way of building a wParam or lParam in C#? (Something friendlier than shift operators?)

When the WIN32 docs says something like: wParam The low-order word specifies the edit control identifier. The high-order word specifies the notification message. What's a nice way of building that wParam? ...

Is there an API for vista to detect if the desktop is running full screen?

e.g, Is the user playing a movie full screen, or looking at powerpoint in full screen mode? I could have sworn I saw a IsFullScreenInteractive API before, but can't find it now ...

File security attributes getting screwed up on file copy

I've a windows service that updates our product. It copies the product files into a temp directory, usually "C:\Windows\Temp", patches the binaries, and then uses MoveFileEx to copy the files back to the install directory on a reboot, usually "C:\Program Files\Product". The files in the install directory are inheriting their security att...

Accessing Win32 C/C++ struct members from C#

I am intercepting Win32 API calls a native dll or exe is doing from C# using some kind of hooking. In this particular case I am interested in DrawText() in user32.dll. It is declared like this in Win32 API: INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags) The LPRECT struct has the following signature (als...

Is there any way to detect the monitor state in Windows (on or off)?

Does anyone know if there is an API to get the current monitor state (on or off) in Windows (XP/Vista/2000/2003)? All of my searches seem to indicate there is no real way of doing this. This thread tries to use GetDevicePowerState which according to Microsoft's docs does not work for display devices. In Vista I can listen to GUID_MO...

Alert Popups from service in Python

I have been using win32api.MessageBox to do alerts, and this works for apps running from the interactive prompt and normally executed code, however when I built a Python service when a MessageBox is triggered I can hear the 'beep' but the box does not display. Is it possible to display alerts from services? ...

Need to bring application to foreground on Windows

I've got two applications I'm developing using Qt on windows. I want the user to be able to press a button in one application which makes the other application come to the foreground. (The programs communicate using QLocalSocket / named pipes) Currently I'm using Qt's QWidget::activateWindow() which occasionally brings the application t...

How to manipulate DLGTEMPLATE programmatically?

What? I have a DLGTEMPLATE loaded from a resource DLL, how can I change the strings assigned to the controls at runtime programmatically? I want to be able to do this before the dialog is created, such that I can tell that the strings on display came from the resource DLL, and not from calls to SetWindowText when the dialog is initiali...

Copying file security permisions

I'm copying a file from folder A to folder B and then trying to copy the file permisions. Here are the basic steps I'm using: CopyFile(source, target) GetNamedSecurityInfo(source, GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION) Print source SD using ConvertSecurityDescriptorToStringSecurityDescriptor SetNamedSecurityInfo(target...

How do you programmatically determine whether a Windows computer is a member of a domain?

I need a way to determine whether the computer running my program is joined to any domain. It doesn't matter what specific domain it is part of, just whether it is connected to anything. I'm coding in vc++ against the Win32 API. ...