NET:LavishVMAPI.LavishVM.GetAPI

From Lavish Software Wiki
Revision as of 21:03, 2 December 2006 by Lax (talk | contribs)
(diff) ←Older revision | view current revision (diff) | Newer revision→ (diff)
Jump to navigation Jump to search

Overview

For use with bootstrapped API, retrieves the function pointer to an API function. The function pointer may then be marshaled into a delegate instance.

Reference Library

Lavish.InnerSpace.dll

Fully Qualified Name

LavishVMAPI.LavishVM.GetAPI

Declaration

static public IntPtr GetAPI(string Library, string Name, uint Version);

Parameters

  • string Library
Name of the registered library containing the API function
  • string Name
Name of the API function
  • uint Version
Version number of the API function

Return Value

  • IntPtr
Function pointer to the retrieved API, or int value 0 if the API could not be retrieved

Examples

C#

This is the stub used for InnerSpace.Echo, which retrieves the API and calls through if the function is available.
static public void Echo(string Output)
{
    IntPtr Address = LavishVM.GetAPI("Inner Space", "Echo", 1);
    if (Address.ToInt32() == 0)
    {
        Console.WriteLine(Output);
        return;
    }
    InnerSpace.Echo = (InnerSpaceAPI.Delegates.Echo)Marshal.GetDelegateForFunctionPointer(Address, typeof(InnerSpaceAPI.Delegates.Echo));
    InnerSpace.Echo(Output);
}

See Also