Python extension interface [2] dynamic link library dll[0, dynamic link library and auxiliary tools

Source: Internet
Author: User
Tags ole

Dynamic Link library /Dynamic Link Library

Directory

    1. Introduction to Dynamic Link library
    2. Function Encapsulation DLL
    3. Component Object Model COM
    4. How to tell if a. dll file is COM or DLL
    5. Auxiliary tools

1 Introduction to Dynamic link library /DLL Introduction

Dynamic link library, DLL, is a way for Microsoft to implement shared library concepts in the Windows operating system, and under Windows, these library functions can be. Dll/.ocx (ActiveX)/.drv ( Legacy system drivers), which are often. So files in Linux systems.

dynamic linking provides a way for a process to invoke a function that is not part of its executable code . The executable code for a function is in a DLL file that contains one or more functions that have been compiled, linked, and stored separately from the process that uses them. DLLs also help to share data and resources . Multiple applications can access the contents of a single copy of a DLL in memory at the same time .

A dynamic-link library file, which is a non-executable binary program file that allows programs to share the code and other resources necessary to perform special tasks. Windows-provided DLL files contain many of the functions and resources that allow Windows-based programs to operate in a Windows environment. It is generally stored in the "C:\Windows\System32" directory of the computer.

In general, the dynamic link library can be divided into the following two kinds,

    1. The function encapsulates the DLL, which is the most common dynamic link library file, which is usually encapsulated as a collection of functions and provides interfaces externally in the form of a function API;
    2. COM, the Component Object model, is a new software development technology developed by Microsoft for the production of software in the computer industry more in line with human behavior .

2 Function Encapsulation DLL

This section can refer to links.

3 Component Object Model COM

3.1 About COM

The Component Object model (Component object models, COM) is a new software development technology developed by Microsoft for the production of software in the computer industry more in line with human behavior. Under the COM architecture, people can develop a variety of functional-specificity components , and then combine them as needed to form a complex application system.

The benefits are manifold, you can replace the components in the system with a new one, so that the system can be upgraded and customized at any time, the same component could be reused in multiple application systems, and the application system can be easily extended To the network environment, COM and language, platform-independent features so that all programmers can give full play to their talents and expertise to write component modules, and so on.

COM is a way to develop software components. Components are actually small binary executable programs that can provide services to applications, operating systems, and other components. Developing a custom COM component is like developing a dynamic , object-oriented API. Multiple COM objects can be joined together to form an application or component system. And the component can be removed or replaced at run time, without being re-linked or compiled by the application. Many of Microsoft's technologies, such as ActiveX, DirectX, and OLE , are built on COM . And Microsoft developers are also heavily using COM components to customize their applications and operating systems.

3.2 COM with the Ole/activex Relationship

OLE and the ActiveX

Object Linking and embedding (object linking and Embedding, OLE), or OLE technology, OLE is an object-oriented technology that leverages this technology to develop reusable software Components (COM) . OLE is not only a desktop application integration, but also defines and implements a way to allow an application to "connect" to each other as a software " object "(a function of data collection and operational data). " mechanism , this connection mechanism and protocol are called Component object models (Component object model), referred to as COM. OLE can be used to create compound documents that contain different types of data created in different source applications, so it can combine text, sounds, images, tables, applications, and so on.

ActiveX is an open integration platform that provides developers, users, and web manufacturers with a quick and easy way to create program integration and content in interne and intranet. With ActiveX, you can easily insert multimedia effects, interactive objects, and complex programs into your Web pages to create high-quality multimedia CD-ROMs that are quite user-friendly. Its main technology is still COM.

ole/activex/com The three-person relationship

Refer to the explanation of Baidu Encyclopedia,

Now you start to explain the relationship between ActiveX, OLE, and COM. First of all, let's have a general concept, from a time point of view ,OLE is the first to appear , then COM and ActiveX. From an architectural standpoint ,OLE and ActiveX are built on top of com, so com is the foundation . From the name point of view, OLE and ActiveX are two trademark names, and COM is a purely technical term , which is why you hear more about ActiveX and OLE.

Since OLE is the first to appear, from OLE, since the Windows operating system became popular, the "clipboard" (Clipboard) first solved the communication problem between different programs (the Clipboard acts as a data exchange center for copying and pasting), but the clipboard passes "dead" Data, the application developer has to write and parse the code of the data format, so the communication protocol of Dynamic Data exchange (Exchange,dde) comes into being, which allows the application to automatically get the latest data from each other, but solves the "data format" between each other. Conversion is still a heavy burden for programmers. The creation of the link and embedding of objects (object linking and Embedded,ole) increases the data exchange of the original application to "Object Exchange, so that the program not only obtains data and also obtains each other's application objects, and can directly use each other's data content, in fact, OLE is Microsoft's Composite document technology, its original version is only aimed at the compound document, but in subsequent versions of OLE2, COM was imported. ThusCOMis to beOLEthe need to be born., so although COM is the basis of OLE, OLE is produced before COM. COM's basic starting point is to have a software service for another software through a common organization. COM's first consumer is OLE2, so COM and composite documents do not have much to do with the relationship, in fact, later COM as a complex document completely unrelated technology, began to be widely used. As a result, Microsoft has started to "meddle" with common platform technologies. But COM is not a product, it requires a trademark name. At that time, Microsoft's market experts had chosen OLE as the trademark name, so the use of COM technology began to affix the OLE label. Although the vast majority of these technologies are not related to compound documents. Microsoft's approach has made it a misconception that OLE refers to compound documents only? Or does it just mean compound documents? In fact, OLE is the brand name of COM, and nature does not refer to compound documents. But Microsoft itself may not be able to explain that it takes considerable effort and time. So, with the development of the Internet, in the spring of 1996, Microsoft changed its mind and chose ActiveX as the new trademark name. ActiveX refers to a loosely defined, COM-based collection of technologies, while OLE still refers to compound documents only. Of course, the most core technology of ActiveX is COM. The biggest difference between ActiveX and OLE is that OLE is for integration between application software and files on the desktop, while ActiveX is primarily for user interaction with further network applications.

COM Status

Here, you should have a more clear understanding of the relationship between ActiveX, OLE and COM, COM is the most fundamental core technology, So the following is the focus of COM. It is a very novel idea to make the object model completely independent of the programming language. This is something we can learn from the concepts of C + + and Java objects. But what is the so-called COM object? For the sake of understanding, COM can be thought of as a kind of (software) packaging technology , that is, as a different part of the software, in a certain object-oriented form , Combines procedures and a set of support libraries that you can interact with. COM objects can be written in any language, such as C + +, Java, and VB, and can be implemented as DLLs or as executable files that work in different processes. A browser that uses a COM object does not need to worry about what language the object is written in, or whether it is executed in a DLL or another process. From the browser side, there is no difference. Such a common processing technique is useful. For example, two apps that are run by the user can be implemented as interactions between COM objects (of course, the OLE compound document can do). To execute code downloaded from a Web server in a browser, the browser can think of it as a COM object, which means that COM technology is also a standard way to package downloadable code (which is what ActiveX controls do). Even methods of interacting with the native OS can be specified using COM, for example, in Windows and Windows NT, where new APIs are used, most of which are defined as COM objects.

COM, although originated from compound documents, but it can effectively apply to many software problems, it is at the bottom of the basic technology. In a word, COM is a language-independent component architecture that allows components to communicate with each other. With the development of computer network, COM further developed into a distributed Component Object model, this is the DCOM, it is similar to the CORBA Orb, this article will not do further elaboration. I believe you have a clear understanding of the relationship between ActiveX, Ole, and com/dcom through the above narrative.

3.3 COM and General DLL difference

The main differences between the two can refer to links,

DLL is a kind of improvement to static connection, bring a finer development division of labor, also bring a lot of problems, in which there is the problem of how binary system interacts. This problem is more pronounced when the DLL output class.

COM to solve this problem put forward a very negative creative solution, not only so, further extension, proposed how to cross-network interaction. COM + is then presented for development of Internet servers. The COM system incorporates a variety of classic design patterns, which can be said to be a more capable C + +.

The main difference between the two is that

1. COM components are categorized by interfaces for ease of organization. DLL especially large DLLs, functions a large heap, difficult to organize;

2. COM components for easy upgrade maintenance , function expansion , just add interface on the line; DLL upgrade is difficult, function can not be arbitrarily changed;

3. com Create call has good security , DLL does not;

4. COM components can easily implement inter-process calls, DLL is very difficult;

5. COM components can easily implement distributed calls, DLLs are not possible, only in the native call;

6. COM components have encapsulation, inheritance, polymorphic Object- oriented features, DLLs are only encapsulated ;

7. COM components based on the implementation of a number of functions: Activex,ole and so on.

3.4 COM Register

You can use the command-line tool to complete the registration of COM components, as follows:

    1. Start menu, enter CMD to open command line tool;
    2. Register with the command regsvr32 + path where path is the full path and file name (or CD to the directory where the registered DLL resides);
    3. If 64-bit COM, then the CD to the SysWow64 directory before registration.

Note:

    1. You can enter regsvr32/? in CMD to see Optional parameters;
    2. When the error code is 0x80070005, for the system permissions are insufficient, need to run CMD administrator mode, then register can be successful;
    3. When the prompt error cannot find the registration entry DllRegisterServer, please confirm whether it is a valid Ocx/dll, then the DLL may be a normal DLL file encapsulated by the function;
    4. Make sure the path to the registration file is in full English.

4 How to Judging . DLL Files is a COM or is DLL

When you get a. dll file, how to determine whether this is an ordinary DLL file, or a COM component. In general, the file type should be informed, but when you do not know, you may try the following methods to judge.

1. Try to register the DLL file, if the registration is successful, it is COM (activex/ole), the ordinary package function DLL without registration can be used, at the time of registration will be prompted to find the registration portal;

2. Look inside the DLL file functions (using tools such as depends), if the interface function shown is a specific five functions, it is basically COM (do not exclude some ordinary DLL implementation of these functions may be):

1) DllMain: entry function, complete some DLL initialization work (DirectShow implementation is dllentrypoint);

2) DllGetClassObject: Used to obtain the class factory pointer;

3) DllCanUnloadNow: This function is called when the system is idle to determine whether the DLL can be unloaded;

4) DllRegisterServer: Register the COM component in the registry;

5) DllUnregisterServer: Removes registration information for COM components in the registry.

5 Auxiliary Tools /Auxiliary Tools

5.1 Depends

The depends tool can be used to view DLL dynamic link library files, using method reference links,

The main interface areas in the depends tool are as follows, where

The information window of the area 1:dll, which mainly shows the DLL module required by the program;

Zone 2: Functions used by the selected DLL module, including ordinal, hint, function, entry point and other information;

Zone 3: Selected DLL module all the exported functions, also including the ordinal, hint, function, entry point and other information;

Zone 4: Properties of all required DLL modules, error data will be warned with red or yellow hints.

5.2 Oleviewer

Oleviewer can be used to view the COM components that are installed in the current computer.

Related reading

Reference links

http://bbs.csdn.net/topics/380080264

Http://www.cnblogs.com/lihaozy/archive/2012/07/04/2576449.html

Python extension interface [2] dynamic link library dll[0, dynamic link library and auxiliary tools

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.