Форум: "Начинающим";
Текущий архив: 2006.01.22;
Скачать: [xml.tar.bz2];
ВнизCoCreateInstance Найти похожие ветки
← →
The Only © (2005-12-27 21:46) [0]Что нужно подключить, чтобы Delphi видела эту функцию ?
← →
Sergey Masloff (2005-12-27 21:53) [1]Delphi help
← →
Sergey Masloff (2005-12-27 21:55) [2]Модуль ActiveX но если ты по каждому из нескольких сотен модулей будешь спрашивать в инете ;-)))
Учись справкой пользоваться.
← →
The Only © (2005-12-27 21:58) [3]В справке написано много про эту функцию, кроме того где она находится.
Sometimes, a server object makes use of another COM object to perform some of its functions. For example, an inventory management object might make use of a separate invoicing object to handle customer invoices. If the inventory management object wants to present the invoice interface to clients, however, there is a problem: Although a client that has the inventory interface can call QueryInterface to obtain the invoice interface, when the invoice object was created it did not know about the inventory management object and can’t return an inventory interface in response to a call to QueryInterface. A client that has the invoice interface can’t get back to the inventory interface.
To avoid this problem, some COM objects support aggregation. When the inventory management object creates an instance of the invoice object, it passes it a copy of its own IUnknown interface. The invoice object can then use that IUnknown interface to handle any QueryInterface calls that request an interface, such as the inventory interface, that it does not support. When this happens, the two objects together are called an aggregate. The invoice object is called the inner, or contained object of the aggregate, and the inventory object is called the outer object.
Note: In order to act as the outer object of an aggregate, a COM object must create the inner object using the Windows API CoCreateInstance or CoCreateInstanceEx, passing its IUnknown pointer as a parameter that the inner object can use for QueryInterface calls.
In order to create an object that can act as the inner object of an aggregate, it must descend from TContainedObject. When the object is created, the IUnknown interface of the outer object is passed to the constructor so that it can be used by the QueryInterface method on calls that the inner object can’t handle.
и ещё в ms sdk:
Creates a single uninitialized object of the kind associated with the specified CLSID and returns any requested interface pointer. Call CoCreateInstance when you want to create a single object based on a CLSID. If you want to create multiple objects from a single class object, refer to the CoGetClassObject function.
STDAPI CoCreateInstance(
REFCLSID rclsid, //Class identifier
LPUNKNOWN pUnkOuter, //Object is or isn"t part of an aggregate
DWORD dwClsContext, //Context for running executable code
REFIID riid, //Interface identifier
LPVOID * ppv //Pointer to storage of interface pointer
);
Parameters
rclsid
Specifies the CLSID that will associate the correct data and code.
pUnkOuter
If NULL, indicates that the object is not being created as part of an aggregate. If non-NULL, points to the controlling unknown of the aggregate that will use the newly created object.
dwClsContext
Specifies the context in which the executable is to be run. The values are taken from the enumeration CLSCTX.
riid
Specifies the interface to be used to communicate with the object.
ppv
Points to where to return the pointer to the requested interface.
Return Values
S_OK
Indicates that an instance of the specified object class was successfully created.
REGDB_E_CLASSNOTREG
Indicates that a specified class is not registered in the registration database.
E_OUTOFMEMORY
Out of memory.
E_INVALIDARG
Indicates one or more arguments are invalid.
E_UNEXPECTED
Indicates an unexpected error occurred.
CLASS_E_NOAGGREGATION
Indicates this class cannot be created as part of an aggregate.
Comments
The CoCreateInstance helper function connects to the class object associated with the specified CLSID, creates an uninitialized instance, and releases the class object. It encapsulates the following functionality:
CoGetClassObject(rclsid, dwClsContext, NULL, IID_IClassFactory,
&pCF);
hresult = pCF->CreateInstance(pUnkOuter, riid, ppvObj)
pCF->Release();
It is convenient to use this function when you need to create only a single instance through a class object, and do not need to keep the class object around to create other instances. If you do, see the CoGetClassObject function.
See Also
CoGetClassObject, IClassFactory::CreateInstance
← →
The Only © (2005-12-27 21:59) [4]Спасибо
← →
Sergey Masloff (2005-12-27 22:03) [5]Прикол. В справке то ссылки на модуль и нет (Delphi7)
Извиняй ;-)
← →
DrPass © (2005-12-27 23:04) [6]
> The Only © (27.12.05 21:58) [3]
Ты еще "Внутреннее устройство Windows 2000" тут опубликуй, ладно?
← →
palva © (2005-12-27 23:36) [7]Я обычно в таких случаях лезу в Source и делаю поиск имени модуля по всем текстам.
← →
Германн © (2005-12-28 01:27) [8]
> Sergey Masloff (27.12.05 22:03) [5]
>
> Прикол. В справке то ссылки на модуль и нет (Delphi7)
> Извиняй ;-)
Прикол? В справке есть ссылки на модули, кроме WinAPI. И имхо, так было всегда. Наверно эти справки писАли разные группы.
← →
VirEx © (2005-12-28 15:13) [9]
function CoCreateInstanceExProc = function (const clsid: TCLSID;
unkOuter: IUnknown; dwClsCtx: Longint; ServerInfo: PCoServerInfo;
dwCount: Longint; rgmqResults: PMultiQIArray): HResult stdcall; external "ole32.dll"
function CoInitialize(pvReserved: Pointer): HResult; stdcall; external "ole32.dll" name "CoInitialize";
function CoUninitialize: HResult; stdcall; external "ole32.dll" name "CoUninitialize";
Страницы: 1 вся ветка
Форум: "Начинающим";
Текущий архив: 2006.01.22;
Скачать: [xml.tar.bz2];
Память: 0.47 MB
Время: 0.037 c