Concept and technology of Win32 itinerary

zhaozj2021-02-17  62

The concept of Win32 itinerary and the technical window will always be just partial landscape. As the manufacturer of the window, we can't understand this truth; for the use of the window of the window, the manufacturer of the window can provide not only the size of the window, but is often the number of the window. Indeed, explore the window to see more, the outer sky is wide, and other windows may have the scenery we want.

This article talks about Interprocess Communication (IPC), I will share the technical and data exchange between cross-travel communication.

Why do IPC? Why do I need Inter-Process Communication?

Obviously, there is no window application to hold all work. In order to avoid the amount of time waste of the data overcome input and the human error, the data between each app will have exchanged needs. The first pressure will come from users, even probably yourself. Don't say anything else, when you write this article, I have clipped to the prior written by Delphi to the instrument editing software. At the same time, I also use the graphic software to help me take the picture, and finally, these articles and models have been Press the compression program and then E-mail sent to the magazine editor.

Using IPC In some cases, it is necessary to decide, sometimes the program must cross the machine boundary to make a work in another machine to work together, but also suggest that we may face different operating systems. problem.

In addition, IPC helps system security and stability. Since the Win32's individual strokes are independent, a trip is dead, and other itinens can continue to run, and for some systems with high stability requirements, it is worthy of overhead exchange system. Robustness. Well! I mean, because the system has a higher demand for stability, it is worth noting to do even additional backup systems, since the work is removed more than two, at this time, IPC will ignite.

Regarding IPC, the average person may have the impression of "slow efficiency", which certain can't be said to be wrong, but it is not a fair review. So, a supervisor personally do something, it is often better than the first place, it is a single job; however, if the manager has several things in the hand, please pay someone else Being able to improve the performance of the entire company. In other words, if you can make good use of IPC, the overall system effect will not decrease, but may be improved because of the ability to make full use of the entire arithmetic group.

Our first IPC example each graphic interface window application accepts and handles the message (Message), so use the message 伫 伫 伫 通 通 行 想 想 想 想 想 想 想 想 想 想 想 想 想;; 想;;;;;;;;;;;;;;;; 想 想;;;;;;; 想 想 想;;; 想;; 想; 想;;;;;; 想; The two lines interverses each other to send a message to each other by send Message () or postMessage ().

Often to send messages to each other, you need a message number that is considered to each other. So, in addition to the Windows standard message number, we also need to define an additional (some) messages.

The method of trip communication is used to redeemed the message number is the call registerWindowMessage () API function. This function has only one string-based quota, and the Windows system checks the name of the message we paste and returns a safe and unusable message number. If the incoming message name has been registered, the system is back. It is the same number of the trip earlier.

In other words, the two projects use the same message name called the registration message with the same message name, and the system will give both the same subscription message number.

Let's take a message, but who is going to give? Well, the method I used here is: I first use the broadcast. Each window will receive a notification, the short number of the message written in the short number of the newsletter, if it is a comrade, it Nature understands what is represented by this message and also uses the message to send the message to receive the message. Similarly, the short number of messages indicates your own handle. So, the young two of the vast people finally learned the whereabouts of the other party, and no longer need to be publicly traced to contact the other party through the handle value. In addition to the message number, the WPARAM of the message, the LParam length can also be used to further agree to the details of communication. The progress seems to be very smooth, and now we know the cooperation object, and it is also aware of what our message represents. Although it is simple, this way of this passing song is the system acquiescence. However, we still need to solve a problem more.

Since SendMessage is only WPARAM, LPARAM two DWORD types, the amount of data is carried is very limited. Obviously, we need to be able to deliver more information. Windows also provides many mechanisms for exchange information, I will explain one by one in this article, the easiest way is to use the WM_CopyData message, the data is as follows

Specify the information content to the information structure of the CopyDataStruct. You must use SendMessage () to send a WM_COPYDATA message, the short number of messages is the handle value of the newspaper window, and the content of the number is the indicator of CopyDataStruct. When the sub-trip is received, the information provided by the long number is retrieved. The system is a hidden red lady when the number of two-way correspondence is round-trip. Just send the WM_COPYDATA message in the newsletter, and the system is acquired between the information, the system is silently taken away from memory management. For the use of WM_COPYDATA, you need to remind the reader, the receipt should be readily read, if the postpartum processing needs these information, you should copy it first.

