When using PowerBuilder 7.0 to develop users their own applications, you need to use some file formats or operation functions in the Windows operating system environment. If everything starts from the beginning, not only a lot of time and energy, but also completed features There is no improvement in Windows. How do I use a lot of applications and application development components in Windows? Windows provides two methods for application inheritance: DDE and OLE.
DDE (Dynamic Data Exchange) is a message-based protocol to exchange information between different applications. In Powerbuilder, not only a set of DDE functions for packaging Windows functions, but also an easy-to-implement interface.
The following is to call the Microsoft Word editing text file in the application developed under PowerBuilder7.0 as an example to show how to call the application in Windows:
Calling the Windows program in PowerBuilder 7.0 is called the Windows program equivalent to seeing Windows as a server, and the application developed under PowerBuilder 7.0 as a client, calling the server program in the client to use the RUN function. The syntax of this function is:
Run (string {, windowstate})
String is the application being called, which can also contain the parameters required to run in the called application; WindowState is an option, indicating the start of the application being called, and the value is: maximized! (Maximize) , Minimized! (Minimize) and NORMAL! (Normal).
Returns 1 if the function performs success, return -1, return -1, return NULL if the parameter is assigned to the function.
Use the OpenChannel function to establish a connection between two applications. The syntax of this function is:
OpenChannel (ApplName, TopicName {, WindowHandle})
Where applName represents the name of the application being called. TopicName indicates the subject name of the called application, as in Microsoft Word, you can take a value that has been opened. WindowHandle is an option, indicating the window handle of the called application.
If the function is executed, the handle of the established channel is returned, and the execution fails returns -1, and if the channel handle is NULL, then -9 is returned.
Here is the code that calls Microsoft Word. If you have Microsoft Word installed, you run Winword.exe, otherwise you run Notepad.exe:
INT VI_RTN
String VS_PROG, VS_PATH
/ / Get the installation path of Microsoft Word from the registry, save in VS_PATH
Registryget ("HKEY_LOCAL_MACHINE / SOFTWARE / Microsoft / Windows / CurrentVersion / App Paths / Winword.exe", "Path", RegString!, Vs_path)
/ / Judgment whether Microsoft Word is installed
IF vs_path <> "" "" "
// vs_prog Save WINWORD related parameters
// If the called application has a space between the parameters, the parameters, and application names
vs_prog = vs_path "winword.exe"
// Start WinWord
vi_rtn = run (vs_prog, normal!)
IF vi_rtn = -1 ThenMessageBox ("error", "unable to run the program!")
Return
Else
// Establish channel
OpenChannel ("WINWORD", "C: / my documents / example.doc")
END IF
Else
vs_prog = "c: /windows/notepad.exe"
vi_rtn = run (vs_prog, normal!)
IF vi_rtn = -1 THEN
MessageBox ("error", "Unable to run the program!")
Return
Else
OpenChannel ("NOTEPAD", "C: / My Documents / Example.txt")
END IF
END IF
It can be used in a similar method
Powerbuilder7.0
Developed users their own applications
Windows
A large number of applications contained in the system can greatly improve user development efficiency and enhance the performance of the developed application.