IPB_VM interface

Description

The IPB_VM interface loads PowerBuilder applications in third-party applications and interoperates with the PowerBuilder virtual machine (PBVM).

Methods

IPB_VM has two methods:

CreateSession

RunApplication

CreateSession

Description

Creates an IPB_Session object that can be used to call PowerBuilder functions.

Syntax

CreateSession(LPCTSTR applicationName, LPCTSTR* libraryList, pbuint numLibs, IPB_Session** session)

Argument

Description

applicationName

The name of the current application object in lowercase

libraryList

The library list of the PowerBuilder application that contains the objects and functions to be called

numLibs

The number of libraries in the library list

session

A pointer to IPB_Session*, which will return the current IPB_Session pointer after the call


Return value

PBXRESULT. PBX_OK for success.

Examples

This example creates an IPB_Session with the simple library list mydemo.pbl:

IPB_Session* session;
IPB_VM* vm = NULL;
fstream out; 
ifstream in;
PBXRESULT ret;

HINSTANCE hinst=LoadLibrary("pbvm.dll");
if ( hinst== NULL) return 0;

out<< "Loaded PowerBuilder VM successfully!"<<endl;

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

getvm(&vm);
if (vm == NULL) return 0;

static const char *liblist[] = 
{
"mydemo.pbl"
};

ret= vm->CreateSession("mydemo", liblist, 1, &session);
if (ret != PBX_OK) 
{
out << "Create session failed." << endl;
return 0;
}
out << "Create session succeeded!" <<endl;

See also

RunApplication

RunApplication

Description

Runs the specified application.

Syntax

RunApplication(LPCTSTR applicationName, LPCTSTR* libraryList, pbuint numLibs, LPCSTR commandLine, IPB_Session** session)

Argument

Description

applicationName

The name of the application object to be run, in lowercase

libraryList

The library list of the application

numLibs

The number of libraries in the library list

commandLine

Parameters to be passed to the application object

session

A pointer to IPB_Session*, which will return the current IPB_Session pointer after the call


Return value

PBXRESULT. PBX_OK for success.

Examples

This code fragment loads the PowerBuilder VM and runs an application called runapp that uses one library, runapp.pbd. It passes in a command line with two arguments:

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
LPCTSTR szHello = "Hello world";


// Provide command line parameters (employee ids)
// to be passed to the PowerBuilder application
LPCTSTR szcommandline = "102 110"; 

int wmId, wmEvent, ret;
PAINTSTRUCT ps;
HDC hdc;

switch (message) 
{
case WM_CREATE:
{
hPBVMInst = ::LoadLibrary("pbvm.dll");

P_PB_GetVM getvm = (P_PB_GetVM)
GetProcAddress(hPBVMInst,"PB_GetVM");

IPB_VM* vm = NULL;

getvm(&vm);

static const char *liblist [] =
{"runapp.pbd"};
vm->RunApplication("runapp", liblist, 1,
szcommandline, &session);
break;
}

See also

CreateSession