Home > database >  How to call external EXE files in the original concept, how to write the file path? If the file path
How to call external EXE files in the original concept, how to write the file path? If the file path

Time:12-13

I want to call in the original program written in PB another EXE file, the EXE file saved in the form of a folder under the original program directory, how do I call? How to show ready to call the file path? Because the original program installation directory is not fixed, originally installed in C pan-gen directory, maybe next time someone to install would not be in this directory!

CodePudding user response:

Define the Global variables
String gs_apppath
Define the Global external functions provides
The FUNCTION ulong GetModuleFileName (ulong hModule, ref string lpFileName, ulong nSize) LIBRARY "kernel32. DLL" ALIAS FOR "GetModuleFileNameA
"
Create a global function gs_getapppath
String ls_dir
String ls_path
Ls_dir=Space (256)
GetModuleFileName (0, ls_dir, 256)
The Environment E_nv
Int li_PBversion
Int I
GetEnvironment (E_nv)
Li_PBversion=E_nv. PBMajorRevision
IF Pos (ls_dir, "pb80. Exe") & gt; 0 THEN//pb80. Exe refers to pb development tool exe file name
Ls_path=GetCurrentDirectory ()
The ELSE
For I=len (ls_dir) to step 1-1
If Mid (ls_dir, I, 1)='\' Then Exit
Next
Ls_path=Left (ls_dir, I - 1)
END the IF
Return ls_path + ""

In the event of an application of the open
Gs_apppath=gs_getapppath ()

Got your current executable file path, on a visit to the external exe was no problem, such as exe in the test folder, then path is gs_apppath + test \ ""

CodePudding user response:

Thank spring_cj, I'll be going to give it a try, don't know to ask you again! Thank you very much! I am a novice, the good will move! So quickly back to the post!

CodePudding user response:

The app open event program in the current directory saved to a global variable
Gs_path=GetCurrentDirectory ()

Such as the bb. Exe aa folder under the current directory, the path is
Gs_path + '/aa/bb. Exe' the

  • Related