Thanks to this special nature, the WM_COPYDATA and the message communication model becomes a small number of IPC mechanisms that support 16-Bit and 32-bit applications on the Win32 platform. You can find the full original program of the paradigm TWINAPP in the WM_COPYDATA directory.

In summary of IPC basic concepts, the above examples are two strokes to use registerWindowMessage () number to send messages, and use the message's length of the number to further agree to the content and details of communication, and the amount of data is relatively large The information uses WM_CopyData.

The readers of the eye may be aware of some DDE shadows when reviewing Twinapp. Of course, compared to DDE, the TWINAPP version of the message is really spring, and there is a lot of shortcomings. However, my intention is not to write a large-scale program to scare people at the beginning; the opposite, I plan to provide a simple example, and borrow several important concepts and features of the stroke communication, these features It is not unique to Twinapp, and the discussion of other IPC mechanisms also has the same value, and we have fasten the feeling of IPC, and then discuss the IPC mechanism supported by other Win32 platforms.

The words of the inner lines are lively. Maybe I can't think of the top masters, but at least we should see something more than watching!: P observed this example of twinApp -

There is only a common communication agreement between the itinerary. The IPC that is discussed later is some of the IPCs that can be across the machine boundaries or even the domain. Process players in the stroke communication, the trip to IPC can It is classified into a CLIENT and Server. The so-called server refers to the provision of services; the client refers to the use or to Server requires the service. In the real world, the human role play is coming. We will be some of the children of others, but it is also a parents of others; even if they are also a couple, the performance of home life and outbound behavior is different. Defining a certain process is the case where the client and the role end of the Server is not absolute. For example, the instrument processing software may require the statistics to the coupum of the trial table. At this time, the trial table plays the role of the Server, but the coupon is written in the trial of the statement of the stock management system, the coupling table is Client. .

In our first example twinApp, do both a message and a message is actively issued. It can also be a client or a server, no obvious masteric side, for this case, there is a proprietary noun called "Peer-to-Peer Model).

Synchronous and non-synchronized discussion Twinapp Use SendMessage () to send a message, the program will pause in the SendMessage (), the line waiting for the message processing to return, then continue the next list, this is synchronous processing. Synchronous (Asynchronous) and Nonnchronous are a very important topic in IPC, it is necessary to first explain these two nouns first:

When the program A call program b, if a first pauses, I will wait until the program B ends back, then the next action of the program A, we call it as synchronous; another situation is - if a call B, If the B is executed, the next action of A will be performed directly, it is a so-called different steps.

Take a bill of money as an example, we will first insert the card, enter your password, type the amount, then the internal security and account check, finally recover the card and amount, the print transaction is detailed, one moves to step by step; This matter, a boss can pay a spending of the accountant to bring money, after the replacement, he will go to the busy things, wait until the accounting, return to the boss, this program is called non-synchronization.

If you further observe the following example: When is the accountant, when will the accountant go back? If this boss is not allowed outside the accounting Miss, there is another work of others, which can be foreseen, not necessarily the work. I finished first. Due to the order of execution, it is impossible to estimate, the stroke communication designed by non-synchronous mode will be many coordination and event processing, so that each other is always looking for something.

The number of strokes and communication, the flow of message information is in TWINAPP, and there is only two endpoints. But in the actual application, Server usually has to pay a few client requirements, how to properly take care of every Client should also take care of the effectiveness of the system, which is a big knowledge.

When the itinerary rides a communication with the trip, this 挢 is a single-way or two-way traffic, and it is also worth listed in the assessment element. However, it is necessary to pay attention to: Whether choosing a single work or duplex IPC mechanism, does not constitute a two-way communication, there is no across, and the mountain does not turn the way, and the two unidirectional 挢 can have two-way traffic. The effects, but for the congenital essential characteristics, some IPC mechanisms are indeed easier to make a duplex effect, and of course, there is also a natural big mouth suitable for broadcast, such as Mailslot, which is described later.

The information on the visibility and security exchange of information must of course be visible between the itinerary, twinApp is the information on WM_COPYDATA. IPC Some technologies can make the itinerary to access information, and we will have discussions when Shared Memory. Do you need to have a window or a pure Console Application can also be applied .twinapp is a message to send a message in SendMESASAGE (), which means there is a window Take it. If you design the application of pure Console Mode, then the IPC mechanism (for example, PIPE) that does not require Windows Handle is also suitable.

