The Old New Thing

Programmatically uploading a file to an FTP site

Today's Little Program uploads a file to an FTP site in binary mode with the assistance of the Wininet library. This program has sat in my bag of tools for years. The program accepts five command line arguments: site (no "ftp://" in front) userid password path for the file to upload location to place the uploaded file For example, I ...
Comments are closed.0 0
Code

We're currently using FILE_FLAG_NO_BUFFERING and FILE_FLAG_WRITE_THROUGH, but we would like our WriteFile to go even faster

A customer said that their program's I/O pattern is to open a file and then every so often write about 100KB of data into the file. They are currently using the FILE_FLAG_NO_BUFFERING and FILE_FLAG_WRITE_THROUGH flags to open a file, and they wanted to know what else they could do to make their writes go even faster. Um, for one thing, you ...
Comments are closed.0 1
Code

Why do I have to add 1 to the color index when I set it as the hbrBackground of a window class?

Our scratch program sets the background color to COLOR_WINDOW by setting the class background brush as follows: What's with the +1? Okay, first of all, let's backtrack a bit. The real first question is, "What's the deal with taking an integer (COLOR_WINDOW) and casting it to a HBRUSH and expecting anything sane to happen?" The ...
Comments are closed.0 0
Code

What two-year-olds think about when they are placed in time-out

My niece (two years old at the time) was put in the corner as punishment for some sort of misdeed. At the expiration of her punishment, her grandfather returned and asked her, "你乖唔乖?" (Are you going to be nice?) She cheerfully replied, "仲未乖!" (Still naughty!) In an unrelated incident, one of ...

Adventures in automation: Dismissing all message boxes from a particular application but only if they say that the operation succeeded

Suppose you have a program that is part of your workflow, and it has the annoying habit of showing a message box when it is finished. You want to automate this workflow, and part of that automation is dismissing the message box. Let's start by writing the annoying program: This annoying program pretends to do work for a little while, and...
Comments are closed.0 0
Code