"In-depth analysis ATL" learning hand - first day (ATL # 1)

zhaozj2021-02-17  53

COM is the basic software model of the Windows operating system. Since its establishment in 1993, it has made an indelible contribution to the development of the Windows platform, and it is still growing. For a programmer who develops application software under Windows, how important is COM, in order to learn COM technology, specially bought a book from the bookstore, "in-depth explanation ATL" book, I hope I can Under the guidance of this book, step by step into the temple of ATL development COM components.

Today is the first day of learning "In-depth explanation ATL", only looked at the order, the original sequence, preface, was deeply encouraged, and the heart was secretly decided to learn from ATL.

Let's make an example. According to the book, I have a picture of the ATL components, compile, compile, NINEDIGITSOFPISTARTINGAT, NINEDIGITSOFPISTARTINGAT, NINEDIGITSOFPISTARTINGAT, NINEDIGITSOFPISTARTINGAT, NINEDIGITSOFPISTARTINGAT. Source code, drag it down, copy the relevant code to your own program, big success, compile.

Try it in VB, add my request PI components in the Component in the Project menu, use the following code DIM SPI As Objectdim str1 as stringset spi = createObject ("pisvr.calcpi") spi.digits = CINT Text1.text) spi.calcpi (str1) MSGBOX STR1 How to spi.calcpi (STR1), please teach a pioneer, original for HRESULT CALCPI ([OUT, RETVAL] BSTR * PBSTRPI; should be used with str1 = spi.calcpi result. In the ATL, * pbstrpi = sysallocstring should be used; to return a BSTR pointing memory, which is released after use by the call. However, there is another question, ATL can run in the same process of COM customers, and the assigned memory is of course the same process space in the customer, and the memory allocated by SysallocString can be used and released directly, but ATL can be different from customers. The process space, how will the ATL designer solve these, now just start, such a problem will throw.

Manage it, compile it into a release version. Why, no, change Unicode, or not, what should I do? Debug can be, ask the master. Oh my god!, ATL's bug, mad at me. The last one is removed in the PreProcessor definitions option of Project Setting's C / C property page, finally passed.

On the first day, I will here. I hope I can learn this book well in the encouragement of 9CBS.

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

New Post(0)