About the performance of performance, many people caught IPC's implementation efficiency, indeed, don't say anything else, start another process itself is much higher than starting a Thread's overhead. If there is a coordinated problem, the time to build a MUTEX is also a few times more than if critical section is slow. Unfortunately, we don't choose, because critical section is simple and easy to use in Multi-Thread, but cannot be used in applications across the stroke boundary. However, IPC must make the system performance, and it is too pessimistic; the view of the flat and draft is different. In this year, everyone hangs Client / Server in their mouths and fully uses reasonable allocation of the entire company's operational resources to improve the overall performance. I think IPC has its own value and benefits.

Another kind of fierce design that caused IPC execution efficiency comes from bad design, the famous example is the so-called busy-loop, and there is only one line of returning round. Take a few early boss and accounting as an example, if the boss will stop all things, it will go back and forth to wait for the accounting Miss, and there is no time to spend on the knife. The result is not good. Finding the efficiency bottleneck to try to adjust the work for long-term fighting, as management is continuously rationalization.

There is also a forth here to be clarified, synchronous and non-synchronous effects on performing performance is dependent, and it is not possible to say that non-synchronization will be fast than synchronization, and the sample sample is small or the amount of data is small. Synchronize It is often fast than simultaneous. The comparative method should be: When there are several works to be handled, "non-synchronization" is often too fast. Taking the books just now takes the matter, the boss personally going to withdraw money is not slower than the lady, but if the boss has several work to be handled, the non-synchronous benefits are obvious.

The discussion of the IPC related technologies supported by Win32 supported the observation of Twinapp, but it is better to say a comprehensive discussion of IPC. After the instructions, it is the discussion of the technical level. The next example is the IPC mechanism for Win32 API support -

CLIPBOARD COM DYNAMIC DATA Exchange (DDE) File Mapping Mailslots Pipes RPC Windows Sockets WM_COPYDATA Scrapbook (CLIPBOARD) People are actually the best IPC mechanism, very clever and very flexible.

The scrapbook is almost specially designed for humans. Its maximum feature is in addition to the user's orientation, all of which allows you to rewrite its content, and it can span the machine boundaries, the range of exchanges is not limited to the various strokes in the stand.

Since it is a pure user orientation, there is a tradition of using the scrapbook to be compliant: There are our programmed materials in the book, even if they are just put in, because users may have cleared or changing their content.

The scrapbook can accommodate any information, in addition to the standard supported CF_Text, CF_bitmap ... and other materials format, we can register your own information on your own format. However, due to its user-oriented, it can also be rewritten due to any program unless the user is willing, otherwise it is not suitable for information exchange between the itinerary. This also makes the IPC mechanism for each application to support each application when designing IPC, but also an IPC mechanism that is also suitable. We should look at other information exchange methods. File Mapping In the early MS-DOS era, there are still so many IPC mechanisms now available, using the disk file to exchange information can be said to be the only choice for general application. Today, the files not only have disappeared from the IPC field, but they are more carry forward, but they have long been unprofitted in the archive system entity file. Indeed, it is now getting more blurred now, and the virtual memory is actually a file. The virtual archive result is a memory.

There is a fun thing in Win32 API called file-maping; basic concept is to open a file and will be able to entertaire, interesting, although the program is aimed at this memory operation, it actually changes It is a file. More fun is that you don't have to really open an entity file in your hard disk, but use a piece of space for page file to act as a file. This virtual file space (or you want to say is a memory) can be shared between the itinerary, usually we take a special name called Share-Memory, sharing a memory.

Since it is indeed not a real file, there is not only a specific disk catalog file, but also not need to care for the last thing to be responsible for deleting the file, of course, even if it doesn't leave some spam. Sharing with each other is exactly the same memory. Once the information is written, this change is immediately reacted to other itinerary.

The approximate steps using ShareMemory are as follows

