wxDev-C++ 7.3.1.3 DLL funcitions create / include

Hello,

sorry for my English. I'm not a native speeker.

I try to program with the free compiler wxDev-C++ 7.3.1.3 a DLL function and include this function in a >C Console Application<. My knowledge in programming Windows applications is even less.

I'll be very happy if someone correct my example files and load up a correct version together with describing the right attitudes of the compiler.
I've written my questions with numbers in the code snippets. Regard to the question numbers in your answers, please. I need to programm DLL-functions in C for wrapping functions of other DLL functions which I'd like to use in LabVIEW. I've designed the German LabVIEW tutorials: http://www.fu-net.de/

Here are the example files of the DLL. They are on my hard drive in the folder

..\projects\DLL_test\dll.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#ifndef _DLL_H_
#define _DLL_H_

#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */

/* 3. Wy is here DLLIMPORT and not DLLEXPORT for the function >void HelloWorld(void)< which is defined in dllmain.c ? */
                           
DLLIMPORT void HelloWorld (void); 

/* Declaration of the DLL-function add2num() :*/
extern __declspec(dllexport) __stdcall double add2num(double a, double b);

#endif /* _DLL_H_ */ 



..\projects\DLL_test\dllmain.c:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

DLLIMPORT void HelloWorld ()    /* Created by wxDev-C++                    */
{                               /* 1. For what is this funciton necessary? */
    MessageBox (0, "Hello World from DLL!\n", "Hi", MB_ICONINFORMATION);
}

/*----- "own" DLL-function out of CPPDLL-Tutorial by VitalDragon ---*/

BOOL APIENTRY DllMain (HINSTANCE hInst     /* Library instance handle. */ ,
                       DWORD reason        /* Reason this function is being called. */ ,
                       LPVOID reserved     /* Not used. */ )
{
    /* Created by wxDev-C++ automatically               */
    /* For what is the switch() construction necessary? */
    switch (reason)
    {
      case DLL_PROCESS_ATTACH:
        break;

      case DLL_PROCESS_DETACH:
        break;

      case DLL_THREAD_ATTACH:
        break;

      case DLL_THREAD_DETACH:
        break;
    }

    /* Returns TRUE on success, FALSE on failure */
    return TRUE;
}


/* Definition of DLL-Function add2num() */
extern __declspec(dllexport) __stdcall double add2num(double a, double b)
{
    return a+b;
}


Call of the DLL-Function add2num() in main.c:
..\projects\DLL_Aufruf\main.c:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <stdio.h>
#include <stdlib.h>

#include "..\DLL_test\dll.h"

extern __stdcall double add2num(double a, double b); /* DLL function add2num() */

int main(int argc, char *argv[])
{
  double num1, num2, erg;
  
  num1= num2= erg= 0,0;
  printf("Put in two numbers, please. The numbers will be added\n");
  printf("Number 1, please: ");
  scanf("%lf", &num1);
  printf("Number 2, please:");
  scanf(" %lf", &num2);
  /* 5. How do I call the DLL function double add2num(double, double); ? */
  /* 5.1. I think there are two ways: static call or                     */
  /* 5.5  dynamic call in the running programm,                          */
  /* erg= add2num(num1, num2);  <-- where has I to place __declspec (dllimport) ? */
  erg= add2num(num1, num2);
  printf(" %lf + %lf= %lf\n\n", num1, num2, erg);
  system("PAUSE");	
  return 0;
}

Topic archived. No new replies allowed.