The understanding and use of COM objects in easy language

Source: Internet
Author: User
Tags time in milliseconds

In Windows programming, COM objects are used, and what are COM objects? If the first contact, it must be difficult to understand the concept! I remember the first time I touched the concept of COM objects, I can say it is confused!

What is a COM object? The following is an understanding of a lot of information and practices that individuals have read:

A COM object should have the same object concept as Object programming. Are all objects, then there must be attributes and methods.

Two COM objects, the official version is the Component Object model, which is a set of specifications, a set of binary and network standards created by Microsoft to address communication between two components Compoment!

(for the 2nd, here I'll explain a little bit here.) In general, the official language is always obscure, but the meaning behind the word is so important. In fact, the most important thing is two points of place: 1. It's about components, which should make sense for Windows components, such as Ie,word, Notepad, and so on. 2. Communication, communication between components, is the communication can be related to the interface of the component communication! )

What is an interface

The interface is the only way for COM to communicate with the outside world, and his definition is the core of the COM specification. An interface is a set of logically related functions that can be thought of as a pointer to a reorganization function!

The following in easy language use WinHTTP this COM to access the Web page simple description of the use of the COM object in the easy language!

First, a button is created in the window and a variable is inserted under the event that the button is clicked, and the type is object.

The meaning of the HTTP object. Creation (winhttp.winhttprequest.5.1) can be understood as follows:

is to create an object named "HTTP Object" with the object type named winhttp.winhttprequest.5.1. Actually also with this COM to establish an interface, for the following interface inside the function of the call provides a way!

Even if the object has been created, the interface has been connected, then we have to invoke the function inside, we must know what can be called in the function, then we use the object. View ()!

We will play the window when we debug it. This window is the property and method that can be used inside the HTTP Object!

Property access Type Description

Option read/write set or retrieve an WinHTTP value.

Responsebody-read-only retrieves the response entity as an array of unsigned bytes.

Responsestream read-only retrieval mechanism as the IStream of the response entity.

ResponseText is read-only as a text retrieval response entity.

Status reads only the HTTP status code from the last retrieved response.

StatusText read-only gets the text of the HTTP status.

Method Description Description

Abort aborts the sending method of a WinHTTP.

getAllResponseHeaders retrieves all HTTP response headers.

getResponseHeader retrieves the HTTP response header.

Open opens an HTTP connection to the HTTP resource.

Send sends an HTTP request to the HTTP server.

Setautologonpolicy set the current automatic login policy.

Setclientcertificate Select a client certificate to send to a secure Hypertext Transfer Protocol (HTTPS) server.

SetCredentials sets the credentials to be used with the HTTP server, either the country of origin or the proxy server.

SetProxy set proxy server information.

setRequestHeader Add, change, or delete an HTTP request header.

SETTIMEOUTS specifies the time in milliseconds that an individual has exceeded a component send/Receive operation.

waitForResponse Specifies the wait time, in seconds, for an asynchronous transfer method to complete the value, settimeouts.

Not all the properties and methods to do a detailed explanation, we can Baidu. Here we only use WinHTTP this COM object for simple Web Access!

Here is a simple access to complete, the main understanding of the concept of COM objects, a simple understanding of the COM object "WinHTTP" access to the Web page process!

The understanding and use of COM objects in easy language

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.