Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

927 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