PB_GetVM

PowerBuilder Native Interface

Method exported by PowerBuilder VM:

PB_GetVM method

Description

Passes the IPB_VM interface to the user.

Syntax

PB_GetVM (IPB_VM** vm)

Examples

This example loads the PowerBuilder VM and calls the f_getrowcount function on the nvo_dw custom class user object:

#include <pbext.h>
#include <iostream.h>
typedef PBXEXPORT PBXRESULT (*P_PB_GetVM)(IPB_VM** vm);

class LibraryLoader
{
public:
  LibraryLoader(LPCSTR libname)
  {
    d_hinst = LoadLibrary(libname);
  }

  ~LibraryLoader()
  {
    FreeLibrary(d_hinst);
  }

  operator HINSTANCE()
  {
    return d_hinst;
  }

private:
  HINSTANCE d_hinst;
};

int main()
{
  int int_rowcount;
  PBXRESULT ret;
  LibraryLoader loader("pbvm125.dll");
  if ((HINSTANCE)loader == NULL) return 0;

  P_PB_GetVM getvm = (P_PB_GetVM)
    GetProcAddress((HINSTANCE)loader, "PB_GetVM");
  if (getvm == NULL) return 0;

  IPB_VM* vm = NULL;
  getvm(&vm);
  if (vm == NULL) return 0;
  
  static const char *liblist[] =
  {
    "load_pbvm.pbl"
  };

  IPB_Session* session = NULL;
  ret = vm->CreateSession
    ("load_pbvm", liblist, 1, &session);
  if (ret!= PBX_OK)
    {
    cout << " Create session failure!" << endl;
    return 0;
  }
  return 1;
}

Usage

To load the PowerBuilder VM and run a PowerBuilder application in a third–party server or application, you first create an IPB_VM object using the PB_GetVM method. Then, create an IPB_Session object within IPB_VM, using the application's name and library list as arguments.

See Also