winapi

Win32 select/poll/eof/ANYTHING!?!?!

Using the standard Win32 file I/O API's (CreateFile/ReadFile/etc), I'm trying to wait for a file to become readable, or for an exception to occur on the file. If Windows had any decent POSIX support, I could just do: select(file_count, files_waiting_for_read, NULL, files_waiting_for_excpt, NULL, NULL); And select will return when the...

Can I draw Qt objects directly to Win32 DC (Device Context)?

I can draw Qt objects to an QImage and then draw the image to HDC or CDC. This may hurt our application's performance. It would be great if I can draw Qt objects directly to Win32 HDC or MFC CDC. I expect that there is a class, say QWin32Image for clear, then I can use it in this way: QWin32Image image(hdc, 100, 100, Format_ARGB32_Premu...

Linking to a Large address aware DLL.

Suppose I have a DLL which is built with LARGEADDRESSAWARE linker flag set. Now I have an application dynamically linking to this DLL. Does this make my application LARGEADDRESSAWARE? If not then, does it make sense to have this flag set for any DLL? ...

How to call in C# function from Win32 DLL with custom objects

How to use in C# function from Win32 DLL file made in Delphi. When function parameters are custom delphi objects? Function definition in Delphi: function GetAttrbControls( Code : PChar; InputList: TItemList; var Values : TValArray): Boolean; stdcall; export; Types t...

Win32: How to determine if DirectDraw is disabled?

When using CachedBitmaps in GDIPlus, there is graphical corruption if Windows video "Hardware Acceleration" is lowered enough that DirectDraw is disabled: There are six levels of hardware acceleration: Disable all accelerations Disable all but basic accelerations. (Default on server machines) Disable all DirectDraw and Direct3D acce...

Timing related crash when unloading a DLL?

I know I'm reaching for straws here, but this one is a mystery... any pointers or help would be most welcome, so I'm appealing to those more intelligent than I: We have a crash exhibited in our release binaries only. The crash takes place as the binary is bringing itself down and terminating sub-libraries upon which it depends. Its abil...

Can a CWinApp be placed in a DLL?

I'm updating some legacy apps to Visual Studio 10 and am in linker hell. All of these DLLs derive classes from CWinApp and use AfxGetApp() to get access to the object. When I link the DLLs I get unresolved externals that look like global static objects that would get pulled in by a normal app's main(): Shell.lib(SHELL.obj) : error LNK20...

Maximize/Minimize is causing Close Button to be re-enabled after disabling it -- Why?

I have used P/Invoke to call GetSystemMenu and EnableMenuItem (win32api) to disable the close functionality. However, after minimizing or maximizing my Windows Forms application the button is re-enabled. Obviously minimizing or maximizing is causing the behavior, but how? I'm not sure where to look to prevent this behavior. Should I be...

Embed Text File in a Resource in a native Windows Application

I have a C++ Windows program. I have a text file that has some data. Currently, the text file is a separate file, and it is loaded at runtime and parsed. How is it possible to embed this into the binary as a resource? ...

Can a Windows Service recieve Windows Messages?

I created an application to receive a broadcasted windows message which works fine. When I turn it into a service, install it, and start the service, the service doesn't receive the message. ...

C++ Windows function call that get local hostname and IP address

Is there built-in windows C++ function call that can get hostname and IP address? Thanks. ...

win32 sdk: how to make the caption/border of a child window transparent

In my win32 application I want to create a child window within the main window. I assigned these styles to the child window when calling CreateWindowEx: WS_CHILDWINDOW | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | WS_SIZEBOX | WS_CAPTION The child window I get has a caption and a resizable border. However there's no close button in the cap...

Line underneath my menu bar!

When you create a menu bar, a funny line appears underneath (for XP and Win7 at least). How can I get rid of this line? I know that some applications, such as Firefox and Thunderbird, have done so. Here's an illustration: I am programming in C, using the Windows API. My menu is loaded from a resource file. ...

how to get vendor id and product id of a plugged usb device on windows

Hello all, I am using Qt on windows platform. i want to get and display vendor id and product id of a plugged usb device from my local system. Below is my full source code to get the vendor id and product id from the usb device. when i run the my qt application it does not throw me any errors . so i plug the usb device into the sys...

C++/Win32 : XP Visual Styles - no controls are showing up?

Okay, so i'm pretty new to C++ & the Windows API and i'm just writing a small application. I wanted my application to make use of visual styles in both XP, Vista and Windows 7 so I added this line to the top of my code: #pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' ...

How to use SHCreateShellFolderView from C# code on Windows 7?

I'm trying to write a shell extension using C# however I haven't found any example on the web about how to use SHCreateShellFolderView windows API function. Does anyone has some example of how to use it? I'm trouble to use it on Windows 7. ...

Removing WS_BORDER and WS_CAPTION from windows styles doesn't work

Hello, I created a small app in C# that removes border and caption from window, then it sets size to the user's resolution and centers it. It's a utility for me to use when I want to play games in windowed mode without being annoyed by the borders. Everything works fine with most games, but I tried to use it on a recently released game A...

Prevent monitor from powering on

I'm turning off the monitor using SendMessage(HWND_BROUADCART, WM_SYSCOMMAND, SC_MONITORRPOWER, 2). That works, but the monitor turns back on when someone touches the keyboard or mouse. I tried to get rid of this using the DevicePowerSetDeviceState function with DEVICEPOWER_CLEAR_WAKEENABLED for the keyboard and mouse: it returns no err...

How can I know if a window belongs to my program? Using win32 only.

How can I know if a window belongs to my program? I guess I can use the window handle to get the executable name but that seems like a lot of work and I have to do this repeatedly so I think it might be a performance issue. Is there a simple way to know if a given window handle is from ones own program with win32 or some OS construct? Ca...

How To Prevent Processes From Starting?

I'm toying around with a very simplistic sort of process-monitor. Currently, it gets a list of the running processes and attempts to kill any process that is not white-listed. What I'm looking for is a way to prevent a process from starting that isn't on the white-list. If that's possible. My knowledge level in this area is pretty ...