Solved

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

Posted on 1997-04-01
2
355 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
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now