[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 325
  • Last Modified:

Use VC++6.0 DLL in BC++5.2

Is it possible to build DLL in VC++6.0 and make it accessible by BC++5.2? Could you provide an example?
0
468572
Asked:
468572
  • 4
  • 2
1 Solution
 
AlexVirochovskyCommented:
Can ,it is possible. Dll is standart thing, and no matter
how you build it. But: Format of Debug information,
that can be in Dll is different in VC and BC.
This means, that you can't debug this Dll in symbol mode!
Example: standart example of using Dll ("SCPWDLL.DLL")

   const char szcScpWDLLName [] = "SCPWDLL.DLL"; //
   const char szcFuncName [] = "VERPROT";        //
   TModule  *ScpDLLModule;

   ScpDLLModule = new TModule ( szcScpWDLLName, TRUE);
   int FAR PASCAL ( *VerProtFun )( char * );
   ( FARPROC ) VerProtFun = ScpDLLModule ->
                      GetProcAddress ( szcFuncName );
   if ( VerProtFun )
     {
     }
   free (ScpDLLModule);
0
 
468572Author Commented:
This doesn't work for me.
See following sample code.
//DLL built in VC++6.0
//---mydll.cpp---
#include "stdafx.h"
#include "mydll.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#pragma data_seg("SharedMemory")
   int data = 0;
#pragma data_seg()

DLLexport void WINAPI IncrementCounter()
{
      char text[80];
      sprintf(text, "New counter value of %d.", ++data);
      ::MessageBox(0,text,"",MB_OK);
}

//---mydll.h---
#if !defined(AFX_COUNTERDLL_H__A45E4A6E_A79A_11D1_887F_D42B07C10710__INCLUDED_)
#define AFX_COUNTERDLL_H__A45E4A6E_A79A_11D1_887F_D42B07C10710__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#ifndef __AFXWIN_H__
      #error include 'stdafx.h' before including this file for PCH
#endif


#define DLLexport      __declspec( dllexport )
DLLexport void WINAPI IncrementCounter();

#endif // !defined(AFX_COUNTERDLL_H__A45E4A6E_A79A_11D1_887F_D42B07C10710__INCLUDED_)

//---the code I used in BC++5.2 to call the function in mydll.dll
          TModule  *ScpDLLModule = new TModule ( "mydll.dll", TRUE);
          void FAR PASCAL ( *entry )( void );
          ( FARPROC ) entry = ScpDLLModule ->GetProcAddress( "IncrementCounter" );
          if ( entry )
            {
              entry();
            }
          free (ScpDLLModule);

I always get entry == NULL.

I also tried to use implib in BC5.2 to create mydll.lib and link it to my exe but I got "unresolved external 'IncrementCounter()' referenced from ......."

0
 
AlexVirochovskyCommented:
By you data, after VC name of programm othen (not IncrementCounter). Can be "_" in Begin or case.
 For know this name you can use tdump programm,that
 print REAL exported name.
something as:
tdump mydll.dll my.lst

0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
468572Author Commented:
I have found the answer at the following inprise web site.
http://www.borland.com/devsupport/borlandcpp/ti_list/TI3242.html
0
 
AlexVirochovskyCommented:
468572! Thank for URL with this article, very interesting,
but may idea exectly as i think: VC generate name of Function other, than original. And I think, that best
way is not make def files, as in anm article, but(as i wrote)
1.use tdump for detect REAL name.
2. Use this real name in line
          ( FARPROC ) entry = ScpDLLModule ->GetProcAddress( "@IncrementCounter32" );
//for example
Best Regards, Alex
0
 
AlexVirochovskyCommented:
468572, you must or cancel you Q or accept my Reply,
becouse, as i think, discussion is over!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now