# Visual Basic > Slow Chat with the Microsoft Visual Basic team >  [RESOLVED] API in VB.NET

## Paul M

Hi MSVB Team i was just wondering what you all thought about the use of API in almost any .NET language but VB.NET more specifically. I find that a lot of stuff can be done with the .NET library instead of using API, is it generally best to use the .NET libraries when it is applicable to do so?

           Thanks Paul M

----------


## PaulYuk_MS

Hi - could you please clarify what you mean by API vs. .NET library (using some examples)?  Are you specifically refering to API features in the VB runtime like MsgBox(), CInt, Left(), etc?

----------


## Paul M

Sorry about that i was in a rush to get to work  :Smilie: 

Anyway i mean like in general would it be better especially performance wise to use the appropriate .NET library over API?

For example checking if a user has administrator privileges, would it be better to use the System.Principal library or to use API directly to determine this?

Sorry it is a very broad question but would you suggest using the .NET libraries over API when it is possible to do so?

----------


## Paul M

Sorry the _System.Security.Prinicpal_ library.

----------


## jmcilhinney

By "API" I'm guessing Paul means the Windows API via PInvoke, yes?

----------


## Paul M

> By "API" I'm guessing Paul means the Windows API via PInvoke, yes?


Yes  :Smilie:

----------


## jaredp110680

In general if the API is available via .Net I would choose that over a PInvoke version.  PInvoke is complex and has a lot of dark corners.  When a .Net wrapper is produced that exposes these API's, generally the author has done the work to get it right and it should be easier to consume.

----------


## Liquid Metal

It would be a wrapper and would add an extra layer that might be a bit slower.

----------


## funkyonex

In general I always prefer the .NET managed libraries over the Windows API. They are usually much cleaner, easier to use and faster to program. Only when they do not provide the functionality I need then I drop down to call the API directly. In the types of .NET applications I have built over the years (information systems) I have never noticed a performance penalty for using managed wrappers. My performance concerns lay elsewhere -- like database query times and network serialization ;-). It all depends on the types of applications you are writing. 

HTH,
-B

----------


## wossname

Every Operating System API call you use binds you to that particular OS more tightly.  That is pretty much the reverse of what .net is all about - cross platform working.

----------


## Paul M

Thanks guys, i always use the .NET libraries over API and sounds like i will continue  :Big Grin:

----------


## jmcilhinney

The entire .NET Framework library is really just a wrapper.  If you're not going to use it all the time you can then why use it at all?  Assume that you should always use a managed type and/or member if one is available unless you have a specific reason for doing otherwise.

----------

