Solved

MSVC++4.2 DLL and VB4.0 32Bit?

Posted on 1997-04-01
2
361 Views
Last Modified: 2011-04-14
I need the MINIMUM code to create a dll with a function in MSVC++ 4.2 that I can call from VB4.0 32 bit. I have received many samples before. Either I get "Bad Calling Conversion" or "Error Loading DLL" or "Function not found in DLL". MSVC++4.2 doesn't use .DEF. Can somebody send me a little test or something?
Thanks
0
Comment
Question by:marquez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:marquez
ID: 1424940
Adjusted points to 100
0
 
LVL 1

Accepted Solution

by:
PC-Alex earned 100 total points
ID: 1424941
marquez,
this is my C++ 4.2 source, it works:

#include "stdafx.h"

HINSTANCE hDLL;

BOOL WINAPI DllEntryPoint(
    HINSTANCE hinstDLL,      DWORD fdwReason, LPVOID lpvReserved )
{
      hDLL = hinstDLL;

      switch(fdwReason)
      {
      case DLL_PROCESS_ATTACH:
            break;
      case DLL_THREAD_ATTACH:
            break;
      case DLL_THREAD_DETACH:
            break;
      case DLL_PROCESS_DETACH:
            break;
      }
      return(TRUE);
}

extern "C" __declspec(dllexport) void WINAPI func_name (double *param_by_reference)
{
    *param_by_reference = some_calculation;
}

Be sure to create a (MYDLL).DEF file that looks like:
################################################################
#; MYDLL.def : Declares the module parameters for the DLL.
#
#LIBRARY      "MYDLL"
#DESCRIPTION  'MYDLL Windows Dynamic Link Library'
#
#EXPORTS
#    func_name
#    func_name2
#    func_name3
#    ; Explicit exports can go here
#################################################################

Avoid result values of functions, make them void, it is sometimes
difficult. Call functions with ByRef parameters instead.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month9 days, 4 hours left to enroll

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question