Creating a ATL Library class

Greetings, I am new to creating ATL libs and have a question about the following code.  I am converting this from a VC 6 dll to a VC 6 ATL dll.  So I can use it with C#.

The library will consist of the 5 functions listed below.  Only two will be called by the client, SetDocument and the CallJScript function.  The other will be used by the library internaly.  Using the Class View wizard and chosing Add Method.  How do I declare the internal functions vs. the external (public) functions.  

Also could someone please help me with the IDL statements.  Especially for CStringArray and do I reference it the same way in the library function?  

      bool SetDocument(IDispatch* pDisp);
      bool CallJScript(const CString strFunc,const CStringArray& paramArray,CComVariant* pVarResult = NULL);

      LPDISPATCH GetHtmlDocument() const;
      const CString GetLastError() const;

Thanks in advance!!!
cdoggettAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jkrCommented:
You can't use MFC classes as arguments in IDL. I'd suggest to replace that by the proper types, such as 'BSTRs' or a variant of type 'BSTR'. 'strings' are also possible, e.g.

    bool SetDocument(LPDISPATCH pDisp);
    bool CallJScript([in, string] PCHAR  strFunc,[in, ref, size_is(m)] PCHAR paramArray, int m, [out, optional] VARIANT* pVarResult);

    LPDISPATCH GetHtmlDocument() const;
    [unique] char * GetLastError() const;
cdoggettAuthor Commented:
Excellent, one question though, how do I use paramArray though.  I noticed the extra argument m which delcares the size.  Could you show me a small code sample??    Thanks and Happy Forth!

jkrCommented:
You'll need to put the pointers you receive into that CStringArray, e.g. assuming that the generated stub code is

bool CallJScript(PCHAR  strFunc,PCHAR* paramArray, int m,  VARIANT* pVarResult = NULL)
{
CStringArray as;
as.SetSize(m);

    for (int i = 0; i < m; ++i) cs.SetAt(i, paramArray[i]);

}

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cdoggettAuthor Commented:
When I used PCHAR as you suggested I got a compiler error

error MIDL2025 : syntax error : expecting a type specification near "PCHAR"

[id(2), helpstring("method CallJScript")] HRESULT CallJScript([in] PCHAR strFunc, [in, ref, size_is(m)] PCHAR paramArray, [in] int m, [out, optional] VARIANT* pVarResult);

I changed it to use BSTR and it compiled OK.  Which is better?  If I go with BSTR, will that change the usage of the code below you suggested??

CStringArray as;
as.SetSize(m);

    for (int i = 0; i < m; ++i) cs.SetAt(i, paramArray[i]);

Thanks
jkrCommented:
Sorry, almost missed that...

Actually, 'PCHAR' (as one of the 'Win32 Simple Data Types') should be defined in 'winnt.h' - that's odd, MIDL should definitely know it. In fact, both will/should work, BSTRs lacking the advantage of having the marshalling layer provide a real 'char*'
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.