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?
468572Asked:
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.

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
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

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

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
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
Web Languages and Standards

From novice to tech pro — start learning today.