Call createFilemapping () API function creates file-maping core object. The first quotient of the createFileMapping () function should be the archive object Handle of the CreateFile (), if it is incoming $ fffffff, the transfer file (PAGING FILE A shared memory. The last quoter of the function is the name of the area of ​​this area, and each other will be used to share the memory according to this same identification name according to this.

FHANDE: = CREATEFILEMAPPING ($ ffffffff, // shared memory file, handle passed the $ ffffffff nil, // does not set the security property Page_readwrite, // Access mode setting to readable write to travel exchange data 0, // Use Page File is usually set to zero size, // Shared memory size PCHAR (NAME)); // Other itinerary will use this name to this shared memory

Since each stroke each has its logical address space, we have to map all or partially map the location space of the travel itself before formally accessing the shared memory. The use of call mappviewoffile () is here, which will return to the Mapped View "View" start (indicator), the next thing is to access the memory with this indicator. FFileView: = MapViewoffile (FHANDLE, / / ​​File-Mapping Object) Handle Value File_map_all_access, // Set to file_map_all_access open access 0, // mode to smooth access to shared memory 0, size); // Prepare to map back BYTE number

Finally, don't forget to use unmapViewoffile () to return the indicator and call CloseHandle () to release the file-mapping core object. Based on the post, the complete program, please read the reader to read the DemosMemSmem project of the Sharemem directory. In addition, for convenience, these createFileMapping (), MapViewOffile () functions have been packaged into the TsharedMem category. Mutex Shared Memory demonstration Demosmem left a lot of suspenses, perhaps you have the same question: Since the two trips use this memory, how do we know when the data changes? In addition, how to prevent it from reading and write information at the same time?

Indeed, the stroke communication is both an individual, coordination is an inevitable burden, to avoid two trips to use key resources at the same time, Mutex's use is your necessary technology.

From the literal explanation, mutually exclusive is the only time; in other words, only the maximum of Mutex is right in the same time (thread) is entitled to use key resources, and other execution is to use only wait. Well! I will temporarily change the port in the two sections of Mutex and Event. In fact, this is the real CPU schedule. Since there is at least a Thread (main execution in the 主), such a name should be in this article. The main purpose of the stroke communication is not contrary.

Just like a registration message, sharing memory is the same (or even later Event, Mailslot, Pipes), before we get the Handle of the core object, it is the "name", which produces a MUTEX API function. : Createmutex (), the following example is taken from the CHIENIPC program unit attached to this article

Constructor TMUTEX.CREATE (Const Name: String); Begin Fhandle: = CREATEMUTEX (NIL, // Security Properties, Temporarily Infinite NIL Adopt Preset Value False, // Doing the Ownership PCHAR with MUTEX ( Name)); // mutex core object name IF fhandle = 0.

It's so good, now we have a MUTEX, what should I use? I use a plot to explain: If a group of people meet together, each person has a microphone in front of the table, in order to let everyone say what to say, what to say, These microphones are temporarily closed, and there is only the Chairman to open the circuit through the central control system. The leader to speak, "I want me to want me", if there is no one else to raise your hand, no one is speaking, the Chair opens the switch to him, then the person's hand puts down the speech. At this time, if other people must speak, according to the rules, they will raise their hands, and only those who continue to raise their hands before the speech is handed over. Of course, those who are queuing can choose from hand; or he only plan to wait for three minutes, and the hand is sour.

Performing a smoke requires Mutex's way is to call WaitForsingleObject () (I want me to, raise your hand), which will be paused in this column. If there is nothing else to have Mutex (no one speech) at this time, the system will be short-lived to Signaled (), so that WaitForsingleObject () is returned, and the system will also hand over this MUTEX ownership. This execution, then proceeds to execute, hold the Mutex owner to start using critical resources, and then add the MUTEX ownership with ReleaseMutex () as soon as possible.

About the entry into this section, please read the Demosmem paradigm read and write program, the same, about the Mutex's API function has also been packaged into the TMUTEX category to facilitate your use. Event discussed with Mutex coordination and avoiding techniques between the trip, Shared Memory's demonstration project Demosmem still left a suspense to solve: Since the two trips use this memory, how do we know when the information is changed? • Taking a round loop regularly to grasp the information back and compared to not only writing, the implementation efficiency is also very low.

Of course, returning to the beginning of the method, writing information is used to use information, one, notifying other partners, but it is possible to have a better solution. There is an EVENT object in the core object of Win32, which makes it easy for us to set its status when an event occurs so that the trip to communicate should pay attention to the occurrence of an important thing.

The method of generating an EVENT object is to call the createEvent () API function:

HANDLE CreateEvent (LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, // flag for manual-reset event BOOL bInitialState, // flag for initial state LPCTSTR lpName // address of event-object name);

Similarly, the last quoter is to perform the identification name of the same EVENT object before obtaining Event Handle, if the EVENT object of the same name has been generated earlier, and the number of times is not returned to zero, and there will be no more EVENT object The system is only added to the number of times the number of times, and the improper is performed to the same object. The third quota is used to set whether the initial value of the EVENT object is Signaled. The second quoter is used to set the excitation state of the event is manual or automatically; the so-called manual and automatic respective respectively When the event is changed to the signal, it is necessary to automatically reset the non-excited state by the system, or It is set to resetEvent () by the program.

Observing DemosMem is this: When a stroke modifies the content of Shared Memory, the stroke sets the state of the EVENT () API function to Signaled (excitation state), and the stroke communication is in the SIGNALED. At the beginning of the start, in addition to establishing the same identification name () EVENT object, another THREAD dedicated to detect the task of stimulating a specific EVENT object, once the object is excited, indicating a certain stroke modification SHARED MEMORY information, at this time we know that it is time to reread the content.

Call! Finally, the model of Shared Memory is finished. The picture below is the picture it executes. It seems that it seems that there is no relationship, but through the co-sharing memory and Mutex, Event two synchronous coordination technology, close to each other is close Exchange opinion.

Figure: Demosmem execution situation

When Mailslot is executed, if you make the feeling of broadcasting, you will make you more radio feelings, and it can be broadcast to the Internet across the machine boundary. From the literal view, this is like a communication mechanism related to the sender, and it is actually in line with its name. Mailslot is like your mailbox, just know the address, anyone can send you a letter, but only if you can open the letter of the letter.

Mailslot is a virtual file maintained by the system, which is built and has Mailslot's stroke. The role of Server. The other itinerary contains the stroke of the MailSlot Server itself. You can turn on Mailslot to write messages, but only Mailslot Server can read information. content. This is a single SERVER multiple client mechanisms, while the information is only allowed by the client to transmit by client. I think you may get used to it, you have to produce a mailslot item probably need a recognition name!: P. Regardless of the CreateMailSlot () function name, you can guess the word. However, this time, you can take anything as before, it can be taking anything, it has the following fixed format:

// servername / mailslot / [pat] name

I first saw it when I saw: God! How can I fill this? The side of the example will be easier to understand.

//mailslot/mymailslotname mailslot's identification name must start from "//" double-inverted slash. The next thing is the name of the machine or the name of the group domain. The "." The junction is the machine where the itinerary is located. Come back "/ mailslot", for Mailslot, must be this single-word photo. The last is your own mailslot name. Previous mentioned that Mailslot is actually a special virtual file, so when it is a file, it should be said.

Indeed, quoting the concept of the archive system, the name of the Mailslot is like a path file name, and can be classified by appropriate class, for example: //./mailslot/account/note. Finally, look at an example: // * / mailslot / mymailslotname, "*" refers to all machines in the group.

It's much enough, let's do it! First, it is an example of establishing Mailslot Server, and takes the CHIENIPC of this article.

procedure TMailSlotServer.Open; var ASlotName: AnsiString; begin if FActive then Exit; // Mailslot configuration identification name ASlotName: = '//' FServerName '/ mailslot /' FSlotName; FHandle: = CreateMailslot (pchar (ASlotName), //Mailslot identifier name 0, // message length maximum, set to zero means not limited mailslot_wait_forever, // read time-out nil); // security attribute, temporarily adopt preset value if fhandle = invalid_handle_value the Factive: = False else begin fact: = true; fwaitthread.resume; end;

Again once, only MailSlolt Server can read the information, the method read is the first to detect the length and quantity of the message with getMailslotinfo (), then configure the memory one by one by one, readfile (not forget) Milslot is also a file), the following is an example:

procedure TMailSlotServer.ReadFromMailSlot; var NextSize: DWORD; MessageCount: DWORD; Result: BOOL; Buffer: pchar; begin if FHandle = INVALID_HANDLE_VALUE then Exit; // detect whether there is information in the Result MailSlot: = GetMailslotInfo (Fhandle, nil, NextSize, @MESSAGECUNT, NIL); if not result or (nextsize = mailslot_no_message) THEN EXIT; // If there is information (MessageCount <> 0), read the information one-by-case result and (MessageCount <> 0) do begin // information length Buffer: = AllocMem (NextSize 1); try // read data FileRead (Fhandle, Buffer ^, NextSize); if Assigned (FOnDataAvailable) then FOnDataAvailable (Self, StrPas (Buffer)); finally FreeMem (Buffer, NextSize 1); END; // Continue to see if there is any information in Mailslot Result: = getMailslotinfo (Fhandle, NIL, NEXTSIZE, @MESSAGECUNT, NIL); End; End; As for Mailslot's Client, there is nothing to say, It is the file to open and write:

procedure TMailSlotClient.Open; var ASlotName: string; begin if FActive then Exit; // MailSlot identification name ASlotName: = '//' FServerName '/ mailslot /' FSlotName; // open MailSlot (File) FHandle: = CreateFile (pchar (ASlotName), GENERIC_WRITE, // Client side for writing only MailSlot FILE_SHARE_READ, // set for sharing read Nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); fActive: = FHandle <> INVALID_HANDLE_VALUE; end ;

Function TMAILSLOTCLIT.WRITEINTOMAILSLOT (Const Data: String): Integer; Begin Result: = 0; if Fhandle = InvaliD_Handle_Value THEN EXIT; Result: = FileWrite (Fhandle, Data [1], Length (DATA));

Almost mentioning Milslot is suitable for network broadcasts across the machine boundaries, but I also explain that only Mailslot Server can read the information, how to broadcast? The answer is the name of Mailslot. If another machine is also created with the same name, once any client gives a message to a mail to a mail, this message will travel to each specified Mailslot on the network node, so The effect of broadcasting is reached. As for how the message is flowing, leave the system and the bottom floor of the network to hurt the brain, and the program will only be sent to the information in the manner. When using mailslot, it is likely that you will encounter a problem with your message; that is, although the Mailslot Client side has written only a message, the same message Mailslot Server may receive two copies. The reason is this: Due to the Win32 multi-communication agreement, Mailslot is broadcast when broadcasting, and does not know which path should be used, so it has passed a variety of possible pathways. The situation is a bit like publishing typhoon alerts, we will know the news from typhoon at the same time. The solution is to add some controlled number code at the beginning of the data, and Server is determined whether it is the same material.

What are the communication mechanisms like Mailslot? The famous example is WinPopup, just now I also wrote a spring, the next picture is the case of MyWinPop.exe. Due to the characteristics of MailSlot broadcast, it is very suitable for web management to know important messages, in addition, the MIS system can also use it to report abnormal conditions, and if each user is placed in the "Start boot" Program, with each other, exchange messages, when the letter comes in, it will immediately display the content of the message.

Figure: MYWINPOP.EXE execution situation

Of course, you can also want to get other applications. As I think it is very suitable for use as a program debug tool, but also records the procedures and conditions of the program, but also the execution status of each node on the Internet will also come back, which is a general test method. Effects do not have to achieve.

After PIPE looks through the broadcast mailslot, the PIPE is the communication mechanism of point-to-point point, and the data allows the one-way or bidward to move between the tube connections. PIPE can be divided into two kinds of Anonymous Pipe and Named Pipe. The ANONYMOMOUS PIPE can only flow one-way, but it is limited to stand-alone, but it is the standard input of its standard output (Standard Output). Method; Named PIPE is like the IPC mechanism previously discussed, because there is a identification name, other itiners can easily be found in accordance with the name, the communication range is not limited to stand-alone, while the data allows two-way circulation.

DDE is like the first Twinapp example in this article, DDE is also based on message communication, but its agreement is clearly a lot.

DDE is a Client-to WM_DDE_INITIATE broadcast message from the call kicked off, after accepting to WM_DDE_ACK end Server response, the communication is between the Client and the Server to send each series WM_DDE_DATA, WM_DDE_REQUEST, WM_DDE_ACK other messages to one another. The actual information is not true to pass through message, but to provide clues to use Atoms (string comparison table provided by Windows systems) seeking three projects such as the application, Topic, Topic and Data. Finally, the conversation ends with the WM_DDE_TERMINATE message.

When the DDE connection is established between the itinerary, when the data exchange of the Server is changed, the frequency of frequent communication with the client is divided into: Cold Link: CLIENT is active, if No, even if Server's information has changed, Server is also ignorant of Client. Hot link: There is a change. When the data changes, the Server end will actively notify the client change. WARM LINK: Update Notification; When the data changes, the Server end only informs the information changed to the information change, and the true information will be sent to the CLIENT request. Since the DDE message communication involves a lot, in order to use convenience, Microsoft also provides the DDE management library (DDE Management library, referred to as DDEML), the maximum difference in use is to use DDEML's program to handle with the Callback function DDE transaction. In addition, the 3 major project Application Change is called a Service Name.

Today, discussing DDE's literature is not in a small number. Indeed, DDE use should be much easier, almost no Windows program development tool does not provide some element or category to make DDE Server or Client program. Of course, if your needs are just informing some messages between the itinerary, you can design a set of message communication protocols to complete the task, I think that the first example twinApp is a good tip.

Other IPC Technology Exe typically calls the output function (Exports function) of the DLL, in some cases, the DLL also uses the EXE-pre-prepared response (Callback) function. Function call This concept and idea What happens if it is transplanted to the trip communication? I mean, let a stroke call another trip function. Ya! This is the so-called RPC, and the stroke belongs to the cooperation of the function call level. It can be imagined. Because the itinerary has its address space, such as OLE, it is necessary to reach an additional standard interface to define.

We have already introduced a lot about IPC, whether it is a message exchange, scrapbook, shared memory, dde, mailslot, pipe, etc., almost all information exchange or Client and Server "requirement - response", The newsletter to communicate must have a certain degree of understanding and processing capabilities for exchange of information. In other words, after we need to pass the information in DDE to the trial watch software, the information is explained to the end; the same, if you want to pass the information to a coupon mesh, even if you help It is still necessary to have basic understanding of the coupling mesh.

Saying back, only if the trial table knows what you know, isn't it? Then, it should be handled by it to handle the information. Strong exquisite proceedings will have a regret of the pedestrians. Using OLE technology to integrate the application to work together, it is really a reasonable approach. If the COM object can work like an electronic IC to work together with our program, then we call Ole Control (ActiveX) , The distance is large to the Internet, you must have heard of this noun.

Think about it, we can finally use the company's statistical chart components, then use the company's components to fax out, so that the window is beautiful. The window does only offer local landscapes, but the window with a telescope can be an observatory, which is not just a scenery, and a pleasant voice. Whether it is RPC or OLE, I think this is a discussion of this article, but it is definitely not discussed, and these two themes are not very good enough to talk about a single article. In fact, some places (such as DDE this section) I have not mentioned the technical practical details in technology, which is in the future, and we will continue to introduce RPC in this column in this column. . About Winsock as an IPC communication mechanism, the previous article of this column "Go! Let us talk to BBS chat", just explained, there is no longer rescued here.

Techniques for applying IPC to your program are often combined in a variety of ways. For example, the Demosmem model provided herein uses ShareMem exchange data, and the synchronization mechanism uses Mutex and Event. The situation is not as complex in the imagination: it is both a stroke communication. It is inevitably between two strokes. It is both separate, middle must have an interposed, defining the specific content of this interface is the so-called agreement, pay attention to the location of the data exchange In a way, it is necessary to coordinate the use of appropriate synchronous control. These points are grasped, and you should have a number.

When you are facing a wide range of technologies, if you are considering applying IPC to your program, you first have to face your needs, you may wish to ask yourself similar to the following questions, it is best to write down

Do you really need cross-wound processing, what is the achievement? The extent of technical practical and cost data of the required cost is unidirectional or two-way, and it is necessary to provide feedback control. These work is only completed, or need to connect to the network, the range is only in the company. What is the number of zone networks or a wide range of networks and communications? Only in an operation environment, or may also meet the performance of different job platforms (Performance) is not a key requirement. Application model uses the GUI interface or console mode next to compare the features of the IPC, which are listed with you If the demand is in line with, there is a limit that you have to exclude, and the IPC has a high-written assembly result, and the points are highly stood out. Finally, if things can be simple to solve, the development time is shortened. The cost is naturally lowered, and it is easy for future maintenance.

转载请注明原文地址:https://www.9cbs.com/read-30799.html

New Post(0)