Creating c dll calling vb ActiveX dll 
Author Message
 Creating c dll calling vb ActiveX dll

Hi,

I'm trying to compile a dll using Visual C++ 6.0, with references to a
Visual Basic 6.0 ActiveX dll.

Here is the code

#include "cbridge.h"

#include "AstraExt.h"

extern /*[[integer out]]*/ BOOL __declspec(dllexport) Initialise
();

int __declspec(dllexport) __cdecl
RMDLLInitialise
   (
      char *_rmdll_Name,
      short _rmdll_ArgCount,
      ARGUMENT_ENTRY _rmdll_Args[],
      short _rmdll_State,
      HWND _rmdll_hCobolWnd,
      RUNTIME_CALLS_TABLE *_rmdll_RtCall
   )
{
   BOOL __RETURN__Initialise;   BOOL *__ptr____RETURN__Initialise =
&__RETURN__Initialise;
   CONV_TABLE *_rmdll_ConvTable;

   if( !_rmdll_RtCall->pConversionStartup( _rmdll_ArgCount,
&_rmdll_ConvTable, _rmdll_Name, 0x700 ) )
      return( RM_STOP );

   if
      (!_rmdll_RtCall->pCobolToInteger
            ( _rmdll_ArgCount,
               -1,
               _rmdll_Args,
               (0 | PF_RETURN_VALUE),
               (0),
               (0),
               (void **) &__ptr____RETURN__Initialise,
               (0),
               (0),
               sizeof( __RETURN__Initialise )
            )
      )
   {
      _rmdll_RtCall->pConversionCleanup( _rmdll_ArgCount,
_rmdll_ConvTable );
      return( RM_STOP );
   }

   __RETURN__Initialise =
      Initialise
         ();

   if
      (
         !_rmdll_RtCall->pIntegerToCobol
            (
               _rmdll_ArgCount,
               -1,
               _rmdll_Args,
               (0 | PF_OUT | PF_RETURN_VALUE),
               (0),
               (void *) __ptr____RETURN__Initialise,
               (0),
               (0),
               sizeof( __RETURN__Initialise )
            )
      )
   {
      _rmdll_RtCall->pConversionCleanup( _rmdll_ArgCount,
_rmdll_ConvTable );
      return( RM_STOP );
   }

   _rmdll_RtCall->pConversionCleanup( _rmdll_ArgCount, _rmdll_ConvTable );

   return( RM_FND );

Quote:
}

extern /*[[integer out]]*/ BOOL __declspec(dllexport) __OpenFile
(
   /*[[address]]*/ LPCTSTR FileName
);

int __declspec(dllexport) __cdecl
RMDLL__OpenFile
   (
      char *_rmdll_Name,
      short _rmdll_ArgCount,
      ARGUMENT_ENTRY _rmdll_Args[],
      short _rmdll_State,
      HWND _rmdll_hCobolWnd,
      RUNTIME_CALLS_TABLE *_rmdll_RtCall
   )
{
   BOOL __RETURN____OpenFile;   BOOL *__ptr____RETURN____OpenFile =
&__RETURN____OpenFile;
   LPCTSTR FileName;
   CONV_TABLE *_rmdll_ConvTable;

   if( !_rmdll_RtCall->pConversionStartup( _rmdll_ArgCount,
&_rmdll_ConvTable, _rmdll_Name, 0x700 ) )
      return( RM_STOP );

   if
      (
         !_rmdll_RtCall->pCobolToInteger
            (
               _rmdll_ArgCount,
               -1,
               _rmdll_Args,
               (0 | PF_RETURN_VALUE),
               (0),
               (0),
               (void **) &__ptr____RETURN____OpenFile,
               (0),
               (0),
               sizeof( __RETURN____OpenFile )
            )
      )
   {
      _rmdll_RtCall->pConversionCleanup( _rmdll_ArgCount,
_rmdll_ConvTable );
      return( RM_STOP );
   }

   if
      (
         !_rmdll_RtCall->pCobolDescriptorAddress
            (
               _rmdll_ArgCount,
               0,
               _rmdll_Args,
               (0),
               (void **) &FileName
            )
      )
   {
      _rmdll_RtCall->pConversionCleanup( _rmdll_ArgCount,
_rmdll_ConvTable );
      return( RM_STOP );
   }

   __RETURN____OpenFile =
      __OpenFile
         (
            FileName
         );

   if
      (
         !_rmdll_RtCall->pIntegerToCobol
            (
               _rmdll_ArgCount,
               -1,
               _rmdll_Args,
               (0 | PF_OUT | PF_RETURN_VALUE),
               (0),
               (void *) __ptr____RETURN____OpenFile,
               (0),
               (0),
               sizeof( __RETURN____OpenFile )
            )
      )
   {
      _rmdll_RtCall->pConversionCleanup( _rmdll_ArgCount,
_rmdll_ConvTable );
      return( RM_STOP );
   }

   _rmdll_RtCall->pConversionCleanup( _rmdll_ArgCount, _rmdll_ConvTable );

   return( RM_FND );

Quote:
}

