winapi

Windows SearchPath function

I am using the following to search for a file defined as a macro DB_CONFIG_FILE_PATH_1. wchar_t filename[100]; SearchPath( L".\\", DB_CONFIG_FILE_PATH_1, NULL, 100, filename, NULL); If the file is in C:\ directory, it is found. But, if the file is in one of its sub-directories the function doesn't find it. Can some explain how to sea...

Differentiating between data card and pen drive or USB flash drive

I am having a Vodaphone data card which can be inserted in a USB port. I have XP and Vista OS, and I am using WM_DEVICECHANGE event of Windows, to know USB Insertion and removal, and it's working fine for me. But I am not able to differentiate between Data card insertion and Pen drive insertion. Is it possible? ...

Return value of process

How can I get the return value of a process? Basically I'm ShellExecute()ing a .NET process from a DLL (in C++). The process does its task, but now I want to know whether it succeeded or failed. How to do that in WinAPI or MFC? ...

Intercept modal dialog popup from another application

We have a third party Windows application that we feel is too complex for our users to use efficiently. The application manages a scanner that we're using to scan 3000 documents per day. The scanner application can be completely piloted using the keyboard. We are therefore in the process of writing a simple WinForms application that ha...

Using FindVCLWindow to call WinHelp32 (WinXP Pro SP3 32bit) in Delphi

what is wrong there? procedure TForm1.VCLHelpClick(Sender: TObject); var Ctrl : TWinControl; begin Ctrl := FindVCLWindow(Mouse.CursorPos); if Ctrl <> nil then if Form2.Cursor = crHelp then begin if Ctrl = CreatorEdit then Application.HelpCommand(HELP_CONTEXT,001); if Ctrl = EditorEdit then Application.HelpCommand(HELP_CONTEXT...

Question about operation on files in Windows.

I have two HANDLEs and they are created from the same file, in such condition I want to write on offset from 1 to 100 using the first HANDLE, and from 101 to 200 using the 2nd HANDLE, from 201 to 300 using the first HANDLE, ..., How can I make this operation seems like a sequential write and no time is wasted between positioning t...

Save a custom cursor created by CreateIconIndirect to a cur file.

Hey, I've been trying to write code that loads a .png file, attaches hotspot information, and saves it to a .cur file. So far I have code to create a System.Windows.Forms.Cursor object, which I'll post below: Bitmap bmp = new Bitmap(source_image); IconInfo inf = new IconInfo(); GetIconInfo(bmp.GetHicon(), ref in...

Creating Compressed (Zipped) Folder using Delphi

Can I create Windows XP's Compressed (Zipped) Folder using Delphi? ...

Read/write synchronization

I have a data structure whose operations can be categorized as read operations (e.g. lookup) and write operations (e.g. insertion, removal). These operations should be synchronized so that: Read operations can't execute while a write operation is executing (unless on the same thread), however read operations can be executed concurrentl...

Where is InterlockedRead?

Win32 api has a set of InterlockedXXX functions to atomically and synchronously manipulate simple variables, however there doesn't seem to be any InterlockedRead function, to simply retrive the value of the variable. How come? MSDN says that "Simple reads and writes to properly-aligned 32-bit variables are atomic operations", but adds t...

Enable secondary monitor programmatically

I want to be able to enable my secondary monitor with C# in Windows Vista. Here is what I do: SafeNativeMethods.EnumDisplayDevices(null, (uint)id, ref d, (uint)0); ... SafeNativeMethods.EnumDisplaySettings(d.DeviceName, -2, ref mode0); ... SafeNativeMethods.DEVMODE dm = mode0; dm.dmPosition.x = 1440; dm.dmFields = SafeNativeMethods.DM_...

What's the fastest way to read/write to disk in .NET?

I've got a little program that reads and writes files on disk. Breaking it down to the most simple level, it reads bytes from one file stream and writes them to another. It performs its duties fine, but it isn't the fastest thing. I've seen other applications that can tear through a gigabyte or more of reads/writes in amazing speeds. ...

Why does OpenThemeData(pParent, L"TEXTSTYLE") fail on XP?

I'm using the theme library to draw some text which works absolutely fine on Windows Vista - however, on Windows XP the returned HTHEME is NULL. This is the code I'm using: HTHEME hTheme = ::OpenThemeData(pParent, L"TEXTSTYLE"); hTheme is valid on Vista, but NULL on Windows XP. I've read the documentation for OpenThemeData and Parts a...

how to differentiate between lan card and data card

Dear All, I have a Data card with me. I wanted to know, is there any way programatically, i can tell that, it is data card and it is LAN card. I have used IFTable, I have used IListManager, INetwork manager provided by microsoft, but not able to solve the problem Edited: I have one lan card and one data card connected on my system, ...

How can we differentiate LAN and wireless data card network connection using NLM(NetworkListManager) API's?

I am working with NLM API's (windows). I have a LAN connection and Wireless data card connection. I am enumerating the networks available. Code: HRESULT hr; VARIANT_BOOL pBool1, pBool2; IEnumNetworks *pEnumNetworks; INetwork *pNetwork; hr = pNetwork->get_IsConnected(&pBool1); hr = pNetwork->get_IsConnectedToInternet(&pBool2); I ha...

PostMessage params from 32-bit C# to 64-bit C++

I am having problem with the contents of a pointer passed as the wParam from a 32-bit C# application is changing along the way to a 64-bit C++ process. There are two processes 32.exe (in C#) and 64.exe (in C++). 64.exe is started as a child process of 32.exe. 32.exe post window message for 64.exe, one of which has a wParam that is a poi...

In .NET, can I detect system focus events (C#)?

Is it possible to determine when window focus changes at the system level? I'm writing a time-tracking application, and I'd like to be able to listen for application switching (so that I can begin logging time in a given application). I've poked around the Process class for a good hour here, and while I learned quite a few useful things,...

Opening OLE Compound Documents read-only with StgOpenStorage

Hi everyone! I'm using the StgOpenStorage API under XP to read an OLE Compound Document, but I can't find the right mix of flags to tell Windows that I need just to read the file without blocking access to it to any other process... Right now I'm using STGM_READ | STGM_EXCLUSIVE but obviously if at the same time I try to open the file fr...

How do I color output text from Perl script on Windows?

I would like to color format the text printed to the console using the Perl print command. In my case the script will only be run under WinXP-DOS Command Line but it would be great if it was OS independent although I would rather tie it to WinXP than have to download a seperate package. ...

What is the recommended way to hook Win32 APIs for a commmercial application?

What is your recommendation for an API hooking library or code to be used in a commercial application? I have looked at Microsoft Detours which seems to be very good, but definitely is out of budget for the profit I am expecting out of my application. Is there any library that offers compatibility across WinXP and Vista (and Windows 7...