1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Problem developping simple dll in vc++ 2008 express

Discussion in 'Software Development' started by newdev, Apr 30, 2012.

Thread Status:
Not open for further replies.
Advertisement
  1. newdev

    newdev Thread Starter

    Joined:
    Apr 29, 2012
    Messages:
    1
    I've developped a very simple dll and all seems to be ok at compilation time but I'm not able to use the exported function on VB project.
    Here the code:
    MyDll.h:
    #ifdef MYDLL_EXPORTS
    #define MYDLL_API __declspec(dllexport)
    #else
    #define MYDLL_API __declspec(dllimport)
    #endif
    // Questa classe esportata da MyDll.dll
    class MYDLL_API CMyDll {
    public:
    CMyDll(void);
    // TODO: aggiungere qui i metodi.
    };
    extern MYDLL_API int nMyDll;
    MYDLL_API int fnMyDll(void);
    MYDLL_API int fnCubeByVal(int);
    MYDLL_API void fnCubeByRef(int *);

    MyDll.cpp:
    #include"stdafx.h"
    #include"MyDll.h"

    // Esempio di variabile esportata
    MYDLL_API int nMyDll=0;
    // Esempio di funzione esportata.
    MYDLL_API int fnMyDll(void)
    {
    return 42;
    }
    MYDLL_API int fnCubeByVal(int data){
    return data * data * data;
    }
    MYDLL_API void fnCubeByRef(int *data){
    *data = *data * *data * *data;
    }
    // Costruttore di una classe esportata.
    // Vedere MyDll.h per la definizione della classe
    CMyDll::CMyDll()
    {
    return;
    }

    and here the simple code in vb:
    PublicClass Form1
    PrivateDeclareFunction fnCubeByVal Lib"MyDll.dll" (ByVal data AsInteger) AsInteger
    PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    TextBox1.Text = fnCubeByVal(5)
    EndSub
    End
    Class

    When I debuc the project I get the following error message:
    Eccezione first-chance di tipo 'System.EntryPointNotFoundException' in TestMyDll.exe

    Can someone help me?
    Thanks a lot!

    Tech Support Guy System Info Utility version 1.0.0.2
    OS Version: Microsoft Windows 7 Home Premium, Service Pack 1, 32 bit
    Processor: Intel(R) Core(TM)2 Duo CPU P7450 @ 2.13GHz, x64 Family 6 Model 23 Stepping 6
    Processor Count: 2
    RAM: 3066 Mb
    Graphics Card: NVIDIA GeForce G 105M, 512 Mb
    Hard Drives: C: Total - 466937 MB, Free - 146651 MB;
    Motherboard: Acer, JV50
    Antivirus: Norton Internet Security, Updated and Enabled
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1051398