extern /*[[integer out]]*/ BOOL __declspec(dllexport) __CloseFile
(
);

int __declspec(dllexport) __cdecl
RMDLL__CloseFile
   (
      char *_rmdll_Name,
      short _rmdll_ArgCount,
      ARGUMENT_ENTRY _rmdll_Args[],
      short _rmdll_State,
      HWND _rmdll_hCobolWnd,
      RUNTIME_CALLS_TABLE *_rmdll_RtCall
   )
{
   BOOL __RETURN____CloseFile;   BOOL *__ptr____RETURN____CloseFile =
&__RETURN____CloseFile;
   CONV_TABLE *_rmdll_ConvTable;

   if( !_rmdll_RtCall->pConversionStartup( _rmdll_ArgCount,
&_rmdll_ConvTable, _rmdll_Name, 0x700 ) )
      return( RM_STOP );

   if
      (
         !_rmdll_RtCall->pCobolToInteger
            (
               _rmdll_ArgCount,
               -1,
               _rmdll_Args,
               (0 | PF_RETURN_VALUE),
               (0),
               (0),
               (void **) &__ptr____RETURN____CloseFile,
               (0),
               (0),
               sizeof( __RETURN____CloseFile )
            )
      )
   {
      _rmdll_RtCall->pConversionCleanup( _rmdll_ArgCount,
_rmdll_ConvTable );
      return( RM_STOP );
   }

   __RETURN____CloseFile =
      __CloseFile
         (

         );

   if
      (
         !_rmdll_RtCall->pIntegerToCobol
            (
               _rmdll_ArgCount,
               -1,
               _rmdll_Args,
               (0 | PF_OUT | PF_RETURN_VALUE),
               (0),
               (void *) __ptr____RETURN____CloseFile,
               (0),
               (0),
               sizeof( __RETURN____CloseFile )
            )
      )
   {
      _rmdll_RtCall->pConversionCleanup( _rmdll_ArgCount,
_rmdll_ConvTable );
      return( RM_STOP );
   }

   _rmdll_RtCall->pConversionCleanup( _rmdll_ArgCount, _rmdll_ConvTable );

   return( RM_FND );

Quote:
}

extern /*[[integer out]]*/ BOOL __declspec(dllexport) DeInitialise
(
);

