winapi

Detect drag and drop operations in an external application using .Net

I need to detect drag and drop operations in an external application, is it possible? I thought of writing a hook to detect these operations. Can anybody point me in the right direction as far as which messages or api functions I could attempt to hook to detect the Drag & Drop events? I want to do this in C#. Thanks in advance. ...

Waiting until a file is available for reading with Win32

I'm watching a directory by calling ReadDirectoryChangesW synchronously. When a new file is available, I try to access it immediately with CreateFile with GENERIC_READ and FILE_SHARE_READ, but this gives me ERROR_SHARING_VIOLATION. The process that put the file in the watched directory does not finish writing by the time I try to read it...

how to draw image on a window

Dear All, I have created a window with createwindow() api using vs2005 in c++ on windows Vista My requirement is to draw image(any format) on that window. I am not using any MFC in this application Please help me with some code snippet with regards Vinayaka Karjigi ...

LoadLibrary on OCX file fails in Windows 7 x64

Hi, I need to open a html help file from within a legacy windows application written in old version of C++ Builder. HtmlHelp is loaded via HtmlHelp.ocx, which I am loading via LoadLibrary. This has worked fine for years, but it does not work anymore in Windows 7 x64. It might also fail under Windows7 x86, but I don't have any computer...

HOWTO: Tag a process

Hi: I am using CreateProcessAsUser() to make processes. I would like to tag some of them so that later on, given a process ID/handle I can work out whether or not it was I who launched them. Are there any techniques for marking a process natively like this. I want my solution to be stateless, hence a table of PIDs is not suitable - no...

Track handle creation / deletion

I have a large old program which has some rather complex graphical displays (all via standard API calls). The program appears to be working fine, but I recently looked at the "handles" field of Windows Task Manager when this program was running and noticed that the number of handles was gradually and relentlessly creeping upwards. Is th...

Determine the current HINSTANCE?

The HINSTANCE of a win32 application is passed to WinMain, but is there any other way of determining the current HINSTANCE (in case you couldn't tell, I'm very new to win32 programming!)? I need to create a window inside of a library and (since the library is cross platform), id prefer not to have to pass it in. ...

XP alternative to "TEXTSTLYE" Aero theme class

I'm using the "TEXTSTYLE" class with OpenThemeData in Vista/Win 7 to render text elements with the appropriate emphasis (all values found on the Parts and States documentation): TEXT_MAININSTRUCTION for my header text TEXT_SECONDARYTEXT for subtitles TEXT_HYPERLINKTEXT for links TEXT_INSTRUCTION for standard text This looks great ...

DeleteFile fails on recently closed file

I have a single threaded program (C++, Win32, NTFS) which first creates a quite long temporary file, closes it, opens for read, reads, closes again and tries to delete using DeleteFile(). Usually it goes smoothly, but sometimes DeleteFile() fails, and GetLastError() returns ERROR_ACCESS_DENIED. File is not read-only for sure. It happen...

How to add picture box in win32 API using visual c++

I have a Window (win32 API) Application in visual c++. I am not using MFC. I have to add a picutre box to my application and Change the image of this picture box periodically. Can any one help me out in achieving the above task? Thanks in advance. ...

Most efficient way to create and write multiple 10 KB text files?

We're using the following approach to writing out text files: public void WriteFile(string filePath, string contents) { if (string.IsNullOrEmpty(filePath)) { throw new ArgumentNullException("filePath"); } if (contents == null) { throw new ArgumentNullException("contents"); } if (File.Exists(filePath)) { throw ne...

Enumerating all IDispatch implementing objects on a machine.

Hi there, I'd like to enumerate all IDispatch supporting objects on a machine. At the moment I need to know what the class id or prog id is but, for inspecting my machine, I'd like to know if I can just enumerate all the objects that implement IDispatch. Is this even possible? Any help would be much appreciated :) ...

How to change underlining color in a Rich Edit control (Win32/C)

I’m looking for a way to make red squiggly underlining in a Rich Edit control (I’m using version 4.1 with Msftedit.dll). I’m able to produce squiggly underlining with this code : CHARFORMAT2 format; format.cbSize = sizeof(format); format.dwMask = CFM_UNDERLINETYPE; format.bUnderlineType = CFU_UNDERLINEWAVE; SendMessage(hWndEdit,EM_SETCH...

Calling ReadFile after DeviceIOControl yields unexpected results (Need Parallel BUSY Status).

Hi folks, I'm using "LPT1" via CreateFile for Overlapped communications. I use WaitSingleObject and then GetOverlapped Result to collect ReadFile results. All that code, including overlapped WriteFile's work great and have been for years. However, now I need to get the BUSY state of the port. It appears the only way to do this in the...

Prevent windows from queuing shellexecute requests

Win.ShellExecute 0, "open", "C:\dir\program.exe", "arguments", vbNullString, SW_SHOWNORMAL Win.ShellExecute 0, "open", "http://www.google.com", vbNullString, vbNullString, SW_SHOWNORMAL I want google.com to open regardless of whether or not program.exe is still running. How do I fix this? I would rather avoid things like calling "star...

Win32 DrawText line height

I'm calling the Win32 DrawText function to output some text into a device context. The text is long and wraps nicely onto a second line. The problem is I need to decrease the space between lines a bit (I guess decrease the line height?). Any ideas on how to do this? I would just call DrawText twice (one for each line) but then I ha...

Win32 CreateWindow() call hangs in child thread?

I'm working on a portability layer for OpenGL (abstracts the glX and wgl stuff for Linux and Windows)... Anyhow, it has a method for creating a Window... If you don't pass in a parent, you get a real window with a frame... If you pass in a parent, you get a borderless, frameless window... This works fine, as long as I do it all on 1 thr...

How to prevent starting TaskManager in my Desktop?

Hi, I am creating a new Desktop in Windows XP/Vista and 7 using win32 API. This is more like having a secure Desktop and I don't want let any other application to be executed in that Desktop. Well, in Windows XP if I press strg+shift+Esc or strg+alt+ent, in the Desktop which I created, I don't see the task manger on my Desktop but inst...

Encapsulating WndProc Problem.

Okay so i wrote a basic class to do encapsulation of a win32 window. I ended up creating a static router callback function to route the messages into another function of the class. EDIT OKAY I Got it m_MainWindowHandle = CreateWindowEx( windowFormat, L"LUDO ENGINE", m_WindowName.c_str(), WS_OVERLAPPEDWINDOW, CW_U...

How to call IsDialogMessage in a Modal Dialog

In my Win32 app, I had a modal dialog that displays settings that I had to add more settings to. In order to fit the new settings, I dropped a TabCtrl in the dialog and implemented two modeless dialogs. The UI is working switching between them but the modeless dialogs don't respond to the keyboard. In a regular app, IsDialogMessage (hW...