Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Начинающим";
Текущий архив: 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.48 MB
Время: 0.038 c
2-1136464094
RDS
2006-01-05 15:28
2006.01.22
Работа с динамическим массивом


2-1136323169
!Han!
2006-01-04 00:19
2006.01.22
ООП


2-1136550279
Viewer
2006-01-06 15:24
2006.01.22
Как хранить jpeg в DLL???


1-1134555673
TUser
2005-12-14 13:21
2006.01.22
Вывод информации в консоль


1-1134852272
Steplerr
2005-12-17 23:44
2006.01.22
Как использовать "голубой" стиль Win XP





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский