|
Carrying Out Commands in a Server Application
A Win32-based application can use the WM_DDE_EXECUTE message to cause a certain command or series of commands to be carried out in
another application. To do this, the client sends the server a WM_DDE_EXECUTE
message containing a handle to a command string, as shown in the following
example.
if (!(hCommand = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE,
sizeof(szCommandString) + 1)))
return;
if (!(lpCommand = GlobalLock(hCommand))) {
GlobalFree(hCommand);
return;
}
lstrcpy(lpCommand, szCommandString);
GlobalUnlock(hCommand);
if (!PostMessage(hwndServerDDE,
WM_DDE_EXECUTE,
(WPARAM) hwndClientDDE,
PackDDElParam(WM_DDE_EXECUTE, 0, (UINT) hCommand))) {
GlobalFree(hCommand);
FreeDDElParam(WM_DDE_EXECUTE, lParam);
}
In this example, the server attempts to carry out the specified command
string. If it succeeds, the server sends the client a positive WM_DDE_ACK message; otherwise, it sends a negative WM_DDE_ACK message. This WM_DDE_ACK
message reuses the hCommand handle passed in the original WM_DDE_EXECUTE message.
If the client's command execution string requests that the server terminate,
the server should respond by sending a positive WM_DDE_ACK message and then post
a WM_DDE_TERMINATE message before terminating. All other commands sent with a WM_DDE_EXECUTE
message should be executed synchronously; that is, the server should send a
WM_DDE_ACK message only after successfully completing the command.
Related Links
Software for Delphi and C++ Builder developers
Software for Visual Studio .NET developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET
More Online Helps
Win32 Multimedia Programmer's Reference (mmedia.hlp)
OLE Programmer's Reference (ole.hlp)
Microsoft Windows Pen API Programmer's Reference (penapi.hlp)
Microsoft Windows Sockets 2 Reference (sock2.hlp)
Microsoft Windows Telephony API (TAPI) Programmer's Reference (tapi.hlp)
Unix Manual Pages
|