Create an instance of the PowerBuilder object

After the session has been created, the C++ application can create PowerBuilder objects and call PowerBuilder functions in that session.

You use the FindGroup function to locate the group that contains the user object you want to use. FindGroup takes the name of the object as its first argument, and an enumerated type as its second argument. You are looking for a user object, so the second argument is pbgroup_userobject.

You pass the group returned from FindGroup to the FindClass function to get a class that you can pass to the NewObject function:

   // Create the PowerBuilder object contained 
   // in loadpbvm.pbl. 
   // First find the group that contains the 
   // user object nvo_mult
   pbgroup group = session->FindGroup("nvo_mult",
      pbgroup_userobject);
   if (group == NULL) return 0;
   
   // Now find the class nvo_mult in the group
   pbclass cls = session->FindClass(group,"nvo_mult");
   if (cls == NULL) return 0;
   
   // Create an instance of the PowerBuilder object
   pbobject pbobj = session->NewObject(cls);