int __declspec(dllexport) __cdecl
RMDLLDeInitialise
   (
      char *_rmdll_Name,
      short _rmdll_ArgCount,
      ARGUMENT_ENTRY _rmdll_Args[],
      short _rmdll_State,
      HWND _rmdll_hCobolWnd,
      RUNTIME_CALLS_TABLE *_rmdll_RtCall
   )
{
   BOOL __RETURN__DeInitialise;   BOOL *__ptr____RETURN__DeInitialise =
&__RETURN__DeInitialise;
   CONV_TABLE *_rmdll_ConvTable;

   if( !_rmdll_RtCall->pConversionStartup( _rmdll_ArgCount,
&_rmdll_ConvTable, _rmdll_Name, 0x700 ) )
      return( RM_STOP );

   if
      (
         !_rmdll_RtCall->pCobolToInteger
            (
               _rmdll_ArgCount,
               -1,
               _rmdll_Args,
               (0 | PF_RETURN_VALUE),
               (0),
               (0),
               (void **) &__ptr____RETURN__DeInitialise,
               (0),
               (0),
               sizeof( __RETURN__DeInitialise )
            )
      )
   {
      _rmdll_RtCall->pConversionCleanup( _rmdll_ArgCount,
_rmdll_ConvTable );
      return( RM_STOP );
   }

   __RETURN__DeInitialise =
      DeInitialise
         (

         );

   if
      (
         !_rmdll_RtCall->pIntegerToCobol
            (
               _rmdll_ArgCount,
               -1,
               _rmdll_Args,
               (0 | PF_OUT | PF_RETURN_VALUE),
               (0),
               (void *) __ptr____RETURN__DeInitialise,
               (0),
               (0),
               sizeof( __RETURN__DeInitialise )
            )
      )
   {
      _rmdll_RtCall->pConversionCleanup( _rmdll_ArgCount,
_rmdll_ConvTable );
      return( RM_STOP );
   }

   _rmdll_RtCall->pConversionCleanup( _rmdll_ArgCount, _rmdll_ConvTable );

   return( RM_FND );

Quote:
}

This is the AstraExt.h

        #ifdef __cplusplus
        extern "C"
        #endif

        BOOL __declspec(dllexport) Initialise();

        BOOL __declspec(dllexport) __OpenFile(LPCTSTR);

        BOOL __declspec(dllexport) __CloseFile();

        BOOL __declspec(dllexport) DeInitialise();

and here are the linking erorrs i'm am currently getting

        AstraExt.obj : error LNK2001: unresolved external symbol

        AstraExt.obj : error LNK2001: unresolved external symbol

        AstraExt.obj : error LNK2001: unresolved external symbol

        AstraExt.obj : error LNK2001: unresolved external symbol

        Debug/test.dll : fatal error LNK1120: 4 unresolved externals

Can anyone help in fixing these errors, I have searched the newsgroups and
found postings on similar topics but the answers do not solve my problem.

TIA

Andy



Sat, 10 Sep 2005 20:37:35 GMT  
 Creating c dll calling vb ActiveX dll

Quote:
> Can anyone help in fixing these errors, I have searched the newsgroups and
> found postings on similar topics but the answers do not solve my problem.

Here's some more information on possible problems.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcco...
ML/lnk2001.asp

It sounds like the project configuration settings do not have enough
information to tell the linker where to find the VB DLL.

--
Eric Jarvi, Microsoft Visual C++ Team
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm



Tue, 13 Sep 2005 04:17:13 GMT  
 Creating c dll calling vb ActiveX dll
Thanks for that info, unfortunatley my c/c++ knowledge is limited, this dll
is going to be called from cobol. Can you provide any more information.

Thanks

Andy Smith



Quote:
> > Can anyone help in fixing these errors, I have searched the newsgroups
and
> > found postings on similar topics but the answers do not solve my
problem.

> Here's some more information on possible problems.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcco...
Quote:
> ML/lnk2001.asp

> It sounds like the project configuration settings do not have enough
> information to tell the linker where to find the VB DLL.

> --
> Eric Jarvi, Microsoft Visual C++ Team
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> Use of included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm



Tue, 13 Sep 2005 16:58:45 GMT  
 Creating c dll calling vb ActiveX dll

Quote:

> I'm trying to compile a dll using Visual C++ 6.0, with references to a
> Visual Basic 6.0 ActiveX dll.

[...]

I'm assuming this header is describing functions from the VB ActiveX
dll?

Quote:
> This is the AstraExt.h

>         #ifdef __cplusplus
>         extern "C"
>         #endif

>         BOOL __declspec(dllexport) Initialise();

>         BOOL __declspec(dllexport) __OpenFile(LPCTSTR);

>         BOOL __declspec(dllexport) __CloseFile();

>         BOOL __declspec(dllexport) DeInitialise();

