winapi

Conflict with DrawText function

I am developing a multi-platform application and in one component I have a class method called DrawText. Unfortunately, I get a linker error (on windows only) saying that there is an unresolved external symbol for a DrawTextW method of this class. I've seen this before with other methods ending in "Text" where it is looking for either a...

winapi: CreateProcess but hide the process' window?

I am using CreateProcess to create a cmd.exe process that is passed a parameter that it executes and quits, this makes command prompt flash up on the screen. I tried to avoid this by setting STARTUPINFO struct wShowWindow to SW_HIDE but this parameter seems to affect the calling window, not the window for the process that gets executed...

Communicating with a Python service.

Problem: I have a python script that I have running as a service. It's a subclass of the win32 class win32serviceutil.ServiceFramework. I want a simple straightforward way of sending arbitrary commands to it via the command line. What I've looked at: It looks like the standard way of controlling the service once it's started is by...

Calling Windows API using VB.NET

How to lock the screen (most important), change the sound, lock the keyboard and etc using VB.NNET? I know it's quite easy to do it using C++ .Net ...

Draw array of bits(rgb) in windows

I have an array of raw rgb data. I would like to know how can I draw this pixels on the screen in Windows OS? Now I use API function DrawDIBits, but I must turn up my image data. ...

Sharing message queues among threads (in Windows)

Is there any way to share a message queue among several threads, or otherwise to read a message queue of a different thread, without using hooks? ...

Processing messages is too slow, resulting in a jerky, unresponsive UI - how can I use multiple threads to alleviate this?

I'm having trouble keeping my app responsive to user actions. Therefore, I'd like to split message processing between multiple threads. Can I simply create several threads, reading from the same message queue in all of them, and letting which ever one is able process each message? If so, how can this be accomplished? If not, can you...

How do I obtain the exit code for a (Java) process with the Win32 API?

How can I obtain the JVM exit code (value of 'status' from call: System.exit(status)) from a Windows program which started this JVM? I tried to use result from the ShellExecute() call, but the result (42) was independent of real value of status. ...

Placing toolbar into Windows taskbar (ala language bar)

Hi all, I'm currently in the process of writing a Windows MFC app to quickly search our corporate DMS. The idea is to have a button placed at the right hand edge of the windows taskbar much like the language bar, that when clicked, would popup the search interface. I can't seem to find much regarding how placing items in the taskbar li...

How to create a transparent window with non-transparent child controls (or child windows)?

Hi All, First, I'm working on Win32 with C++. I have been trying to implement a transparent window with a child window which should remain 100% opaque. It seems that child controls cannot have opacity better (ah.. lower) than the parent and if I make my parent 100% transparent then my child control also inherits the transparency. C...

How to send a link to an application, like Spotify does.

Hi, When we save a level in our editor, we create a log file of any errors it contains. These consist basically of an error message and a path that allows the user to find the erronous item in a tree view. What I want is to make that path a link, something like < a href="editor://path/to/gameobject" > Click to see object in editor< /a ...

Does using SecureZeroMemory() really help to make the application more secure?

There's a SecureZeroMemory() function in WinAPI that is designed for erasing the memory used for storing passwords/encryption keys/similar stuff when the buffer is no longer needed. It differs from ZeroMemory() in that its call will not be optimized out by the compiler. Is it really so necessary to erase the memory used for storing sens...

Is the HPET directly accessible in Windows?

I would like to use the High Performance Event Timer (HPET) for an profiling tool to take very high precision measurements, quickly. timeGetTime does not provide sufficient resolution at 1ms, and QueryPerformanceCounter is much slower per read than I'd like. I came across the HPET while researching the problem, but I can't see any sample...

How to perform atomic 64b read on x86 (Pentium and above)?

I would like to perform and atomic read of 64b aligned 64b data on x86 platform (Pentium or above guaranteed). Is there a way to do this? (And no, I do not want to use a critical section or a mutex for this, I want this to be lock-free). ...

A few ListView questions

The documentation of the ListView control (using WinApi) seem to lack some basic information, here are some questions I couldn't seem to find a solutin to: On most apps, when you double-click the border to the right of a column, the column resizes to some default width. I would have guessed that this width is specified by LVCOLUMN.cxDe...

Getting File Version Information fails -- But not for me

Hello all :) I am trying to get version information from a file. My code works perfectly for me, but fails on several others' machines. Because I can't reproduce the bug, I'm having quite a time finding the issue. Does anyone see anything majorly wrong with this? LPBYTE versionInformationBlock; struct LANGANDCODEPAGE { WORD wLanguage...

Executable sections marked as "execute" AND "read"?

I've noticed (on Win32 at least) that in executables, code sections (.text) have the "read" access bit set, as well as the "execute" access bit. Are there any bonafide legit reasons for code to be reading itself instead of executing itself? I thought this was what other sections were for (such as .rdata). (Specifically, I'm talking abou...

How can I load an image from a resource using GDI+?

I am trying to load a non-bmp image (png in my case) into a Bitmap/Image instance from a resource in my app. Since the Bitmap constructor only has an overload for a bitmap resource, this is what i've came around: I allocate memory on the global heap, and then copy the resource data into it. Then I create an IStream for that global memor...

When using Win32 code in your modern C++ app, should you use proper casting?

For example the following cast can be found littered throughout the MSDN documentation: (LPTSTR)&lpMsgBuf Should I bother converting that to: static_cast<LPTSTR>(&lpMsgBuf); Or should I just leave all the idiomatic C-esque Win32 portions as they are typically found in the docs, and save the more idiomatic C++ style/usage for the re...

Using SendMessage for Simulating User Mouse Clicks

I need to use SendMessage fro simulating user clicks in a target program as SendMessage blocks until the event that it triggers is finished processing. The reason for this is that this blocking gives opportunity to detect if any dialogs have opened up as a result of the clicking. My problem currently is that although I can get the clic...