How Can I get string list from interface? 
Author Message
 How Can I get string list from interface?

I am new to ATL..help me,please !_!

Now,I have two component one is displaying component
another is read ini file to form the category string list.

I want the those string can display on my ap.
so I let component B have a interface.

[id(12), helpstring("method getTemCat")] HRESULT getTemCat([in,string]
queryStr , [in] long icunt , [out] long* pcunt, [out , size_is( icunt ) ]
BSTR* sarray);

Am I right!? but my component A is always error to use the interface form
component B.
Can I write the interface in another way??

[id(12), helpstring("method getTemCat")] HRESULT getTemCat([out] long*
pcunt, [out , size_is( *pcunt ) ] String sarray[]);



Sun, 29 Feb 2004 10:25:39 GMT  
 How Can I get string list from interface?
I am new to ATL..help me,please !_!

Now,I have two component one is displaying component
another is read ini file to form the category string list.

I want the those string can display on my ap.
so I let component B have a interface.

[id(12), helpstring("method getTemCat")] HRESULT getTemCat([in,string]
queryStr , [in] long icunt , [out] long* pcunt, [out , size_is( icunt ) ]
BSTR* sarray);

Am I right!? but my component A is always error to use the interface form
component B.
Can I write the interface in another way??

[id(12), helpstring("method getTemCat")] HRESULT getTemCat([out] long*
pcunt, [out , size_is( *pcunt ) ] String sarray[]);



Sun, 29 Feb 2004 10:25:21 GMT  
 How Can I get string list from interface?
Hi,

To get a list of string from the COM component, you can write the interface
in IDL this way.

//IDL
HRESULT getmystrings([out] SAFEARRAY(BSTR)* pr);

//callee
STDMETHODIMP CMyObj::getmystrings(SAFEARRAY** pr)
{
        // TODO: Add your implementation code here
        ATLASSERT(pr);
        *pr=SafeArrayCreateVector(VT_BSTR,0,3);
        ATLASSERT(*pr);

        long ndex;
        ndex=0;
        BSTR bstr1=::SysAllocString(L"test1");
        SafeArrayPutElement(*pr,&ndex,bstr1);
        ndex=1;
        BSTR bstr2=::SysAllocString(L"test2");
        SafeArrayPutElement(*pr,&ndex,bstr1);
        ndex=2;
        BSTR bstr3=::SysAllocString(L"test3");
        SafeArrayPutElement(*pr,&ndex,bstr1);

Quote:
}

//caller
        SAFEARRAY* sarray;
        m_ptr->getmystrings(&sarray);

Thanks,
Kelton



Sun, 29 Feb 2004 15:01:20 GMT  
 How Can I get string list from interface?
Hi,

To get a list of string from the COM component, you can write the interface
in IDL this way.

//IDL
HRESULT getmystrings([out] SAFEARRAY(BSTR)* pr);

//callee
STDMETHODIMP CMyObj::getmystrings(SAFEARRAY** pr)
{
        // TODO: Add your implementation code here
        ATLASSERT(pr);
        *pr=SafeArrayCreateVector(VT_BSTR,0,3);
        ATLASSERT(*pr);

        long ndex;
        ndex=0;
        BSTR bstr1=::SysAllocString(L"test1");
        SafeArrayPutElement(*pr,&ndex,bstr1);
        ndex=1;
        BSTR bstr2=::SysAllocString(L"test2");
        SafeArrayPutElement(*pr,&ndex,bstr1);
        ndex=2;
        BSTR bstr3=::SysAllocString(L"test3");
        SafeArrayPutElement(*pr,&ndex,bstr1);

Quote:
}

//caller
        SAFEARRAY* sarray;
        m_ptr->getmystrings(&sarray);

Thanks,
Kelton



Sun, 29 Feb 2004 15:02:49 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Getting a String Out of a String Stream (ostringstream)

2. Determining what canned preprocessor symbols are available

3. Beginner [Q] Using Canned File Open/Save dialog

4. Help with compiling a "canned" program

5. Canned Dialogs

6. Need help getting interface parameter for dialog

7. Getting marshalled interface from 2nd out-of-proc server

8. Getting the C++ class from the Interface pointer

9. Interface Class member variable Ptr getting NULL after being SET

10. Getting the a pointer to IResponse Interface

11. getting interface pointer from another process..

12. Getting object from the interface

 

 
Powered by phpBB® Forum Software