> and here are the linking erorrs i'm am currently getting

>         AstraExt.obj : error LNK2001: unresolved external symbol

>         AstraExt.obj : error LNK2001: unresolved external symbol

>         AstraExt.obj : error LNK2001: unresolved external symbol

>         AstraExt.obj : error LNK2001: unresolved external symbol

>         Debug/test.dll : fatal error LNK1120: 4 unresolved externals

A VB ActiveX dll does not export its functions like a normal dll.
If you want to access it, you must do so through COM.  The easiest
way to do this is with #import.  Rather than calling individual
functions, you'll have to work through coclass instances.

It is possible to use certain tools to make a VB ActiveX dll export
functions like a normal dll.  If this is what you're doing, you need
to change the "dllexport" above to "dllimport" and link against the
export library (same name as the dll but with a .lib extension).

--
Craig Powers
MVP - Visual C++



Tue, 13 Sep 2005 22:33:14 GMT  
 Creating c dll calling vb ActiveX dll


Quote:

> > I'm trying to compile a dll using Visual C++ 6.0, with references to a
> > Visual Basic 6.0 ActiveX dll.

> [...]

> I'm assuming this header is describing functions from the VB ActiveX
> dll?

> > This is the AstraExt.h

> >         #ifdef __cplusplus
> >         extern "C"
> >         #endif

> >         BOOL __declspec(dllexport) Initialise();

> >         BOOL __declspec(dllexport) __OpenFile(LPCTSTR);

> >         BOOL __declspec(dllexport) __CloseFile();

> >         BOOL __declspec(dllexport) DeInitialise();

> > and here are the linking erorrs i'm am currently getting

> >         AstraExt.obj : error LNK2001: unresolved external symbol

> >         AstraExt.obj : error LNK2001: unresolved external symbol

> >         AstraExt.obj : error LNK2001: unresolved external symbol

> >         AstraExt.obj : error LNK2001: unresolved external symbol

> >         Debug/test.dll : fatal error LNK1120: 4 unresolved externals

> A VB ActiveX dll does not export its functions like a normal dll.
> If you want to access it, you must do so through COM.  The easiest
> way to do this is with #import.  Rather than calling individual
> functions, you'll have to work through coclass instances.

I have very little control on the method used to call these functions as it
is a utility to provide an interface between cobol and dll's.

Quote:
> It is possible to use certain tools to make a VB ActiveX dll export
> functions like a normal dll.  If this is what you're doing, you need
> to change the "dllexport" above to "dllimport" and link against the
> export library (same name as the dll but with a .lib extension).

Do you know what tools are available or how these tools work to export the
functions.

Thanks

- Show quoted text -

Quote:
> --
> Craig Powers
> MVP - Visual C++



Fri, 16 Sep 2005 16:55:38 GMT  
 Creating c dll calling vb ActiveX dll

Quote:



> > It is possible to use certain tools to make a VB ActiveX dll export
> > functions like a normal dll.  If this is what you're doing, you need
> > to change the "dllexport" above to "dllimport" and link against the
> > export library (same name as the dll but with a .lib extension).

> Do you know what tools are available or how these tools work to export the
> functions.

I know they exist.  I don't know what they are, nor exactly how they
work.  If you ask in a VB group (e.g. vb.general.discussion), someone
there should be able to help you.

--
Craig Powers
MVP - Visual C++



Fri, 16 Sep 2005 22:38:08 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Atl NT service calling VB ActiveX dll had problem when clean-up

2. How do you call VB ActiveX DLL functions from VC

3. Call/Use VB ActiveX Dll in Visual C

4. calling vb activex dll

5. How can I call a VB ActiveX dll from VC++

6. Calling a VB ActiveX DLL

7. call vb ActiveX DLL in VC++

8. Help - Calling ActiveX DLL function from VB and C++ returns different values

9. How to call a VB ActiveX DLL from VC++

10. Can call a VB ActiveX DLL's method using Invoke, but not directly

11. newbie question - VB ActiveX DLL calling

12. MFC app calling VB ActiveX DLL

 

 
Powered by phpBB® Forum Software