name of library specified in importlib() not apearing as nemaspace prefix in generated header 
Author Message
 name of library specified in importlib() not apearing as nemaspace prefix in generated header

Hi all,

I have been stuck on this problem for two days now. Could anyone
please help?

I need to use the _Collection interface from msvbvm60.dll as the
datatype for a property in my interface. My goes code goes like this:

TestProject.idl
---------------

//misc code

library DPSSYSTEMVCLib
{
        importlib("stdole32.tlb");
        importlib("stdole2.tlb");
        importlib("C:\\WINNT\\System32\\msvbvm60.dll");

//misc code

interface IRSCollection : IDispatch
        {

                [propget, id(2), helpstring("property Col")] HRESULT Col([out,
retval] _Collection** pVal);
                [propputref, id(2), helpstring("property Col")] HRESULT Col([in]
_Collection* newVal);

//misc code

stdafx.h
--------

This file gets included in all the necessary places and it is here
that I am importing msvbvm60.dll like so:

#import "C:\WINNT\System32\msvbvm60.dll" rename("RGB", "vbRGB")
rename("EOF" , "vbEOF")

The problem is as follows:

If I rewrite the #import with the no_namespace attribute, everything
works fine. But if I leave it without the no_namespace declaration
(because I am importing other typelibs as well that cause namespace
collicsions), I make the following changes in the code:

1. everywhere that _Collection appears in the generated C++ code, I
prefix it with "VBA::" which is the namespace generated automatically
for msvbvm60.dll during #import.
2. In IDL, I prefix _Collection* with "VBA.". Again VBA is the library
name specified in importlib(). IDL compiles fine.

Somehow, I can't prefix "_Collection" in an autogenerated file
TestProject.h. Unfortunately, I cannot manually edit this file (as
opposed to other.cpp and .h files in trhe project) because it is
regenerated EVERY TIME the project is compiled. So I get the following
error (among others):

c:\program files\microsoft visual
studio\vc98\atl\include\atlcom.h(1827) : error C2259:
'CComObject<class CRSCollection>' : cannot instantiate abstract class
due to following members:
        c:\program files\microsoft visual
studio\vc98\atl\include\atlcom.h(1823) : while compiling
class-template member function 'long __stdcall ATL::CComCreator<class
ATL::CComObject<class CRSCollection> >::CreateInstance(void *,const
struct _GUID
 &,void ** )'
c:\program files\microsoft visual
studio\vc98\atl\include\atlcom.h(1827) : warning C4259: 'long
__stdcall IRSCollection::get_Col(struct _Collection ** )' : pure
virtual function was not defined
        c:\vss\fps\vc++ projects\dpssystemvc\dpssystemvc.h(87) : see
declaration of 'get_Col'
        c:\program files\microsoft visual
studio\vc98\atl\include\atlcom.h(1823) : while compiling
class-template member function 'long __stdcall ATL::CComCreator<class
ATL::CComObject<class CRSCollection> >::CreateInstance(void *,const
struct _GUID
 &,void ** )'

Is there a clean solution to the problem, so that i can #import
libraries, as well as use types from them in my idl such that the
project compiles successfully, other than the following possible
hacks:

1. use IDispatch* instead of _Collection* in IDL.
2. #import the dll using no_namespace but rename _Collection interface
(using rename attribute in #import statement) so that it doesn't
collide with another interface of the same name declared in another
imported typelib (e.g. both msado15.dll and msvbvm60.dll contain
(different) interfaces named "_Collection".

Thanks a lot for your help.



Mon, 16 Feb 2004 01:16:04 GMT  
 name of library specified in importlib() not apearing as nemaspace prefix in generated header
Hello,

Actually this is a problem caused by the way MIDL and C++ parse importlib
and #import. I would like to suggest a workaround for this problem:

In Stdafx.h, add following:

#import "F:\WINNT\System32\msvbvm60.dll"  rename("RGB", "vbRGB")
rename("EOF" , "vbEOF")
typedef VBA::_Collection _Collection;

Since the header files are included like the following:

#include "Stdafx.h"
#include "TestProject.h"

The typedef will declare the _Collection type in the generated header file.

Hope this is useful for you.

Regards,
Woody



Mon, 16 Feb 2004 15:47:50 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Data Source Name Not Found and No Default Driver Specified

2. Data source name not found and no default driver specified

3. Data source name not found and no default driver specified

4. ATL, importlib attribute, library attribute, ADO

5. Prefixing names with an underscore

6. When is it ok to prefix names with an underscore

7. using prefix letters for variable naming coding style.

8. Prefix of variable names

9. importlib does not import enum type

10. Specifying default name for saving file in client browser

11. Bad crash when wrong DSN name specified

12. Specifying a Different Name for DEBUG Targets

 

 
Powered by phpBB® Forum Software