GSerg писал(а):Подключи TypeLib Info в референсах.
Option Explicit
Private Sub Form_DblClick()
Dim o As Object
Set o = GetObject(, "Word.Application")
Dim disp As olelib.IDispatch, info As olelib.ITypeInfo
Set disp = o
Set info = disp.GetTypeInfo
Dim pta As Long, ta As TYPEATTR
Dim i As Long, pfd As Long, fd As FUNCDESC
pta = info.GetTypeAttr
MoveMemory ta, ByVal pta, LenB(ta)
Dim Clsid As String * 39
Debug.Assert StringFromGUID2(ta.iid, Clsid, 39) = 39
Debug.Print Clsid
For i = 0 To ta.cFuncs - 1
Dim Name As String, Description As String
pfd = info.GetFuncDesc(i)
MoveMemory fd, ByVal pfd, LenB(fd)
' Debug.Assert info.GetNames(fd.memid, Name, 1) = 1
' Debug.Print Name
info.GetDocumentation fd.memid, Name, Description, 0, vbNullString
Debug.Print Name, Description
info.ReleaseFuncDesc pfd
Next
info.ReleaseTypeAttr pta
End Sub
Private Declare Function DispatchTypeInfo Lib "..\Debug\TestCOM2.dll" (ByVal x_obj As Object) As Long
Dim A As Object
Set A = CreateObject("Scripting.FileSystemObject")
DispatchTypeInfo A
long DispatchTypeInfo(LPDISPATCH lpDisp)
{
ITypeInfo **tpInfo;
UINT tpCount=0,tpI;
lpDisp->GetTypeInfoCount(&tpCount);
tpInfo=(ITypeInfo**)(new DWORD[tpCount-1]);//Создаем массив из tpCount-1 элементов.
//Записываем массив
for(tpI=0;tpI<tpCount;tpI++)
{
lpDisp->GetTypeInfo(tpI,0,&tpInfo[tpI]);
}
//Чего нибудь тут делаем с этим массивом.
//...
//Удаляем массив
for(tpI=0;tpI<tpCount;tpI++)
tpInfo[tpI]->Release();
//delete [tpCount-1](DWORD*)tpInfo; //В этой строке происходит memory exc. Почему?
return 1;
}
ANDLL писал(а):2tyomitch: Спасибо. щас проверю. Впрочем, я тут тоже постарался:
ANDLL писал(а):А что собственно можно делать с tpInfo? Там куча каких-то непонятных функций. Для чего они предназначены?
И еще: что такое второй параметр в ::GetTypeInfo? LCID lcid. Я оставил его 0, но что-то же он значит.
И почему происходит exc. в последней закомментированой строке?
Ну и наконец: весь указанный код ничего, в принципе, не делает, но и не вызывает exc.
Правда, если запустить VB-проект под IDE появляеться Bad DLL Conversion calling , но после сборки и эта ошибка исчезает:)
lcid
The locale identifier for the type information. An object may be able to return different type information for different languages. This is important for classes that support localized member names. For classes that do not support localized member names, this parameter can be ignored
IDispatch::GetTypeInfoCount
Retrieves the number of type information interfaces that an object provides (either 0 or 1).
dispinterface id: {CE1B1932-509E-4BA9-8F6E-1517DB41FCA2}
dispinterface members list:
----------
Property Get _Default() As Object
(dispatch only)
Description:
_Default
----------
Property Get Name() As String
(dispatch only)
Description:
Name Returns the name used in code to identify an object.
----------
Property Get Caption() As String
(dispatch only)
Description:
Caption Returns/sets the text displayed in an object's title bar or below an object's icon.
----------
Property Let Caption(RHS As String)
(dispatch only)
Description:
Caption Returns/sets the text displayed in an object's title bar or below an object's icon.
----------
Property Get hWnd() As Long
(dispatch only)
Description:
hWnd Returns a handle (from Microsoft Windows) to an object's window.
----------
Property Get BackColor() As Long
(dispatch only)
Description:
BackColor Returns/sets the background color used to display text and graphics in an object.
----------
Property Let BackColor(RHS As Long)
(dispatch only)
Description:
BackColor Returns/sets the background color used to display text and graphics in an object.
----------
Property Get ForeColor() As Long
(dispatch only)
Description:
ForeColor Returns/sets the foreground color used to display text and graphics in an object.
----------
Property Let ForeColor(RHS As Long)
(dispatch only)
Description:
ForeColor Returns/sets the foreground color used to display text and graphics in an object.
----------
Property Get Left() As Single
(dispatch only)
Description:
Left Returns/sets the distance between the internal left edge of an object and the left edge of its container.
----------
Property Let Left(RHS As Single)
(dispatch only)
Description:
Left Returns/sets the distance between the internal left edge of an object and the left edge of its container.
----------
Property Get Top() As Single
(dispatch only)
Description:
Top Returns/sets the distance between the internal top edge of an object and the top edge of its container.
----------
Property Let Top(RHS As Single)
(dispatch only)
Description:
Top Returns/sets the distance between the internal top edge of an object and the top edge of its container.
----------
Property Get Width() As Single
(dispatch only)
Description:
Width Returns/sets the width of an object.
----------
Property Let Width(RHS As Single)
(dispatch only)
Description:
Width Returns/sets the width of an object.
----------
Property Get Height() As Single
(dispatch only)
Description:
Height Returns/sets the height of an object.
----------
Property Let Height(RHS As Single)
(dispatch only)
Description:
Height Returns/sets the height of an object.
----------
Property Get Enabled() As Boolean
(dispatch only)
Description:
Enabled Returns/sets a value that determines whether an object can respond to user-generated events.
----------
Property Let Enabled(RHS As Boolean)
(dispatch only)
Description:
Enabled Returns/sets a value that determines whether an object can respond to user-generated events.
----------
Property Get WindowState() As Integer
(dispatch only)
Description:
WindowState Returns/sets the visual state of a form window at run time.
----------
Property Let WindowState(RHS As Integer)
(dispatch only)
Description:
WindowState Returns/sets the visual state of a form window at run time.
----------
Property Get MousePointer() As Integer
(dispatch only)
Description:
MousePointer Returns/sets the type of mouse pointer displayed when over part of an object.
----------
Property Let MousePointer(RHS As Integer)
(dispatch only)
Description:
MousePointer Returns/sets the type of mouse pointer displayed when over part of an object.
----------
Property Get FontName() As String
(dispatch only)
Description:
FontName Specifies the name of the font that appears in each row for the given level.
----------
Property Let FontName(RHS As String)
(dispatch only)
Description:
FontName Specifies the name of the font that appears in each row for the given level.
----------
Property Get FontSize() As Single
(dispatch only)
Description:
FontSize Specifies the size (in points) of the font that appears in each row for the given level.
----------
Property Let FontSize(RHS As Single)
(dispatch only)
Description:
FontSize Specifies the size (in points) of the font that appears in each row for the given level.
----------
Property Get FontBold() As Boolean
(dispatch only)
Description:
FontBold Returns/sets bold font styles.
----------
Property Let FontBold(RHS As Boolean)
(dispatch only)
Description:
FontBold Returns/sets bold font styles.
----------
Property Get FontItalic() As Boolean
(dispatch only)
Description:
FontItalic Returns/sets italic font styles.
----------
ANDLL писал(а):А пример кода?
GSerg писал(а):Подключи TypeLib Info в референсах.
ANDLL писал(а):2tyomitch: Напиши вместо GetObject... CreateObject("Microsoft.XMLDOM"). Там получаеться два интерфейса, но эти интерфейсы описаны раз десять.
MSXML2 Microsoft XML, v3.0
LibID: {F5078F18-C551-11D3-89B9-0000F81FE221}
Version: 3.0
tyomitch писал(а):... во-вторых, tlbinf32.dll является частью Студии, и её нельзя распространять.
Vi писал(а):tyomitch писал(а):... во-вторых, tlbinf32.dll является частью Студии, и её нельзя распространять.
Ты ошибаешься: tlbinf32.dll является свободно распространяемой библиотекой. Это описано в REDIST.TXT в студии.
нет уже готовых Object Browser-ов на VB?
Andrey Fedorov писал(а):нет уже готовых Object Browser-ов на VB?
Дык они-ж довольно элементарно пишутся с использованием TLBINF32.DLL. По крайней мере я полный аналог VB-шного когда-то делал...
Andrey Fedorov писал(а):Могу дать исходники одного проекта...
Andrey Fedorov писал(а):Но Object Browser я там успел реализовал в полной мере и ничуть не хуже чем в VB. Так что достаточно его немножко причесать, выкинув лишнее.
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 17