winapi

How can a Windows service execute a GUI application?

I have written a Windows service that allows me to remotely run and stop applications. These applications are run using CreateProcess, and this works for me because most of them only perform backend processing. Recently, I need to run applications that present GUI to the current log in user. How do I code in C++ to allow my service to lo...

How do you convert multistring to/from C# string collection?

Multistrings (double null-terminated string of null-separated strings) are common in the Windows API. What's a good method for converting a multistring returned from an API to a C# string collection and vice versa? I'm especially interested in proper handling of character encoding (Windows XP an later). The following method seems to be...

How to quickly get started at using and learning Emacs

There are all sorts of advantages to using Emacs, but for someone comfortable with the usual Win32 applications it comes with a wall-like learning curve. With most other editors it’s possible to just start using them and then learn about their other features and enhancements as you go along. How to just get on with using Emacs straight...

How to repaint the UI inside DoDragDrop

I'm implementing my app as a drag source. When I call DoDragDrop (Win32 call, not MFC) it enters into a modal loop and I don't get repaint messages in my main window until DoDragDrop returns. Unfortunately if I do a drop in the shell (a file) and the filename is already there the shell asks if I want to replace the file. But since me app...

Alternative to GetProcessID for Windows 2000

I've accidentally removed Win2K compatibility from an application by using GetProcessID. I use it like this, to get the main HWND for the launched application. ShellExecuteEx(&info); // Launch application HANDLE han = info.hProcess; // Get process cbinfo.han = han; //Call EnumWindows to enumerate windows.... //with this as the callba...

User Interface Privilege Isolation in XP SP3

Hi All, Just after a bit of confirmation really: Does XP SP3 implement the User Interface Privilege Isolation (UIPI) mechanism found in Vista? Back story for human interest :) I've recently been handed the C++ source to a fairly large application. Sadly the sole developer of this application, since its inception back in the mid 90's, ...

Calling Win32 functions returning strings with alien in Lua

I'm trying to use alien to call Win32 functions. I tried this code, but it crashes and I don't understand why. require( "alien" ) local f = alien.Kernel32.ExpandEnvironmentStringsA f:types( "int", "string", "pointer", "int" ) local buffer = alien.buffer( 512 ) f( "%USERPROFILE%", 0, 512 ) ...

Is it possible to "decompile" a Windows .exe? Or at least view the Assembly?

A friend of mine downloaded some malware from Facebook, and I'm curious to see what it does without infecting myself. I know that you can't really decompile an .exe, but can I at least view it in Assembly or attach a debugger? Edit to say it is not a .NET executable, no CLI header. ...

Form.Release + NIL

Hello, if Form.Release is called after using the form, it will free all related memory but not set the form variable to nil. if not assigned (Form1) then begin Application.CreateForm(Tform1, Form1); try // Do something finally Form1.Release end; end; To be able to call the same code again, Form1 would ...

Slow performance of AddString in MFC

I've got a dialog with several largeish combo boxes in it (maybe several hundred items apiece). There's a noticeable delay at construction while these are populated (confirmed that it's them by profiling). My initial thought was that sorting was killing it's performance, but disabling sort and using InsertString instead doesn't seem to ...

How can I use C to change the last modified date of a file in Windows?

Is there a C function call that can change the last modified date of a file or directory in Windows? ...

API for getting screen region changes?

I am writing a sort of screen-recording app for Windows and wish to know when and which regions of the screen/active window have changed. Is there a Windows API I can hook to get notified of screen changes? Or would I need to manually write something like this? :( I always figured that Remote Desktop used some sort of API to detect wh...

Win32 WriteProcessMemory() magical offset value

I'm trying to read the data in a Win32 ListView owned by another process. Unfortunately, my WriteProcessMemory() call fails with the error "This function is not supported on this system." when I specify "NULL" for the base address in my VirtualAlloc() call. If, however, I offset that VirtualAlloc() address by some "magic" value that I go...

RGB back buffer in Win32

I have an array of RGB values, whose size I can guarantee to match the client area of a window on screen. Using the Win32 API, what are the easiest and fastest ways to get the contents of my array on the screen in response to a WM_PAINT message? If it makes it simpler/faster, we can assume it's a 32-bit display and each element of the ...

SendMessage API in 64 bit

According to MSDN The return value specifies the result of the message processing; it depends on the message sent. I know it is defined as typedef LONG_PTR LRESULT; Meaning it will be 8 bytes on 64bit machine but (!) .... Does anyone know if it is safe to assume that only the lower 4 bytes are used and store it as an IN...

Win32: Registry entries required to register an ActiveX control?

i need write the code that runs when DllRegisterServer is called. i.e. when someone calls: regsvr32 myActiveX.ocx i'm trying to find the definitive list of required registry entries (rather than just what i can cobble together by spellunking through the registry). So far my expeditions have found: HKEY_CLASSES_ROOT \MyCoolLibrary...

Tuning socket connect call timeout

Is there any way in a Win32 environment to "tune" the timeout on a socket connect() call? Specifically, I would like to increase the timeout length. The sockets in use are non-blocking. Thanks! ...

Win32: How to use RegisterTypeLib API from standard user.

The Win32 API call RegisterTypeLib() is used to create the registry keys necessary to register a type library. Unfortunatly, on Windows XP, it tries to write those registry key entries to HKEY_CLASSES_ROOT\TypeLib rather than HKEY_CURRENT_USER\Software\Classes\TypeLib Meaning that a standard user will not be able to run an Activ...

WS_VSCROLL, CreateWindow style works, SetWindowLong doesnt

When i do wnd = CreateWindow("EDIT", 0, WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN, x, y, w, h, parentWnd, NULL, NULL, NULL); everything is fine, however if i remove the WS_VSCROLL and WS_HSCROLL then do the below, i do not get them thus have i...

Enumerating all available drive letters in Windows

Hi! I want to enumerate all available drive letters (which aren't already taken) in Windows using VC++. How can I do this? ...