winapi

How does FileSystemWatcher work on another computers directory?

Something intrigues me and I don't find any resource on this. How can FileSystemWatcher know when a file on a computer "A" is created/removed/changed/renamed ? I thought that this worked with polling, (the observer polls the server to check update), but after verifying the network activity with Wireshark I saw that polling was not use...

GetDiskFreeSpaceEx reports wrong number of free bytes

__int64 i64FreeBytes unsigned __int64 lpFreeBytesAvailableToCaller, lpTotalNumberOfBytes, lpTotalNumberOfFreeBytes; // variables used to obtain // the free space on the drive GetDiskFreeSpaceEx (Manager.capDir, (PULARGE_INTEGER)&lpFreeBytesAvailableToCaller, ...

How to handle notify messages in child & parent classes?

I have a custom CTabCtrl which I am trying to customize (to automatically change pages). If I handle ON_NOTIFY_REFLECT(TCN_SELCHANGE, ...) in my tab control, ON_NOTIFY(TCN_SELCHANGE, ...) is not received by the parent class. How can I receive both notify messages in the child and parent classes? Currently I am using a "workaround" of...

Using GNU gettext on Win32

I'm writing a game that is mainly geared for GNU/Linux and Mac OS X systems, but I've been keeping things fairly portable in most of my code. I've ported nearly all of the OS-specific stuff to Windows; the only thing remaining is i18n. My question is this How am I supposed to use Win32's setlocale() function along with gettext? ...

URLs in Win32 VERSIONINFO resources?

One of our managers has decided that the CompanyName in our EXE/DLL files (in the VERSIONINFO resource) should contain our URL (e.g. "OurCompany - http://www.ourcompany.com"). I think this is a bad idea, because it could lead to unintended consequences. It also offends the aesthete in me, because the field's not call CompanyNameAndUrl, ...

Need help to display Japanese Text using GDI+ without installing East Asian Language pack in Windows XP

I am writing a Japanese language quiz program and I don't want to require people to install the East Asian language pack for Windows XP. I am using GDI+ for drawing text. I tried downloading a free Unicode font and using that to draw text. I tested it on my computer (with East asian pack installed) and it displayed the Japanese charac...

Prevent windows from going into sleep when my program is running?

I have to stop windows from going into sleep when my program is running. And I don't only want to prevent the sleep-timer, I also want to cancel the sleep-event if I press the sleep-button or in any other way actively tell the computer to sleep. Therefore SetThreadExecutionState is not enough. Or...I don't actually have to prevent the ...

How to notify the user of important events for a desktop application?

Our customer is using our software (Java Swing application started using Webstart) besides other software like MS Office, to do his job. From time to time there are important events he has to deal with in our software without much delay. The customer wants to have a prominent notification then. Now he might be using Excel at the moment, ...

Programmatically getting per-process network statistics on Windows?

I'd like to find out which processes are using my network. This is quite easy in Linux, but I'm stumped as to how to do this in Windows. Essentially, I'd like, for each process, to know how many bytes it has read/written to the network over a time period. If I could know IP addresses/port numbers, etc., that would be awesome. Any point...

Library initialization -- pthread_once in Win32 implementation

Hello. I am trying to make a fully thread-safe initialization function for my library and I couldn't easily find an alternative to pthread_once, which should solve the problem very easily. I've come to this code: void libInit (void) { #ifdef WIN32 static volatile int initialized = 0; static HANDLE mtx; if (!initialized) ...

Creating C++ DLLs with Visual Studio

I am creating a simple C++ DLL project using Visual Studio 2008 Express Edition. I have a few classes inside a namespace, and a few non-static functions and constructors inside it are declared with __declspec(dllexport). All those functions are implemented. I also have an extern "C" BOOL APIENTRY DllMain function which simply returns TR...

Win32: Determine whether stdout handle is char or wchar stream

I'm writing a win32 utility function for our product that needs to call an arbitrary program via the shell and log its output. We do this by redirecting the stdout from the child process into a pipe: saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.bInheritHandle = TRUE; saAttr.lpSecurityDescriptor = NULL; Create...

ImageList Transparency on Listviews?

EDIT: I've offered a bounty, since I doubt I'll be getting any answers otherwise. Lately I've been working with listviews and I've decided to add an icon for each item indicating whether it's input or output. The icons add fine, but they're not transparent: As can be seen, the icons are clearly not transparent. I'm currently doing so...

How to make an icon button in C++

I know how to draw a button in C++ but how would i make an icon on it can someone post source or give reference please? by SendMessage() or if not that way just please paste Please need easier anwsers without so many files im new a bit ...

C# - Win32: Getting a handle to the topmost window, after it has lost focus?

Hi Trying to dig into the win32 api from my WPF application (which just runs through the systray). When clicking on the systray icon, I present the user with a contextmenu, which gains focus over whatever window was topmost. I want to get a handle to that window (the one, that just lost focus) and have tried with different approaches...

Shouldn't Gdiplus::Image::GetWidth() and a bunch of other getters be "const"?

Why aren't they const? I believe that's flawed API design. Or am I missing something? UINT GetWidth(); UINT GetHeight(); ... vs. UINT GetWidth() const; UINT GetHeight() const; ... ...

Simple Thread Synchronization

I need a simple "one at a time" lock on a section of code. Consider the function func which can be run from multiple threads: void func() { // locking/mutex statement goes here operation1(); operation2(); // corresponding unlock goes here operation3(); } I need to make sure that operation1 and operation2 alwa...

ListBox.FindString what's the worst case runtime? O(n), O(n log n), O(1)?

Out of curiosity, what is ListBox.FindString(string)'s worst case runtime? MSDN does not state this in its API docs. I have a strong suspicion it is O(n), I have a sorted list and O(log n) or O(1) would be nice, is there a way to change which sorting algorithm FindString uses at runtime? ...

Concept of WNDCLASSEX, good programming habits and WndProc for system classes

I understand that the Windows API uses "classes", relying to the WNDCLASS/WNDCLASSEX structures. I have successfully gone through windows API Hello World applications and understand that this class is used by our own windows, but also by Windows core controls, such as "EDIT", "BUTTON", etc. I also understand that it is somehow related t...

wtsapi32.WTSQuerySessionInformation() Failing on x64

Hi All, I'm trying gather Terminal Server session information on 64-bit Windows machines. My question is two fold. First, on 32-bit machines we called the following function, which worked fine. Private Declare Function WTSQuerySessionInformation Lib "wtsapi32" _ Alias "WTSQuerySessionInformationA" _ ...