LETTERS

Windows Instance Return

Dear DDJ,

Just about the most common programming task required for each application I write for Windows is located at the beginning of WinMain, namely, code to ensure that, at most, one instance of the application can exist. All this code has to do is return to the previous instance, if any. Sounds simple, right? Well, there's no Windows function to do it! Not only that, but the existing published examples I've seen fail in a number of simple situations. See Example 1 for some generalized code that you can plug right into your applications to accomplish this common task. This code has been tested in several applications.

David Spector

Waltham, Massachusetts

Copyright Questions

Dear DDJ,

Having owned three IBM-compatible computers since 1982 and having used several such computers at work, I'm concerned about the issues raised in your January "Editorial." In this ten-year period, I've probably spent more dollars on software than on hardware. I have also upgraded software numerous times and changed to new products when old products failed to stay competitive or when their update costs were out of line with those of their competitors. I also have made a conscientious effort to regularly backup my systems at home and at work using both floppy- and tape-based techniques. Combining this experience with your editorial has prompted several concerns. Therefore, I would be interested in an article addressing the following:

Ignorance of the law. Publishing a copy of the law and an interpretation of it in plain English would be most helpful. Along with this interpretation, the impact of the law on some typical examples would be most helpful. Only with this type of assistance can the user community understand how the law relates to their use of computer software.

Creditability of vendor records. During this ten-year period I have made an effort to register all of my software. Unfortunately, when I moved recently, I found out that many vendors do not make a very strong effort to track their users. In many cases their records were incomplete or non-existent, or they had mixed up registrations for work and personal copies. In one case, the vendor had no way to track copies owned at both work and home by the same individual. Their response in many cases was to send in the registration card (which had been sent to them years before). Therefore, how can the user community be held responsible for proof of license when vendors are not diligent in their record keeping?

Number of copies made. Your article states that if more than two copies are made for personal use, penalties can be imposed. Does this cover copies contained in system backups? If so, probably every user of backup software could be sent to jail. Most long-term users have learned that incremental backups are fine over the short term, but that full backups are required periodically if system restoration is to be feasible in any sort of reasonable manner. In ten years I have probably accumulated numerous copies of key software on my floppy and tape backups.

The other aspect of this question is, what about previous versions of the software--do they count as additional copies? In many cases as software has changed over the years the new versions lack direct compatibility with data created using previous versions. Therefore, to provide reliable access to this data, all versions of the software must be retained.

What if the software license allows you to make more than one copy, do the numbers stated in the law still apply?

Purpose of backup copies. We backup software to ensure that if something happens to the original diskettes, we can still use the software. What is our position if the originals are lost or destroyed? Having a legitimate copy of software without the original disks may place the user in a difficult situation. Also, in such a situation, can the user then legally make an additional copy? Further, does the working copy of the software on the hard disk count as one of the two backup copies?

Burden of proof. Your editorial implies that the powers that be must first establish reasonable proof that you have violated the law to enter your office or house. Could they use the fact that you own an option board or Fastback as an indication of generic guilt and search for any duplication, or must they specifically state that they are looking for duplicate copies of Wordperfect? If they must be specific, what happens if they find other copied software during their search? If the first case is true, then maybe the industry should track the sale of all companies selling backup software more closely.

Out-of-print software. Several of the programs I have used over the last ten years have ceased to be available. Can I make copies of these programs to allow others to access the old data created with them?

Define availability for use. If you have a computer at home and one at work, can you use one copy of a software package in both locations under any of the following conditions?

  1. You delete and reinstall the package with each use.
  2. You delete and reinstall only the main .exe file with each use.
  3. Your computers are password protected or locked and only you have the means of access.
  4. Your computers are used only by you at both locations, but there is no physical or software control that prevents others from using them. For instance, no one at home knows how to use the computer and your office is locked when you are not at work and the computer is assigned for your use only.
Existing copyright procedures. How does the new law relate to the ability of individuals to record video and audio works for personal use?

I hope that you find these issues useful in the development of an article addressing the critical issues. As for me, I wonder why a nation with an increasingly permissive society supports the Gestapo-like tactics of the SPA. Because of my lack of understanding regarding the full implementation of the new and or existing laws and SPA's use of fear to motivate software users, I must request that you not print my name in your magazine.

OS Resource Management: Another Country Heard From

Dear DDJ,

