PB_GetVM

PowerBuilder Native Interface

Method exported by PowerBuilder VM:

PB_GetVM method

Description

Syntax

PB_GetVM (IPB_VM** vm)

Examples

#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("pbvm170.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

See Also