???? ID: 245115 - ????? ???????: 03 ?????? 2010 - ??????: 2.0 ??????? ??? ????? ???????? ?? ??? ???????? ?? ????? ????
?? ????? ???????????? ?? ????? ???? ?? ??? ??? ??????? ????? ?? ???? ?????????, ???? ????????, ????????????? ?? maintainability ??? ?? ????? ?? ???????? ?? ???? ???? ?? ???? ?????? ??????? ??????? ?? ??? ???????? ?? ?????? ?? ????? ???? ??, ?? ???????? ???? ?? ????? ?????? weighs. ???? ?????????????? ?? ??/???? ?? ?????????? ??? ?? ??? communicates ?? ???? ???? ?????????? ??? Microsoft ?? ????? ?? ????????? ???? ??, ?? ????????? ??? ???????? ???? (COM)? ?? ??????? ?????-??? ????? ??????????? ?? ??? Visual Basic ?? Visual Basic ???? ?????? ??? ????? ?? ??? ???? ??, ?? ??????? ????????? ?? ???? ??? ??????? ?? ??? ??? Historically, ??????? ???????? IDispatch ?? ?????? ???? ???? ??? ???????? ?? ???????? ?? ??????? ??????? ?? ??? ???? ?? ??? ??????? ?? ?????? ???? ?? ?? ????? ?? ????? ??? ?? ??? ???????? ?? ??? ??? ???? ????? ??? ?? ??? ?? ????? ??????? ??????? ???; ??? ????????? ??? ???????? ?? ??? ???? ????? ??, ??? ??, ????????? ??????????? virtually COM ????????, ?? ?? ?? IDispatch ?? ?????? ???? ?? (?? ????? ???? ???? ?? ???? ?? ?? ??? ?????) ???? ?? ??? ?? ???? ??? ?? ???? ???? ?? ????? ?? ???? ????? ???????? Automating ??? ?? ????? ???????? ??????? ?? ?????? ???? ??? ???? ???????? ??????????? ??? ??????? ???? ???? ?? ?? ???????? ??? (?????? ?? ?????) ?? ??? ?????????? ?????? ???? ?? ?????? ??? ?? ??? ???? ?? ?? ????????? ??? ?? ????????? ?????? ????, ?? ??? ?????? ??? ??? ??? ????? ???? ?????? ?? ???? ??? ?? ????????? ?? ???? ??? ?? ?? ??? ???????????? ?? ????? ???, ?? ??? ??? ?? ???????? ???????? ?? ??? ?? "????????" ?? ?????? ???? ??? ?? ???? ??? ???????? ??? ?? ?? ??? ???? "?????? 12, ????? x ???? ????? ?? ??? ?????." ???? ??? ???????? ?? ??? ?? ??? imagine ?? ???? ????? ??????? ?? ?? ?? ?? ???????? ???? ?? ?? ??, ????? before ???????? ??? ?? ????, ??? ??? ???????? ?? ??? ????? ?? ??? ????? ???? ????? ?? ???????? ??? ??? ????? ?????? ???????? ????? ???? ??? ?? ???? ?? ???? "?????" ???? ?? ???? ???????? ?? ???? ????? ?? ?????? ?? ??? ???????? ?? ??? ????????? ????? ?????????? ???????? ???? ???? ??? ???? ??? ?? ??? ?? ??? ?? pulled ?? ??? ??? ??? ?? ????"." ???? ?? ???? ???? ?? ???????? ?? ???????? ??? act ?????? ?? ????? ?? ?? ?????? ??? (?? ?????? offsets, ???? precise ???? ?? ???) ?? ??? ?? ???? ??? ???? "???? ?? ???" ?? ?????? ?? ??? ???? ???? ??? COM ????????, ??? ?? ??? ?????? ????? ???? (v ?????? ?????? ??) ?? ?? ?????? ??? ???????? ?????? held. ?? ??? COM ?????? ????? ??, ??? v ?????? ?? ?????? ?? ????? ??? COM ???????? ?? ?????? ??? ??? ???? ??? ?? ?????? ?? ???? ???????? ?? ???? ??, ?? ?? ???? ?????????? ???? ?? v-???? ?? ???? ??? ?? ???? V-?????? ?? ?????? ???? ?? ??? ???? ???? ???????? ????????? ????? ?????? ?? ?? ???????? ?? ??? ?? ???? ??? ???? COM ???????? ?? ????? ?????? ?? ??? ???? ?? ??? ?? ???? ?????? ??? ???????????? ?? ??? ?? ???? ?? ???? ?? ?? ?????? ????? ?? ????? ?? ?????? ?? ??? ??? ?? ????????? ???? ?? ??, ?? ????? ??, ???? ?? ???? ??? ?? ???? ?????? ?? ????????? ???? ?? ??? ????? ???
+-[Code]------------+ +.................................[COM Object]...+
| | : +-------------+ :
|Set obj = Nothing -|--->| obj pointer | :
| | : +-|-----------+ :
+-------------------+ : | +-----------------+ :
: +-->| v-table pointer | :
: +--|--------------+ :
: | :
: | +----------------------------+ :
: (3rd) | | Function 1 Address pointer | :
: (Offset) | +----------------------------+ :
: | | Function 2 Address pointer | :
: | +----------------------------+ :
: +->| Function 3 Address pointer | :
: +----------------------------+ :
+................................................+
Fortunately, ?? ????? ?? ??? Visual Basic ?????? ???? ?????? ???? Visual Basic ?????????? ?? ??? ??? ??? ???? ??? ?? v-?????? ?? ??? ???? ??? ???? ?? ???? ?????, ?? ?????? ?? ?? ??? COM ???????? ????? ???, ?? ?? ?? ?? ??? ??? ???????? ?? ??? ?? ?????? ??? ?????????? ??? ????? ??????????? ?? ?????? ???? ?? early ?? ??? ??? ???? (?? ??????-v) ???????? ??? ??? COM ????????, ?? ??? ?? ??????? ?? ???????? takes ???? ?? ??? COM ???????? IUnknown ???????? ?? ??? ???? ???? ??? ????? ?? ???????? ?? ???? ?????? ?? ???? ??? ????? ???? ???? ???? ??? ???? ???? ???? ?? ???? ?????? ???? ?? ???? ???????? ?? ??? ?????????? ????? ????? ?????? ???? V-?????? ??? ???? ????? assumed ???? ???? ?? ???? ??, ??? ???? ???? ?? ??? ?????? ??? ???? ?? ??? ?????? ??????? ?????????? ??, ????? ?? ???? ?? ?? ????? ??? ?? ???? ??? ???? v-?????? ???????? ?? ??? ??? ???? ?? ?????? ????? ??? ?? ????, ?? ????? ?? ???????? ????? ??????? ?? ???? ?????-???????? ????????? ?? ??? ??? ???? IUnknown ??????? ??? ???? ?? ?? ?? ???? "?????-????????." ?????? meant ????????: ?? ???? ???????? ?? ????? ???????? ?? ????? ????, ?? ????? ??? ?? ???? ???? v-?????? ??? ?? ??? ???? ?? ???????? ??? Visual Basic ??? ?? ?? ???? ??? ??? ???? ?? ??? ?????? ????????? ????????, ???? ??????? (v-??????), ?? ???????? ?? ??? ?? ???? ??? ?? ??? ?????? ?? ????? ???? ?? ?? ?? ?????? ?????? ??????? ?? ?? ??? ??, ?? ??? ?? ?? ???? ???????? ?? ???? ??????? ??????, ???? ?? ??? ?? ??? ??? ????? ??? ??? ?? ????? ?? ???? ?? ???????? v-?????? ?? ????? ?? ??? ??? ?????? ?? ???, ??? ?? ???????? Microsoft Office Excel ????? ???????? ?? ????? ???? ?? ??? wanted, ?? ???? Project|References ????? ?? "Microsoft Excel 8.0 ???????? ?????????" ???? ?? ??? ??? ?????? ??????, ?? ???? ??? ???? ?? ?????? "Excel.application." ?? ???? ?? ??? ??? ????? ???? ??? ?? ??, ??? ??? ??? ?? ???????? ?? ???? ???? ?? ??? ???? ???? ?? ???? early ?????: Late bindingCOM includes IDispatch. Objects that implement IDispatch are said to have a dispinterface (if it is the only interface they support) or dual interface (if they also have a custom interface that you can early bind to). Clients that bind to IDispatch are said to be "late bound" because the exact property or method they are calling is determined at run time using the methods of IDispatch to locate them. Going back to the book example earlier, think of it as being like a footnote that directs you to the table of contents where you have to "look up" the page number at "read time" rather than having it already printed there in the text.The magic of the interface is controlled by two functions: GetIDsOfNames and Invoke. The first maps function names (strings) to an identifier (called a dispid) that represents the function. Once you know the ID for the function you want to call, you can call it using the Invoke function. This form of method invocation is called "late binding." Again, in Visual Basic the way you specify how the object is bound is by your object declaration. If you declare an object variable as "Object" you are, in fact, telling Visual Basic to use IDispatch, and are therefore late binding: It is important to note that what is "late bound" is the function being called and not the way it is called. From the earlier discussion on binding in general, you should notice that IDispatch itself is "early bound:" that is to say that Visual Basic makes the call to set the Visible property through a v-table entry (IDispatch::Invoke) as it would any COM call. The COM object itself is responsible for forwarding the call to the correct function to make Excel visible. This indirection allows the Visual Basic client to be compiled (that is, bound to a valid function address) but still not know the exact function that will actually do the work. Dispid bindingSome Automation clients (most noticeably MFC and Visual Basic 3.0, but also Visual Basic 5.0 and 6.0 with respect to ActiveX Controls) use a hybrid form of late binding called dispid binding. If the COM object is known at design time, the dispids for the functions that are called can be cached and passed directly to IDispatch::Invoke without the need to call GetIDsOfNames at run time. This can greatly increase performance, because instead of making two COM calls per function, you only need to make one.Dispid binding is not an option you can normally choose in Visual Basic 5.0 or 6.0. It is used for objects that are referenced in a type library but do not contain a custom interface (that is, for objects that have a dispinterface only) and for aggregated ActiveX Controls but, in general, Visual Basic uses early binding any place you would normally use dispid binding. Which form of binding should I use?The answer to this question depends as much on the design of your project as anything else. Microsoft recommends early binding in almost all cases. However, there may be reasons for choosing late binding.Early binding is the preferred method. It is the best performer because your application binds directly to the address of the function being called and there is no extra overhead in doing a run-time lookup. In terms of overall execution speed, it is at least twice as fast as late binding. ????? ???????? ?? ?????? ?? ??????? ???? ??? ?? ???? ??? ??? ?????? ??? ?????? ????????? ?? ??? ??? ??, ?? Visual Basic ???????? ????? ?? ??? ??? ?? ??? ??? ??? ???? ?? ??? IntelliSense ?????? ???? ??? | Visual Basic ?? ???? ???? ??? ??? ???????? ?? ???? ?????? ?? ????? ??? ??? ???? ??, ?? ???? ??? ?????? ?? ???? ?? ??? ?? ?? ??? ???? ????? ??? ???????? ???? ?? ???????? ?? ???? ??????? ????? ???? ?? ??????-??? ?? ????????? ??? ??? ?? ?????? ??? ??? ???? ????????? seeks ?????? ????? ?? ?????? ?? ?????? ?? ??? (Visual Basic 6.0 ?? ????? ?? ??????? ???? ?? ??? ???????? ?? ??? ??? ???? ?? ???CallByName?????? ?? ??? ???) ?? ?? ??? ???????? ?? ????? ???? ?? ???????? ??? ??? ???????? ?? ?? ??? ?? ?? improperly ??????? ?? ???? ??????? ????????? ?? ??? adapted ??? ?? ?? ???? ????????? ?? ??? ?????? ???????? ?? ?? ???? ?? ??? ?????? ??? ????? ???????? ?? ??? ??? ?? ????? ????? ??? ????? ?????? ?? ???? ??? ?????? ????????? ?? ??? ?????? ?? ?????? ??????? ?? ????? ????? ???? ?? ?? ?? ??? ?? ?? ???? ???? ????? ????? ?? ??? ??????????? ????, ?? ?? ????? ?? ?? ????? ??????? ??-????, ?? ??? ???????? ?? ??? ?? (??? ?????? ???) ??? ??? ????????? ?? ??? ???? ?? ?? ???? ?? ??? ????? ????? ????? ????? ???? ?? ??? ?????? ???? ????? ??? ??????? ?? assured ???? ??? ?? ????? ??????? ????? ?? ?? ???? ??????? ?????? ?? ??????? ??????? ??? ????? ???? ?? ??? gracefully ???? ?? ???? ?? ?? ?? ?????? ?? ??? ???? ?? ??? ??? ???????? ?? ????? ?????Microsoft Office ??????????? ??? ??? COM ??????? ?? ?? ????? ?????? ???? Office ????????? ?????????? ?? ??????????? ?? ??? ????? shortcomings ????????? ?? ??? ??? ?????? ?? ??? ???? ???????? ?? ??????? ???? ?????? ??? ?? ???? Office ????????? ?? ???????? ???? ?? ???????? ??, ?? ?? ??????? ?? ???? ?? ?? ?? early ?? ??? ????? ??????????? ??????? ?? ?????? ?? ?? ???? ??????? ??????? ?? ?????? ?? ??????? ???? ?? ???? ?? ?????? ?? ???, ???? Excel 95, Excel 97, Excel 2000 ?? Excel 2002 ?? ???????? ???? ??? ????? ??, ??? ?? ????? ???? ????? ?????? ????????? Excel 95 (XL5en32.olb) ?? ??? ??? ??? ????????? ?? ??? ?????? ???? ???? ?? ???? Office ????????? ?? demonstrate ?? ?? ??? ????? ??????? ?? ???????? ???? ?? ??? ???????????? marshalling ??? ?????? suffer ?? ???? ???? ??? ???????????? ?? ??? ??????? ?? ????? ???? ?? ??? ???? ??? ?? ??? IDispatch ?? ????? ?????Office ?? ??? ????? ???? ??? ?????? ???? ???? ?? ???? ??????? ?? ??? ????????? ?? ???, Microsoft ???????? ??? ???? ????? ?? ??? ????? ???? ?????? ?? ????? ????: 247579
(http://support.microsoft.com/kb/247579/
)
?? ???? ?? ?? Office ??????????? ?? ???????? ???? ?? ??? DISPID ???????? ?? ????? ???? ??????COM ?? ???? ??? ???? ??????? ?? ??? v-??????, ??, ??????? ?? ????? ?? ??? ?? ????? ????? ????? ????????: Rogerson, Dale,?????? COMMSPRESS, ISBN: 1-57231-349-8? Curland, Matt,????? Visual Basic 6DevelopMentor, 0201707128? ???? ???? ???? ??:
???? ?????? ??????????????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??. ?????????? ?? ??????? ????????? ??????? ??:245115
(http://support.microsoft.com/kb/245115/en-us/
)
| ???? ?????? ???? ?????? ??????
????????? ?????? ??????? ???????? ??????
|






Windows Live
Facebook
Twitter
Linkedin
Digg it
Yahoo
Delicious
StumbleUpon
Yammer
Reddit
Technorati
FriendFeed
Email

????? ?? ???? ????
