dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB4/32,VB5,VB6
Expertise: Intermediate
Apr 20, 1999

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Never use the GetLastError API function

If you heavily use API calls and strictly follow the SDK documentation, you might be tempted to use the GetLastError API to retrieve the error returned by your last API function or procedure. However, this function doesn't always return valid error codes, because Visual Basic internally does a lot of calls to the Windows API, therefore it is highly likely that the value returned by the GetLastError function actually refers to one of those internal calls, rather than your most recent explicit call.

To work around this problem, just use the LastDLLError property of the Err object. Visual Basic always caches in this property the error code returned by any call to a routine to the Windows API. Unfortunately, you cannot disable this mechanism, which means that all your calls to the API are slowed down, even if you're not interested in error codes.

Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date