Top 5 Tips - Error Free Win32 API Access in .NET

I would like to share some of Tips which i come across...  Use .NET Framework data types whenever possible. This technique avoids conflicts with native language data types and makes the code more portable. In addition, some languages, such as Visual Basic, benefit from using the .NET Framework data types.


2.       Avoid excessive data-manipulation-oriented Win32 API code by using built-in .NET Framework functionality. For example, you can obtain the handle for the current object by using the this.Handle property.


3.       Windows provides a means for creating your own custom messages. Always use the _RegisterWindowMessage() function to register a unique name for your custom message.


4.       Make sure you understand the use of special-purpose messaging functions. For example, it’s essential to know the purpose of the PostThreadMessage() function if you want to manipulate threads directly.


5.       Use multiple overrides of the same Win32 API function to create certain effects. For example, if you want the ability to assign a null value to a structure, you need one version of the function call with the structure in place and a second version with an IntPtr substituted for the structure.


Happy Learning.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.