Code examples

Example 1:

For example, to load the runtime DLL file PBORC190.dll from where PowerBuilder IDE is installed, you write code differently between 2019 R3 and 2019 R2.

Also note that the file name PBORC190.dll in 2019 R2 has been changed to PBORC.dll in 2019 R3.

In version 2019 R2 In version 2019 R3
hORCALibrary = AfxLoadLibrary("PBORC190.dll"))
//First, define the AddEnvironmentPath method
BOOL AddEnvironmentPath(LPCTSTR lpAddPath)
{
   TCHAR szSysPath[1024 * 8] = { 0 };
   TCHAR szNewPath[1024 * 8] = { 0 };

   if(0 == GetEnvironmentVariable(_T("path"), szSysPath, 1024 * 8))
      return FALSE;

   _tcscpy_s(szNewPath, lpAddPath);
   _tcscat_s(szNewPath, _T(";"));
   _tcscat_s(szNewPath, szSysPath);

   if(0 == SetEnvironmentVariable(_T("path"), szNewPath))
      return FALSE;

   return TRUE;
}

//Add the path of runtime file before loading the runtime DLL
//The directory needs to be updated when PB is upgraded
AddEnvironmentPath(_T("C:\\Program Files (x86)\\Appeon\\Common\\PowerBuilder\\Runtime 19.2.0.2566"));
AddEnvironmentPath(_T("C:\\Program Files (x86)\\Appeon\\PowerBuilder 19.0\\IDE\\"));
(hORCALibrary = AfxLoadLibrary("PBORC.dll")

In summary, you need to write code in two steps in version 2019 R3:

Step 1: Define a method that can add a path to the PATH environment variable.

Step 2: Call the method to add the PowerBuilder Runtime and PowerBuilder IDE directories to the PATH environment variable and then load the DLL file.

Note that if the directory is hard-coded in the scripts, make sure to update the directory accordingly if PowerBuilder Runtime and IDE are upgraded to new version.

Example 2:

If you have source code like below which determines the PowerBuilder versions according to the class name, you will need to change the code accordingly.

Original code in 2019 R2:

Environment le_env

GetEnvironment(le_env)

// determine position of window within microhelp bar
ii_width = st_time.x + st_time.width + 25
this.width = ii_width

// set object class name
choose case le_env.PBMajorRevision
       case 10, 11, 12
              choose case le_env.PBMinorRevision
                     case 5
                           is_classname = "FNHELP" + &
                                  String(le_env.PBMajorRevision) + "5"
                     case 6
                           is_classname = "FNHELP" + &
                                  String(le_env.PBMajorRevision) + "6"
                     case else
                           is_classname = "FNHELP" + String(le_env.PBMajorRevision * 10)
              end choose
       case else
              is_classname = "FNHELP" + String(le_env.PBMajorRevision * 10)
end choose

// set parenthood
this.wf_setparent()

Modified code in 2019 R3:

choose case le_env.PBMajorRevision
         case 10, 11, 12
                   choose case le_env.PBMinorRevision
                            case 5
                                     is_classname = "FNHELP" + &
                                               String(le_env.PBMajorRevision) + "5"
                            case 6
                                     is_classname = "FNHELP" + &
                                               String(le_env.PBMajorRevision) + "6"
                            case else
                                     is_classname = "FNHELP" + String(le_env.PBMajorRevision * 10)
                   end choose
         case 17
                   is_classname = "FNHELP" + String(le_env.PBMajorRevision * 10)
         case 19
                   if le_env.PBMinorRevision > 1 then
                            // pb2019 R3 or later:
                            is_classname = "FNHELP"
                   else //pb2019 R2 or earlier:
                            is_classname = "FNHELP" + String(le_env.PBMajorRevision * 10)
                   end if
         case IS > 19
                            is_classname = "FNHELP"                 
end choose
Function long GetClassName ( &
       longptr hWnd, &
       Ref string lpClassName, &
       long nMaxCount &
       ) Library "user32.dll" Alias For "GetClassNameW"
public subroutine wf_setparent ()
String ls_name
LongPtr ll_hWnd
Integer li_rc

// find the microhelp handle
ll_hWnd = GetWindow(Handle(gw_frame), 5)
DO UNTIL ll_hWnd = 0
       ls_name = Space(25)
       li_rc = GetClassName(ll_hWnd, ls_name, Len(ls_name))
       If ls_name = is_classname Then
              ll_hWnd = SetParent(Handle(this), ll_hWnd)
              ll_hWnd = 0
       Else
              ll_hWnd = GetWindow(ll_hWnd, 2)
       End If
LOOP