CONSIDERING SOME ISSUES WHEN USING API CALLS

Before jumping into some examples, let's look at some of the issues of using API calls, such as what to keep in mind when creating your own API declarations from scratch, and what it takes to convert 16-bit API calls to 32-bit API calls.

Creating Your Own API Declarations from Scratch

Two words describe the situation when you find an obscure declaration, and there isn't a document declaration already built: Be careful! Although it's very rare that anything dangerous will happen, in some cases people have literally trashed their hard drives or reset CMOS by using API calls they weren't quite sure of. As mentioned earlier, one of the most common problems is that your system will GPF, and you could lose whatever changes you made to your code if you haven't saved recently.

It's always better if you can find routines that have sample code for them or get them from other developers.

Converting 16-Bit to 32-Bit API Calls

When moving into the Windows 95/98/NT world from Windows 3.x or Windows for Workgroups 3.1, you'll have to switch any 16-bit API calls to 32-bit. You need to remember a few things that will get you past most API conversions:

  • Start over from scratch. (Just kidding!)

  • The DLL names themselves have changed. Here's a list of known DLL name changes:

    16-Bit Name32-Bit Name(s)
    Kernel.dllKernel32.dll
    User.dllUser32.dll, Mpr.dll (network routines)
    Gdi.dllGdi32.dll

  • The names of the API routines have also changed. As mentioned earlier in the section “Examining the Syntax for API Calls,” the most notable change is the addition of the A to the end of the actual API routine. The A means that it's an ANSI version. The other letter used is W for Unicode.

Tip

Typically, if you get a Can't find routine message when switching to 32-bit, add a 32 to the end of the library called and an A to the actual name of the routine.


  • Some arguments and return data types have changed. The most common are those that were once Integer are now Long. This makes sense; because the operating system has switched from 16-bit to 32-bit, it requires the ability to return larger (32-bit) values.

That's about it for switching from 16-bit to 32-bit. You will have to go through and make these changes yourself. It will take some patience in converting your application, but it can be fairly painless.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.91.153