Results 1 to 12 of 12

Thread: [RESOLVED] API in VB.NET

  1. #1

    Thread Starter
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Resolved [RESOLVED] API in VB.NET

    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

  2. #2
    Special Guest - Microsoft
    Join Date
    Dec 2007
    Posts
    36

    Re: API in VB.NET

    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 Yuknewicz
    Lead Program Manager
    Microsoft Visual Basic
    http://msdn.com/vbasic

  3. #3

    Thread Starter
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: API in VB.NET

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

    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?

  4. #4

    Thread Starter
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: API in VB.NET

    Sorry the System.Security.Prinicpal library.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,296

    Re: API in VB.NET

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

  6. #6

    Thread Starter
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: API in VB.NET

    Quote Originally Posted by jmcilhinney
    By "API" I'm guessing Paul means the Windows API via PInvoke, yes?
    Yes

  7. #7
    Special Guest - Microsoft
    Join Date
    Dec 2007
    Posts
    1

    Re: API in VB.NET

    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.

  8. #8
    Frenzied Member
    Join Date
    Apr 2003
    Location
    The Future - Skynet
    Posts
    1,157

    Re: API in VB.NET

    It would be a wrapper and would add an extra layer that might be a bit slower.
    I'll Be Back!

    T-1000

    Microsoft .Net 2005
    Microsoft Visual Basic 6
    Prefer using API

  9. #9
    Special Guest - Microsoft funkyonex's Avatar
    Join Date
    Dec 2007
    Posts
    12

    Re: API in VB.NET

    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
    Beth Massi, Visual Studio Community
    Visit the Visual Basic Developer Center

  10. #10
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: API in VB.NET

    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.
    I don't live here any more.

  11. #11

    Thread Starter
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: API in VB.NET

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

  12. #12
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,296

    Re: [RESOLVED] API in VB.NET

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width