January 26, 2021
Hot Topics:

Visual Basic 6 Win32 API Tutorial

  • By James Limm
  • Send Email »
  • More Articles »

Let's try to sum up all of the issues we've addressed so far in this chapter concerning API calls:

  • Save your work often
  • Always pass strings ByVal
  • Be very careful when using the Any keyword
  • Pass in the first element when using arrays as buffers
  • Make sure your UDTs map to what the DLL is expecting
  • Never tell a DLL that you've allocated more space than you really have
  • Don't embed null characters in strings if an API call needs it
  • Save your work often
  • And…save your work often

You're bound to run into other subtle "features" when you use the Win32 API. In a way, the Win32 APIs remind me of the English language; it does have structure, but there are a lot of exceptions to the rules. But as long as you try to find out as much as you can about what's going on underneath the scenes, you should be able to solve any problem.

And yes, I did mention the save edict three times. NEVER run your code without saving it first, and I mean NEVER. You're throwing the safety net away when you tear into the Win32 APIs, so save your work before you try to run your code. A crash may shut down VB or even Windows itself, but if your code was saved, you can always go back and figure out what went wrong after the OS reboots

Page 10 of 13

This article was originally published on November 20, 2002

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date