Diferences between a Lib and a Wraper...

Discussion in 'Questions (Windows Mobile)' started by Cableguy, Aug 25, 2007.

  1. Cableguy

    Cableguy Expert Licensed User

    Hi guys...

    whats the diference?

    a Librarie calls methos and prperties from an suposed already availabe "Component", in the lack of a better word....and a wrapper calls an otherwise, not available one?
    Even if it was there?

    So code wise, whats the diference? what are the steps?
     
  2. agraham

    agraham Expert Licensed User

    They are terms of convenience, describing the intended function, as both are in fact libraries.

    Library - a set of pre-compiled code callable by an application at runtime and, under Windows, normally contained in a DLL (dynamic link library)

    Wrapper - a library whose intended function is to interface another library that is not directly callable by an application. i.e. the application calls the wrapper and the wrapper calls the incompatible library and returns the result to the app. For example B4PPC cannot call the native Windows Win32 API functions but the full .NET framework can so a wrapper library can be written in a .NET language that is callable by B4PPC and in turn calls the required Win32 API. The Scroll Bar component DLL is effectively a wrapper to the native .NET framework Scroll Bar control as B4PPC cannot instantiate .NET controls directly.

    Note that a native code DLL and a .NET DLL are fundamentally different though both confusingly share a common file extension.
     
    Last edited: Aug 25, 2007
  3. Cableguy

    Cableguy Expert Licensed User

    so in order to use the dll i whant to call, i add it using the "using" statement?

    How do call the properties and methods?
     
  4. agraham

    agraham Expert Licensed User

    Not enough info I'm afraid Cableguy. Tell me a bit more about what you are trying to do
     
  5. Cableguy

    Cableguy Expert Licensed User

    I found a couple of components (dll's) wich would be of great use to us all:

    a pdf creator component
    an excel reader/writer component

    Both free, but needing a wrapper...So instead of waiting on Erel's Time and availability, I was wondering if I was up to the challange...

    See my wishlist post...
     
  6. agraham

    agraham Expert Licensed User

    If you have .NET Reflector then download Erel's Hekkus wrapper here and look at hssNETDesktop.dll which is a wrapper to hssDesktop.d which is actually a native code dll with a renamed extension.

    http://www.basic4ppc.com/forum/showthread.php?t=693

    It defines six classes, each with the mandatory constructor, that enables B4PPC to create an instance of each class. The classes in turn call the native code dll using [dllImport] (C#) or <dllImport> (VB) to access the unmanaged code.

    "Using" (VB) or "Imports" (C#) only work for shortcutting namespace references in .NET dlls and are a convenience, not a necessity. You can call into .NET dlls without "Using" or "Imports" as long as the project has a reference to the dll and you use fully qualified class names.
     
  7. Cableguy

    Cableguy Expert Licensed User

    Thanks Agraham..

    I do have reflector and also AUtoDiagramar, wich, oif you dont know, is a sort of companion for reflector, wich show the class diagram and interoperations, data flow, etc...

    I wil spend some time loking into this, as there are so many interesting features wich basic4ppc cam be made much powerfull, at least to the desktop...
     
  8. agraham

    agraham Expert Licensed User

    For completeness I should also point out that you may find another type of DLL that contains COM/ActiveX code. Unlike a plain unmanaged C/C++ DLL these are more complex beasts and must be registered in the Windows Registry. To use these under .NET you can't use dllImport but need a .NET Interop Assembly. I don't know about SharpDevelop (which I think you are using) but Visual Studio 2005 automates a lot of the (quite complex) work involved. When you add a reference to a project VS will show you all the registered COM types and will build the required interface automatically for simple acess to a COM dll. More sophisticated access will need additional programmer intervention.
     
Loading...