I take issue with Andrew D. Todd's assertion that it is the role of the operating-system developer (OSD) to manage computer resources ("Letters," DDJ, February 1993). It is the role of the OSD to provide computer resources. Managing those resources should be the role of the application-program developer (APD), which implies that the APD be given the opportunity to manage them. When an OSD provides resources that it uses routinely in its own software products, but refuses to make available to the programming community at large, that is management of computer resources of a particularly invidious sort.

Furthermore, the whole point of Undocumented DOS (and, I assume, Undocumented Windows) is not that Microsoft should put more into DOS in order to reduce the workloads of APDs, but that DOS already has more in it than Microsoft is willing to divulge. The work of the authors of the Undocumented books, and the thousands of others who mine for hidden nuggets in the operating systems we've bought into, is based on the premise that everyone who owns a stake in the claim should start digging with the same-sized shovel, and have an equal chance at striking a rich vein.

Microsoft's claim that it doesn't document some features because it would then be committed to supporting them in the future rings a bit hollow. Many of the undocumented features exist in the first place because Microsoft needed to circumvent DOS's deficiencies in its own products to the same nightmare of incompatibility as everyone else's, besides making it impossible to do some of the things that users have come to expect of their software. The fait accompli with which Microsoft has been presented is entirely of its own making.

Is Microsoft, having been forced to document and maintain some of the features that developers (including myself) found indispensable, better off than it would be if it had presented those features in an orderly manner in the first place? Would Microsoft enjoy its present status among OS vendors, and would Bill Gates be one of the wealthiest men in America, if some of the first APDs hadn't found unmapped routes around the roadblocks that DOS erected and, as a consequence, made their products so useful that they sold in the hundreds of thousands? When we buy an operating system, do we buy the whole thing or just those parts of it that the OSD is sure won't allow us to create products that could conceivably compete with its own? If I don't have the right to use everything the OSD put into the product, where is my discount from the purchase price? Would you buy a car, Mr. Todd, if the manufacturer hid the fuel filter and then refused to tell you where it was?

Mr. Todd's proposal for dealing with undocumented features, if followed to its logical conclusion, presents a chilling prospect. In fact, part of it is already in place. A system of [leaks] "to the APDs of known probity" is not exactly a new idea, though it isn't always clear just how an APD's probity is assessed. The idea that "APDs may commission new features in the operating system," of which "interested parties" would then be notified, and for which they would presumably be billed, is a prescription for turning the dull headache of version incompatibilities into an epidemic of unimaginable virulence.

Finally, I would say to Mr. Todd that if he has ever written a DOS TSR that made more than trivial use of OS resources without resorting to undocumented features, he should write a book. It is sure to find a ready market among serious programmers, who aren't looking for thrills when they use undocumented features, but for ways to accomplish what would otherwise be impossible.

Richard Zigler

Marion, Michigan

Example 1

/* find_prev_wnd(): Find the main window of the previous
 * instance by searching all top-level windows
 */
HWND      prev_wnd;
FARPROC   find_prev_wndi;

BOOL CALLBACK _export  find_prev_wnd(HWND wnd, LPARAM lParam)
{
      /* Look for a top-level window having the same instance*/
      if (!GetParent(wnd)
          &&  GetWindowWord(wnd, GWW_HINSTANCE)== (HINSTANCE)lParam)
      {
          prev_wnd = wnd;
          return FALSE; /* Stop enumerating */
      }
      return TRUE; /* Continue enumerating */
}

/* Main application function */
int pascal
WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR pCmdLine, int Show)
{
      /* If there is a previous task instance, return to it */
      if  (hPrevInst)
      {
              find_prev_wndi =
                  MakeProcInstance((FARPROC)find_prev_wnd, instance);
              EnumWindows(find_prev_wndi, hPrevInst);
              FreeProcInstance(find_prev_wndi);
              /* Window not found error */
              if  (!prev_wnd)
                     return  0;  /* Fail silently */
              /* Return to the last active popup window, if any,
               * of the previous instance
               */
              prev_wnd = GetLastActivePopup(prev_wnd);
              /* if the existing window is minimized, restore it */
              ShowWindow(prev_wnd, SW_SHOWNORMAL);
              SetActiveWindow(prev_wnd);
              return 0;
        }
        . . .
} /* end WinMain() */

Copyright © 1993, Dr. Dobb's Journal