winapi

Changing a dialog's style at creation to override what's in the .RC template

I have a little dialog I created using Resource Editor in VS2005. It's going to be used as a child dialog of another dialog, in 2 different ways... either as a child which sits on top of the dialog like a custom control, or as a popup which can move beyond the boundaries of the parent window. If I modify a single style in the RC file, bo...

Raising event on reading file?

I have external app reading files, I want to hook that to get event in my app. But I cannot find a sources hooking ReadFile (or something else that can help me achieve that). Any ideas how to do that? It must be done in User-Mode. I was thinking for something similar to Process Monitor. I wonder how it does it.. ...

Is it possible to determine the working directory of another process?

Given a HANDLE (or ProcessID) to process 'A' is it possible on Win32 for an unrelated process 'B' to determine the current working directory of process 'A' ? ...

LogonUser -> CreateProcessAsUser from a system service

I've read all the posts on Stack Overflow about CreateProcessAsUser and there are very few resolved questions, so I'm not holding my breath on this one. But it seems like I'm definitely missing something, so it might be easy. The target OS is Windows XP. I have a service running as "Local System" from which I want to create a process ru...

How to marshall a LPCWSTR to String in C#?

I'm trying to define a P/Invoke signature for the following method (defined in propsys.h) PSSTDAPI PSRegisterPropertySchema( __in PCWSTR pszPath); I've seen on the WinNT.h that PCWSTR is an alias to LPCWSTR as typedef __nullterminated CONST WCHAR *LPCWSTR, *PCWSTR; And the PSSTDAPI is an alias for HRESULT So how should be the ...

Python - Launch a Long Running Process from a Web App

I have a python web application that needs to launch a long running process. The catch is I don't want it to wait around for the process to finish. Just launch and finish. I'm running on windows XP, and the web app is running under IIS (if that matters). So far I tried popen but that didn't seem to work. It waited until the child pr...

Issue with EnumWindows

When enumerating windows using EnumWindows, I get hundreds of handles instead of one per open window on my desktop. First of all, i am curious if this is the correct behavior. Secondly, trying to get a difference between open windows before and after launching a process returns 15-20 new handles. I am wondering if there is a way to fi...

Compile unmanaged executable for BOTH x86 and x64

Is there any way to compile an EXE file, so that it will run natively in both x86 and x64? Something like: compile both codebases and pack them into a single executable. I know .NET code could run in "any cpu" mode, but it is not what I want. ...

How to tell if a MFC Dialog has been created/initialized?

I have an OnMove handler in my dialog class, which does some stuff with control objects (i.e a CButton). I'm finding this handler gets called before the dialog OnInitDialog method is called, and hence when I try to call methods on the child controls, I get ASSERTS in debug as the controls don't yet exist... they are created in OnInitDial...

wpf and win32 overlapping issue

I have a wpf Window, which has wpf control and windows forms control hosted in WindowsFormsHost. The expected behavior is that the WPF control should be rendered on top of WindowsFormsHost. Unfortunately, this is a limitation in the interop story, WindowsFormsHost elements are always drawn on top, and don't get affected by z-order. http...

Do I need RpcEpRegister() for well-known endpoints?

Our native Win32 C++ RPC server application doesn't use RpcEpRegister(), instead it calls RpcServerUseProtseqEp(), then RpcServerRegisterIf(), then RpcServerListen() and that stuff works except for minor problems we still can't solve. I've thoroughly read MSDN and still don't get whether using this function is necessary. What exactl...

Which messages are processed by DefWindowProc?

is there any documentation which messages are processed by DefWindowProc, and how? I recently stumbled over WM_SETFONT/WM_GETFONT not being handled, I'm not sure if there's a mistake in my code, or if that's expected behavior, so I tried the following WinMain: WNDCLASSEX wcx = { sizeof(WNDCLASSEX), CS_HREDRAW | CS_V...

How to get USB devices List

I want to get the list of usb devices from the Windows system. I don't know Win 32 programming and all. I am using Qt for development, don't have any idea to solve my problem. I have searched code for that, but I can't find anything. ...

WINAPIs keybd_event() not recognized in certain progams

I've made an interface to a NES Controller with an atxmega, which send the keys through serial. The problem lies in the program that reads the input and sends keybd_events accordingly. if(szBuff[0] & BTN_LEFT) { keybd_event(VkKeyScan('j'), 0, 0, 0); keybd_event(VkKeyScan('j'), 0, KEYEVENTF_KEYUP, 0); } Problem is, it fails to ...

Execute code in another users context

I have an app with a manifest that requires running as administrator, but part of the app is to map a drive using WNetAddConnection2 which I believe requires it to be run in the normal user context due to credentials etc. Is there a way to execute this bit of code in the normal user context without creating a separate process. EDIT Fro...

How to decompress compiled qt resource file with rcc extension?

How to decompress compiled qt resource file with rcc extension? ...

Resolving RVA's for Import and Export tables within a PE file.

I am currently writing a PE parser/loader. I have successfully loaded the PE file into memory using standard c file io, retrieved valid DOS and PE headers (the optional header) as well as gaining access to the PE's sections. My next target is to gain access to the Export table to retrieve exported symbols. To do this i have used the RVA ...

"start /affinity" equivalent in .NET

The start Windows shell command (in cmd.exe) appears to be able to start a process with a chosen processor affinity, rather than starting the process then setting the chosen processor affinity some (small) period of time after it has started. start /affinity 2 something.exe Is there a way to do the same from within a .NET application ...

Efficient way to send files across processes

How to effectively send a file from my own process to a program such as Photoshop, Word, Paint. I do not want to save the whole file to disk and then open the program from the startup parameters using CreateProcess, ShellExecute, etc. Maybe the only way out is Memory Maped Files? Maybe I should look to COM, IPC, Pipes? ...

Expand Registry Environment Variable Strings on Remote Machine

After calling RegConnectRegistry(...) to open the registry on a remote machine, is it not possible to expand environment variables? I have looked at ExpandEnvironmentStrings and ExpandEnvironmentStringsForUser, but that only appears to be useful on the local machine. I think it must be possible considering that RegistryKey.GetValue() in ...