Solved

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

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
message box in access 4 52
vb6 connector to mongodb 2 144
Exit a vb6 apps when a calling it apps closes 15 58
Recommendation vb6 to vb.net or others 14 210
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

730 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