Novice understanding and doubts

zhaozj2021-02-16  51

Novice understanding and doubts

2003.7.1

I have studied a study with COM programming, development, and application. After pondering, I have initially formed some of the following understandings and doubts, so I would like to give pointers.

First, use a COM component

1. If you want to know the CLSID of the COM component (one number, 16 bytes long, the world's only); if you don't know CLSID, you have to know the name (Progid), such as Excel.Application.

2. Start to deal with Ole32.dll! If the process has not been loaded, LoadLibrary, then getProcaddress ...

3. Regardless of the three seventy-one, first run a function within CoinitializeEx, Ole32.dll so that OLE32.DLL is recorded inside the thread record the corresponding data and allows you to call other functions in OLE32.DLL.

4. If you already know CLSID, you skip this step. Otherwise, CLSIDFROMPROGID is called to calculate the CLSID according to the name.

The functions in this OLE32.DLL are actually looking in the registry, where: / hkey_classes_root / name (PROGID), there is a / clsid, which is CLSID, in fact, you can go to the registry to look up. Excel.Application CLSID = {00024500-0000-0000-c000-000000000046}.

5. Call the COGETClassObject in OLE32.DLL to create a CLSID Object. You can also call CocreateInstance / CocreateInstanceEx.

This object can imagine that the operating system loads a dynamic link library in memory, or starts a process independently, it does not return the Object handle, so don't want further access by a handle - like getWindow (hwnd, ... ), Also gave up early to further access the Intit position of GetProcAddress. How to access it, look down ...

6. Call COGETCLASSOBJECT to establish a CLSID Object while returning an interface pointer according to an interface number parameter IID_I ... (World Uniform Fixed Number), an interface can imagine a collection of functions.

According to the Object generated by CLSID, there may be several different function sets, each function set has an interface number and corresponding, and the interface corresponding to the number of IUNKNOWN is every Object. The first three functions for each function set: queryinterface, addref, release. Call QueryInterface as a parameter to find the corresponding function set.

7. About CLSID and Interface IID

CLSID is a 16-byte long global unique number, OLE32.DLL looks for the corresponding DLL file according to it in the registry (can also be an exe file). The reference program and the process of the process, the instantiation of CLSID is to load a DLL or run an EXE process. After the DLL or EXE is loaded by OLE32.DLL, the address space of OLE32.DLL creates several function entry address tables (of course, according to DLL or EXE's own definition), and establish a saving start address for each function entry table. The pointer (this pointer is a long word in the address).

IID - Interface, is also a 16-byte long global unique number, OLE32.DLL finds a corresponding, return according to the pointer of all functions of the CLSID instance. Therefore, the instance of the interface is the pointer returned. The C programmer can think of an interface is a structure, and its members are several functions; C programmers can think of an interface as a class class.

As for how the functions in the entry table found through the IID, go to the development interface document of that DLL or EXE. When calling a specific function, it is of course possible to press the parameters into the stack, then the function, but it seems to be the low-level practice in the assembly, it is more troublesome, defined a pointer in the VC to save the pointer to the interface, then Access classes, which is more convenient - the problem compiler of the parameter pressing the stack is solved for you.

8. COM

So COM, summarizes, is the way to call a DLL or EXE to invoke a function provided by OLE32.DLL.

Of course, on this basis, there is Automation, etc., define more standard interface numbers and access methods to complete more complex features.

9. Why use COM

Previously, everyone accessed the function in the DLL mainly loaded by kernel32.dll and then implemented by direct access to the function portfolio. Why do you want to put this process on a layer of ole32.dll now?

9.1. Fill the DLL black hole.

For many years, the DLL will be upgraded, even if it is not upgraded, it is necessary to modify the bug, so Microsoft (of course, other companies) keeps the improvement, the upgraded version of the DLL, the names of each version of the DLL are the same. Although doing every effort to ensure compatible with previous versions, the difference between interface functions (including bugs) or the inexplicable collapse of their own procedures and customers (I still remember the procedures you write to you can run normal SQL Server 6.x's version of the ODBC driver, what should I do? Add a serial number to each DLL file number (of course, there is a version number inside the DLL), then there is a plurality of DLLs of the same original name different serial numbers in the system directory of the operating system? That's too ugly! The final solution is to pack this DLL file that does not have the serial number into a DLL, open in it, and then uses different serial number access, the implementation result of these serial numbers is the current CLSID IID. However, this DLL is not loaded by kernel32.dll, so make a new OLE32.DLL to support this mode, and the OLE32.DLL is saved to save a plurality of sub-DLL in the load, supply Use program call. Of course, this model is also considered compatible with remote call. But for remote calls, the caller is required to tell OLE32.DLL where the remote DLL can be used automatically, this seems to have a direction in Microsoft improvement. This model is called COM. But I still have questions, that ole32.dll ourselves if the version updates or corrects how to do it, and the interior is also a pile Ole32.dll? Each also accessed through CLSID IID?

Is my idea is a bit too much?

9.2. DLL Selling Money

Since over the years, Microsoft has been successfully written in Windows, but organized more programmers to develop applications on the development of programmers. Each application software has produced a large number of intermediate products (such as DLL). ) - Microsoft is definitely a large number of multiplexed middle products. Is Microsoft looked at these Xinxin-made middle products after the application software continued successfully? Do you engage in a model to start selling an intermediate product? 10. COM and .NET

Is COM to strengthen the communication function between the component (which is the instance of CLSID) on COM, in order to ensure the quality of mutual call calls?

.NET is overwritten Ole32.dll (or set up a new DLL), plus one of the framework?

Is there a file name of the program we wrote later, it is important that there are several 16-byte long numbers in the program we must remember, and then to an IP address (in the future, there will be 16 bytes) Send a string number in the past, the other party's system starts we write the program, or a function of our program is called, regardless of a computer, a handheld device, or an implanted chip in the human body?

My mind has no shots in the "Hacker Empire" ...

Second, the impact of COM on programmers

1. Influence on Windows Kernel and API

Will Windows kernels will be overwritten by COM?

The basic API exhibited on the kernel will not change it? So before the previous application can continue to run.

However, there is a message saying that the foundation of Windows file system is based on SQL Server. It is obviously com, which is actually a set of SQL Server COM on the basis of the original File I / O API? Still falling, based on SQL Server COM, here you keep a compatible API dynamic linkory in the previous application?

I think this is not enough, look at DirectX, look at ODBC to ADO, see GDI to GDI .

So, is it not a window mechanism and a message mechanism to transform into a COM mode?

Is the TCP / IP API from UNIX to be completely replaced with Winsock COM?

The final result is from the kernel. Windows is a bunch of COM. Start first starting a basic COM (kernel COM), then this COM creates more com?

2. Influence on the VC - SDK programmer

Isn't it necessary to write createWindow and WndProc in the future, don't have to process WM _..., lock C's programming technology and information to a collection box? Then I have experienced the pain from the DOS API to the Windows API. I have experienced a class of C theory, and I re-familiarize N more than N many Object's N-many INTHOD of the N-many INTHOD. , Then start writing CreateObject?

Is the example of the progID of the COM change, and once the Interface is the same, once the COM's interface is continuously increased? Open MSDN Just look at the number of functions under an interface, I started to fain.

3. Influence of VC - MFC programmers

Is the MFC originally defined a programming interface defined for encapsulating CommON Controls (itself is not API)? Is MFC also have natural defects, supporting the back of COM or too many history bags (such as Document / Frame / View), will also face the fate of eliminated in the future? Are you a deep understanding of C , it is not difficult to change a development environment?

4. The impact on the VC - ATL programmer

Is it when it is raging? The big situation of the revolution is in front of you?

What is the C #?

5. Impact on VB programmers

Obviously, see if VB6 to VB.NET changes.

After learning QBasic, after learning the incident, is it our new thing?

Is this change like the FoxBase to VB 3.0, but then find out what else can be written?

6. Influence on ASP programmers

Is our ASP code itself can also compile COM? Calling with JAVA / JSP? Anyway, no one can see the advantages and disadvantages of our ASP code.

Is it necessary to start using XML COM so that our ASP COM can communicate with other people's ASP COM?

Third, the impact of COM on software companies

1. Influence on the project development process

Is it our development process that will be divided from a function and module, and the management becomes divided into COM units.

Is it the same as the COM write document developed by our project, while Coding is written in different languages ​​to retain the outstanding talents of the company's languages.

After running in this way, we actually have a pile of COM with a variety of questions, completing time, pushing, bug and compatibility issues are endless, plus customers From time to time, we will be unhappy? Does the project group have been killed or the project manager is killed?

Is it a high-level management at the fundamental requirements for the progress of the technology and the change of the development process? Nor does it use new technologies to raise raise?

Will not use the COM development model to high-rise Buffs to speed up the development schedule, reduce the development cost, reduce the development cost, and immediately decide to reduce the number of project groups immediately after listening?

Is it we have to wait a new project management theory with a COM development model, and the system is ripe, and then eat crabs again?

2. Influence on product development

Is it the documentation and code that we maintain products in the future become a document and code that maintains several independent COM?

Is it the product upgrade we will become automatically downloaded from the website and update a COM?

Is it the reliability of our products after using COM?

Is it a time to find a COM of Microsoft, and then change it?

Will not develop the product, we keep in switching with Microsoft's COM, then write Microsoft has not written COM, so alternately, until Microsoft catch up with us, or we fall due to exhaustion?

Or in the end, only 2 in the 33 COM in a product is written by our own, and the others are written by Microsoft. Then we earn 20% of the price of the product, the rest of the 80% pay Microsoft according to property rights charge?

3. Influence on sales

Is it difficult to convince customers to upgrade to our COM technology?

Is it for a long time? Sales staff and customers will not know what COM is?

Is our technology and product upgrade to COM, the customer is not asked to see change, it is not willing to pay more? Instead, I have heard that the COM component is re-installed and the contract amount is required? Is it possible to add an IT budget for a thousand-year-old insects of the application system, but will not prepare the budget for the system COM upgrade?

Is the sales person who listens to us to talk about COM upgrade?

Is there any company to pack COM technology into a new concept to brag?

4. The impact on the market and industry

Is the industry's total sales in the industry in the industry increased by 10%?

Is there a foreign large software company after COM technology to outsource COM's development tasks, hand it over to low-cost production?

Is there a COM technology, the software development industry has become the same as the traditional industry, which is manufactured according to the design drawings (COM design document) processing (COM this word is accurate), then the big general assembly company (such as Microsoft) Just like General Motors, Toyota)

Referring to the traditional industry, is it fast to end in the era of non-standard (quasi) design, but to start the age of standard parts? Just like the development of various technologies and products since the industrial revolution, such as military, shipbuilding, automobiles, household appliances, especially, PC compatible machine hardware systems created by IBM.

Fourth, write my own COM component - what I want to do?

Before the abyss of C grammar and COM, I think it is necessary to do what I have to do.

1. Do I have to rewrite a DLL (non-COM) I have written in myself?

In order to catch hipster, it is also hidden behind ole32.dll, and then define several 16-bytes of connector tips? And it is transformed from the function header (parameter) that does not match the COM function call specification? Handle the string of the function in the function, all of the memory applications check and rewrite it properly?

Add: QueryInterfaceAddRefreeSecreGisterSTerverDllunregisterserver, etc., on the basis of the previous DLL.

Tell yourself, continue: Continue: Overwritten the original DLL supporting test program? Have you rewrite the original DLL profile documentation? To ensure that the original language is guaranteed on the basis of understanding the COM mode. Add a wonderful What's new in the original DLL supporting documentation?

After the quality inspection, modification, quality inspection, modification of Dan Dan ... After the high-spirited callors, I will tell the original DLL caller: My new COM interface is ready, can you start to rewrite your application?

If this is the revolutionary action I started myself, will they suddenly show the behavior of unreasonable intelligence control?

If I am a COM's Interface, will someone call my release function?

2. Do I want to transform the current product or project (traditional EXE application) into a COM mode?

100% transformation is not, at least we have to have a traditional EXE so that it makes the first COGETCLASSOBJECT call to OLE32.DLL, so that our program is loaded and started, just like Iexplore.exe and Shdocvw.dll (This example is not very accurate, let's take a look).

What is the result of the transformation? Is our development efficiency improved? Is it a reduced product / system maintenance? What is the proportion of this renovation process compared to a DLL's transformation process? If the component is sold separately, is the marketing department to make our sales plan for our "salary entry COM component"?

Forget it, this problem allows the company's high level to discuss it.

3. Is I intend to divide the new product / new project design into two major parts, part of the traditional EXE section, another part is the COM component (refers to my own COM component, doesn't mean the COM of Microsoft?

Is it a multi-project / multi-product multiplexing? Is it possible to solve customer custom trouble on this basis? Can you take some COM components out?

Is it very important to have the design of each COM in this whole system? Is it because it is designed to have a significant, far-reaching impact on several products / projects in the future? Once we found a COM existently designed, it was a wasteful - its 16-byte interface numbers could not be used? Is it for this situation I have to carry out a lot of investment in the design of COM, and to gradually test in realization, accumulate COM as an important thing as it is as important as the product.

Is this mode will be the mainstream development model in the next year, is the real large-scale industrialization mode?

Is it the development process of the company, the management system needs to be completed with it? Is there only a manager of these truths, or even the general manager, can the company develop in this direction? Otherwise it is easy to apply East, 邯郸 步? Is it possible to wait patiently in learning - don't have conditions not yet mature and I blindly promote COM final failure is done?

Isn't my few thousand lines of small apps for this model, most of the code is a frame code, useful code is not a few lines, most of the documents are a set, just after CMM certification? Will you eat a few bitterness, I found that the knife killed with slaughter is too tired?

4. I am going to talk to foreign companies, learn from foreign companies, learn from the foreign software companies, learn from people to COM design specifications, document writing specifications, Coding Specifications - to understand international practice, then work hard to pick them COM outsource?

I am not another software farmer's artist in the agricultural natural economy of the software? I am not a joke that I meet the US programmer I met, the Indian programmer is a shit? I should also participate in the software industrialization process of the world, replace the Qingli long sweats into blue-collar work clothes, start from screwing, sweep floor, eat Japanese, Taiwanese, Koreans, Indians, The road they walked, continued to grow, after several years, we came to formulate the standards of the COM era, do not like for so many years, people keep public release standards, we don't stop the giddole?

Is there so much money from the domestic customers, it should be content, should you go to the competition of the real gun with the foreigner?

Will I get to work at the time of get off work this evening, tell me how to work overtime, this is not careful, a big bit of ambition is unprepared?

5. Write my own COM component - Who will define those 16-bytes of numbers?

Ok, let's follow your step. Is it the definition of 16-byte numbers that should be done first?

It is very simple to do, and the cocreateguid in OLE32.DLL returns one, and the continuous call can return a lot. But thinking about this in this stuff, it should be treated carefully. Of course, ProgID is also very important, but is not as big as CLSID and IID affect? For later, it is convenient, I divide the relevant personnel into COM's writers and COM usage people.

1. COM writer defines those 16-bytes of numbers

This should be what the cattle is doing. "I have defined a number of 16-byte numbers, you are using it!", These numbers should be the trademark, ID number in the programmer circle. These numbers mean that there is a martial arts in which they have martial arts, general programmers can't write at all, and their functionality is unique. These numbers will be the strength of the program development master (not necessarily a person, or a company) will have a long time to be admired by COM. Many corners of the applicant made for a long time - famous writers looked at the works of the work, the experience of the world is a kind of program master, after retreating the river, find a tool to search for the host's registration in the Internet. CLSID and IID, are the number of numbers defined by their own? Is it also a fun? Even if your own secret code has disappeared in an accident, or even if you still have you can't understand it.

Is it the program expert no longer use source code to express your deep internal strength? Is it the previous source of more than 1,000 rows of rows that will spread most rookies, so that even the tricks have not learned? Is it possible to stick COM, attach a number of numbers and a small amount of instructions to better solve the problem of rookie - especially for rookie who is eager to live

Is it a program master (including its company), can begin to study unique martial arts, other masters can be used when needed, do not need to practice like the doors, what is the result? Anyway, the master is only the call of binary COM, not the source code, don't worry about the cheats leakage.

Is it not necessary for the masters to promote their COM?

Is it not a master of the WINDOWS API, but it is those who have deep research on algorithms and special technologies.

Looking for a master to see, Mr. Liang Yixin's super tie (if there is a constant discussion of Mr. Liang and super Jiezheng discussion, it is not intentional, please forgive me) Is it possible to make COM sales? Let everyone can embed a Window of a movie in the program. Of course, in the current situation, almost no one may pay the copyright fee for Mr. Liang, but is long? Obviously, Mr. Liang did not have to worrying that someone made an exe in the super-Ski COM, what "Super Movie Player" is made, then the board is open - if he pays the copyright fee is intended, otherwise let him sell, sell money I will sue him or earn money. This is not a reuse of the source code level, is a binary multiplex, he dares to reply?

After a while, it will not ask someone in Zhongguancun's streets to ask a small number of passengers: "Do you want to CD, the latest super Skie COM component?"

If Mr. Liang does not have a super-tie COM, is it we only use Microsoft's Media Player?

2. CoM caller defines those 16-bytes of numbers

This is probably that the programmer I have to face. Let's take a company COM design task (or participate in the bid), listen to Party A announcement: "The number of COM's number and its member function we have defined, you can design it!", These companies obviously know 16 bytes The importance of the number, and gradually accumulates a set of management mechanisms (will have already applied for those 16-byte numbers for patents or trademarks), and we can only be the implementation of those functions. Is it feeling that people release design drawings, and we are just a construction team? Is there too many functions made in our construction team in recent years, and more and more international engineering packages have been made to Indians? In the end, we still squat in the bridge, Indians have been big? And, is it true - Indians began to transfer projects in foreign?

Is it that the school's students can work hard during the school, to realize the member function of a 16-byte number of a company, make this small part of the fine, after graduation, to the company, say: "This is me One 16-byte number implemented by your company, here is the source code. This COM, source code and its documents have passed your company's standard test. I am willing to join your company, my salary can be more salary than the current programmer Low 20%? "

Can we do it in the international market?

Sixth, further understanding of .NET Framework

1. Is the .NET Framework abandoned OLE32.DLL - retaining it to continue to support the previous application, write MSCOREE.DLL, MSCORLIB.DLL ... a bunch of DLL?

2. Is it used in Framework, we just want to use COM (playing less accurate, we want to write a salary entry program, want to use COM using VB6 - it is COM, don't want to use COM We use VC6-SDK / MFC to call User32.dll's createWindow directly, and we have no choice after using Framework? Is it we will always say goodbye to loadlibrary and getProcaddress - Although Windows is still using them? Always do not want "connect programs" and createProcess to put Windows's basic API function portfolio in our process address? Is there only COM? Only those 16-byte numbers corresponding to the function table, only through them to continue the previously familiar call mode, however, when you find a function, you have found unrecognizable?

3. Is it staying away from the operating system kernel (DOS era), it is necessary to stay away from the operating system base API? Is there a security review when we pass the function table to communicate within Windows? Is it a hacker master to get the security review of these function tables before successful enters the Windows kernel?

4. Is that we let our VB programmers understand inheritance, heavy-duty, and aggregate, let our C programmer abandon the programming call mode with the internal function of the operating system? Is it based on these unified functional tables, which language development application is like a Mandarin expression or use Cantonese expression, it is nothing to write on paper?

5. Is it a bunch of functions in the J2XE of Sun? Is there any obstacle that the Java programmer rewritten .NET application? Is it a bunch of functions to introduce a bunch of functional tables for a while, can directly establish correspondence between the function table inside the J2XE, and the application of Java directly runs on .NET? Is it .NET and J2XE Even if the server is different, but the performance of the client (for most users' windows) is much better than J2XE, J2XE If the HTML / DHTML of the IE of Windows does not turn roots in the client Is there no expressive? Is it Microsoft to start against J2XE for many years? 6. Isn't that I can't tell the people that their Windows can run the application on the .NET as long as it is installed with a total of 30 m installation files (after installing IE6)? Is it that I am going to be newly developed by the competitors, tell the customer that unstable, then continue writing my STUDIO 6 program?

7. Is it that I have to exhaust the leadership that I haven't endored, and the demand for the current period is anger to the large-scale technology of Microsoft. Will not finally have a day to bear to find a big iron hamlet with Windows, a raining, then walk to the restaurant or go to the restaurant. As a result, I haven't given it to the door, I haven't given the friends on QQ, and evening I have already got about a few good buddies to discuss where the trek is hidden in the game on MSN Messeger ...

8. Is it necessary to graduate for many years, the programmer tied to the mouth felt that it is OK, but it is getting more and more heartless to follow this big environmental change? Is it possible to work hard in a short period of time, a management position, but considering long-term issues, watching the tradition of state-owned units in their own hearts.

9. Correct: My 8th awareness is a worry, time will prove.

7. Why is Framework not called COM ?

1. Is it different for Framework COM with ole32.dll? Although Framework can continue to be compatible with the previous COM, there is no COM above the Framework? Is it from the Framework to start the component? Isn't it com (at least not specifically)? Is Framework only retains the 16-byte number of interface (Interface), but Interface is no longer something inside CLSID, but is Namespace?

2. Is the access to the interface (interface on the framework) and OLE32.DLL is completely different from the internal access method of the interface (interface on the COM)? Is it a storage location in the registry and storage mode is also completely different? Although it looks like it looks like a code.

Is it the component I wrote on Framework I only build on its interfab?

Is Microsoft no longer developing COM technology after COM ?

3. Is that I want to write components in the future? Do you have to choose between COM and Framework? Is it started from Framework, I can't write it?

Is it what I need to think when I choose to choose? a. Continue to write a WIN32 API and COM-based component: No application is required to install Framework; can continue to be used by non-Framework applications; future development prospects are unclear. b. Start writing Framework-based components: Application must be installed in Framework; cannot be used by non-framework applications; future development prospects - refers to the direction of Microsoft. 4. Isn't I am angry ready to write a selfime?

5. Is it necessary to go to Framework after I transfer to COM from SDK / MFC? Why can't Microsoft can't make Framework COM ?

After I adapt to Framework, how long does it take to go to another environment?

I can't help but start suspected that Microsoft's top researcher is far from the end. What is Microsoft's researchers study?

How to sell DOS transfer to IBM? How to learn how to learn window / message principle development window 3.0? How to study how the project leaders of the VMS (Unparalleled operating system of Dec VAX machine) do Windows NT? How to learn Lotus 1-2-3 and do Excel? How to learn Netscape and do IE? How to dig the Sybase's horse to do SQL Server? How to buy FoxPro to improve the ACCESS operational speed? ... How to learn J2XE and make Framework?

I admit that Microsoft has learned every time, and it is successful in overall business operations.

6. Is it what we really should learn about Microsoft's learning technology and business operations? Is there much not much value written on MSDN? I am not always in Microsoft's business operations to achieve my lofty programmer, but often painful discovering his business operations caused the program code that I didn't have night, and the experience was all evident in a few years.

7. What is the future of programmers? I started to confuse again. ... ..

8. Correct: My 7th understanding is wrong. The wife has just reached the command: "What to stay ?! Leading his son to the park to turn a circle!"

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

New Post(0)