Всем привет. Сейчас работаю с некоторой динамической библиотекой(*.dll). Пытаюсь из этой dll использовать некую функцию GetTitleIDList. Прототип функции в Visual C++ выглядит так GetTitleIDList(VARIANT_BOOL , int, int, int*, VARIANT*,VARIANT*). В документации к dll эта функция описывается так:This method retrieves two arrays which contain the IDs and titles of all entities (in the selected ID range) with the same type as the current object. GetTitleIDList( bIncludeID, minID, maxID, count, listID, listTITLE )
Input: - BOOL bIncludeID
If True, the titles are in the form “ID..title” (for example, “1..Steel”. If False, only the title, without the ID or separator is returned. - INT4 minID
The minimum and maximum entity IDs to retrieve. You can set minID=maxID=0 to retrieve all available entities. - INT4 maxID
Output: - INT4 count
The number of entities retrieved. This is the number of entries in listID and listTITLE. - INT4 listID[0..count-1]
The IDs of the available entities. STRING listTITLE[0..count-1] The titles of the available entities. If the entity does not have a title, the string “Untitled” will be returned. Return Code: - [FE_FAIL=0 FE_OK=-1
This function is only available for entity types that have titles (Material, Property, View, etc) В документации приведен пример на Visual BAsic
| Код | ‘Attach to FEMAP........................ Dim femap As Object Set femap = GetObject(, "femap.model")
‘Look at Output Set 3................... Dim oc As Object Set oc = femap.feOutputSet() oc.Get (3) Dim od As Object Set od = oc.Vector(1)
Dim rc As Integer Dim Count As Long Dim ID As Variant Dim Title As Variant Dim Row As Integer
‘Retrieve ID and Title of all available Output Vectors... rc = od.GetTitleIDList(False, 0, 0, Count, ID, Title) ‘ Display list in cells of a spreadsheet................. For Row = 1 To Count Worksheets(1).Cells(Row, 1).Value = ID(Row - 1) Worksheets(1).Cells(Row, 2).Value = Title(Row - 1) Next Row
|
Теперь как я пытаюсь это использовать.
| Код | int count; SAFEARRAY *TitleArray; SAFEARRAY *IDArray; BSTR str; TitleArray=SafeArrayCreateVector(VT_BSTR,0,9); IDArray=SafeArrayCreateVector(VT_I4,0,9); if(TitleArray==0)return 0; if(IDArray==0)return 0; if(pEntity->GetTitleIDList(true,0,0, &count, (VARIANT*) IDArray, (VARIANT*) TitleArray)==-1){ for (long i=0; i<count;i++){ if(SafeArrayGetElement(TitleArray,&i,&str){ MessageBox(0,str,str,0); // в этом месте планировалось вызвать SendMessage(hList, LB_ADDSTRING,0, (LPARAM)str); } } }
|
В сообщении MessageBox выводятся иероглифы вместо строк на английском языке. пробовал использовать VARIANT
| Код | VARIANT ListTitle int count; SAFEARRAY *TitleArray; SAFEARRAY *IDArray; BSTR str; TitleArray=SafeArrayCreateVector(VT_BSTR,0,9); IDArray=SafeArrayCreateVector(VT_I4,0,9); if(TitleArray==0)return 0; if(IDArray==0)return 0; ListTitle.vt=VT_ARRAY|VT_BSTR; ListTitle.parray=TitleArray; if(pEntity->GetTitleIDList(true,0,0, &count, (VARIANT*) IDArray, &ListTitle)==-1){ for (long i=0; i<count;i++){ //тут пока не понятно как из VARIANT ListTitle извлечь массив строк и вывести их хотя бы в MessageBox } } }
|
Подскажите в чём моя ошибка и как лучше исправить? |