Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 1997-04-01
2
Medium Priority
?
362 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 300 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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

721 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