winapi

Wiggling the mouse using C#

OK. This is a bit of a vanity app, but I had a situation today at work where I was in a training class and the machine was set to lock every 10 minutes. Well, if the trainers got excited about talking - as opposed to changing slides - the machine would lock up. I'd like to write a teeny app that has nothing but a taskbar icon that does...

Can a windows dll retrieve its own filename?

So a windows exe file has access to the command string which invoked it, including its path and filename. eg. "C:\MyApp\MyApp.exe --help". But this is not so for a dll invoked via LoadLibrary. Does anyone know of a way for a dll to find out what its path and filename is? Specifically I'm interested in a Delphi solution, but I suspect ...

How can you tell when a user last pressed a key (or moved the mouse)?

In a Win32 environment, you can use the GetLastInputInfo API call see msdn doc. Basically, this method returns the last tick that corresponds with when the user last provided input, and you have to compare that to the current tick to determine how long ago that was. Xavi23cr has a good example for C# at codeproject. Any suggestions fo...

Bringing Window to the Front in C# using Win32 API

I am writing an application that needs to bring window of an external app to the foreground, and not necessarily steal focus (there is a setting the user can toggle to steal/not steal focus). What is the best way to go about this using the win32 API? I have tried SetForeground() but it always steals focus and does not consistenly work. W...

Where is a good place to start programming GUIs for windows?

I have experience writing console and network client/server apps in C and C++, but I know next to nothing about using the win32 visual API, MFC, QT, WxWidgets, etc. Where is a good place to start, and what method should I specialize in, so as to be future ready and robust?...

How do you create your own moniker (URL Protocol) on Windows systems?

How do you create your own custom moniker (or URL Protocol) on Windows systems? Examples: http: mailto: service: ...

Does it still make sense to learn low level WinAPI programming?

Does it make sense, having all of the C#-managed-bliss, to go back to Petzold's Programming Windows and try to produce code w/ pure WinAPI? What can be learn from it? Isn't it just too outdated to be useful? ...

Get list of domains on the network

Using the Windows API, how can I get a list of domains on my network? ...

Validating a Win32 Window Handle

Given a handle of type HWND is it possible to confirm that the handle represents a real window? ...

_wfopen equivalent under Mac OS X

I'm looking to the equivalent of Windows _wfopen() under Mac OS X. Any idea? I need this in order to port a Windows library that uses wchar* for its File interface. As this is intended to be a cross-platform library, I am unable to rely on how the client application will get the file path and give it to the library. ...

What is the easiest way to parse an INI File in C++?

I'm trying to parse an INI file using C++. Any tips on what is the best way to achieve this? Should I use the Windows API tools for INI file processing (with which I am totally unfamiliar), an open-source solution or attempt to parse it manually? ...

Is FindFirstChangeNotification the best API to use for file system change notification on windows?

I'm new to windows programming and I'm trying to get notified of all changes to the file system (similar to the information that FileMon from SysInternals displays, but via an API). Is a FindFirstChangeNotification for each (non-network, non-substed) drive my best bet or are there other more suitable C/C++ APIs? ...

Suitable alternative to CryptEncrypt

We have a situation in our product where for a long time some data has been stored in the application's database as SQL string (choice of MS SQL server or sybase SQL anywhere) which was encrypted via the Windows API function CryptEncrypt. (direct and decryptable) The problem is that CryptEncrypt can produce NULL's in the output, meanin...

Sending a mouse click to a button in the taskbar using C#

In an application that I am currently working on, a requirement is to bring a window of an external application to the foreground. Making Win32 API calls such as BringWindowToTop and SetForeground window do not work all the time. This is due to some restrictions within Windows XP. What I would like to do instead is send simulate a mou...

Getting UI text from external app in C#

Is it possible to get UI text from an external application in C#. In particular, is there a way to read Unicode text from a label (I assume it's a normal Windows label control) from an external Win32 app that was written by a 3rd party? The text is visible, but not selectable by mouse in the UI. I assume there is some accessibility AP...

FlashWindowEx FLASHW_STOP still keeps taskbar colored

I am developing an application that controls an Machine. When I receive an error from the Machine the users should be able to directly notice it, one way that is done is Flashing the tray on the taskbar. When the machine clears the error the tray should stop flashing. There's one little annoyance using the FlashWindowEx function, when I...

What's an alternative to GWL_USERDATA for storing an object pointer?

In the Windows applications I work on, we have a custom framework that sits directly above Win32 (don't ask). When we create a window, our normal practice is to put this in the window's user data area via SetWindowLong(hwnd, GWL-USERDATA, this), which allows us to have an MFC-like callback or a tightly integrated WndProc, depending. Th...

Find out which process has an exclusive lock on a USB device handle

I have a library that reads/writes to a USB-device using CreateFile() API. The device happens to implement the HID-device profile, such that it's compatible with Microsoft's HID class driver. Some other application installed on the system is opening the device in read/write mode with no share mode. Which prevents my library (and anythin...

Notification of drop in drag-drop in Windows

My C# program has a list of files that can be dragged from it and dropped into another program. My requirements are that the file be copied to a different directory first. So, can I be notified of the drop operation so that I can only copy the file if operation succeeds? I'd rather wait till I know it needs to be copied before actually ...

How to convert std::string to LPCWSTR in C++ (Unicode)

I'm looking for a method, or a code snippet for converting std::string to LPCWSTR ...