1. Rajkumar K S
  2. PowerBuilder
  3. Friday, 12 April 2024 11:14 AM UTC

Hi Team,

Recently we have moving our PB application to powerclient. In our application we will be calling some other PB application exe's in other application menus. We just wanted to know file path of the exe clicking in the menu. We need the exe corresponding file path then only we can call the exe with the filepath without any issues in powerclient application.

 

Thanks 

Rajkumar

Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Friday, 12 April 2024 23:45 PM UTC
  2. PowerBuilder
  3. # 1

Just use OpenURL() and have it open the URL of the other PowerClient app you want to open.  It is not good idea to go based on hard drive location for the .exe.  The location could possibly changed, and also there is no guarantee the .exe you want to launch exists. Referencing the URL rather than the .exe is the right way to do this in my opinion.

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Friday, 12 April 2024 15:40 PM UTC
  2. PowerBuilder
  3. # 2

Hi, Rajkumar -

I'm not entirely sure I understand what you are asking for, but if you want the path/name of the executing PB application, you can obtain it at runtime via a Windows API function. Here is the external function declaration:

FUNCTION UnsignedLong GetModuleFileNameW ( &
   Longptr      lhModule, &
   REF String   sFileName, &
   UnsignedLong nSize &
   ) LIBRARY "kernel32.dll"

Tip: Save after adding the external function declaration, then add the code that calls it, otherwise the compiler will not see/find it.

Here is an example of how the API function can be called:

ULong   lul_rc, lul_size
Longptr lp_hmodule
String  ls_module_name

// Module handle = 0 means Windows will use the handle of executing module in the current process.
lp_hmodule = 0

// The size of the pre-allocated buffer, in Unicode characters.
lul_size   = 300

// To call from PB, PB must pre-allocate the string that will be assigned the executing file path/name.
ls_module_name = Space(lul_size)

lul_rc = GetModuleFileNameW(lp_hmodule,ls_module_name,lul_size)

If lul_rc > 0 Then
   // The return code is the length of the string returned by Windows in characters.
   MessageBox("Module Name",ls_module_name)
Else
   // A return code of zero means API function failed.
   MessageBox("Module Name","The path/name of the module cannot be determined.")
End If

When running from within the PB IDE, the path/name of the executing module will be the PB virtual machine (PBnnn.exe). When compiled/deployed, the string returned will contain the path/name where the application's exe is running from.

Best regards, John

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.