CreateSession

PowerBuilder Native Interface

IPB_VM interface:

CreateSession method

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 Values

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("pbvm125.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