Dealing with Pointers

Some Windows API functions return pointers. Sometimes the pointer comes back in the return value, sometimes in a reference argument. And sometimes it comes back in a field of a UDT. Regardless of how you get it, you can do only one thing with a pointer: pass it on. In Basic, you should treat pointers the same way you treat handles. A handle is a sacred object passed to you for safekeeping, and modifying it will incur the wrath of the gods. As far as Basic is concerned, pointers should be treated with the same reverence.

You’ll see pointers in the Windows API documentation as either a type followed by * (often void *) or a defined type starting with LP (such as LPVOID). The LP in LPVOID stands for long pointer, which is what everyone except the designers of Windows called a far pointer. Nowadays a pointer is a pointer—no near or far or huge about it. In C, when you declare a pointer, you must specify what it points to. You can’t do that in Basic. In fact, you have to lie to force Basic to accept pointers at all. You claim that the pointer is a Long. Once you get the pointer, you never do anything with it except pass it to another Windows API.