This method is exported by the PowerBuilder VM:
Passes the IPB_VM interface to the user.
PB_GetVM (IPB_VM** vm)
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("pbvm105.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;
}
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.