472,378 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,378 software developers and data experts.

dll problem

Hello,

I am using Dev c++ to create a dll in c++ on windows xp pro. It provided me
with a template and I added a simple function to return an int as a test.
It compiled the dll ok and I added a reference to a Visual basic 6 project,
yet when I call it VB complains about run time error 453, "cant find dll
entry point 'funcname'". Can anybody show me what I am doing wrong, do I
need to create a definition file and if so how?

I have included the declaration in VB and the c++ code below:

Thanks for any help or advice.
Private Declare Function runme Lib "d:\c++programmingtest\\test.dll" () As
Integer
dll.h file:

#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 */
class DLLIMPORT DllClass
{
public:
DllClass();
virtual ~DllClass(void);
int runme(void);

private:

};

#endif /* _DLL_H_ */

dllmain.cpp file:

/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>

DllClass::DllClass()
{

}
DllClass::~DllClass ()
{

}

int DllClass::runme() {
return 9000;
}
BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ ,
DWORD reason /* Reason this function is being
called. */ ,
LPVOID reserved /* Not used. */ )
{
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;
}
Jul 17 '05 #1
6 5653
StdCall ???

On Tue, 20 Jan 2004 15:02:42 +0000 (UTC), "Jason"
<ja***********@btinternet.com> wrote:
Hello,

I am using Dev c++ to create a dll in c++ on windows xp pro. It provided me
with a template and I added a simple function to return an int as a test.
It compiled the dll ok and I added a reference to a Visual basic 6 project,
yet when I call it VB complains about run time error 453, "cant find dll
entry point 'funcname'". Can anybody show me what I am doing wrong, do I
need to create a definition file and if so how?

I have included the declaration in VB and the c++ code below:

Thanks for any help or advice.
Private Declare Function runme Lib "d:\c++programmingtest\\test.dll" () As
Integer
dll.h file:

#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 */
class DLLIMPORT DllClass
{
public:
DllClass();
virtual ~DllClass(void);
int runme(void);

private:

};

#endif /* _DLL_H_ */

dllmain.cpp file:

/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>

DllClass::DllClass()
{

}
DllClass::~DllClass ()
{

}

int DllClass::runme() {
return 9000;
}
BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ ,
DWORD reason /* Reason this function is being
called. */ ,
LPVOID reserved /* Not used. */ )
{
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;
}


Jul 17 '05 #2

This is where I get to answer my own question after much effort searching
the internet and piecing together the information:

I needed to declare this for getting a string into VB from Dev c++:

extern "C" __declspec( dllexport ) __stdcall char * Hello();

extern "C" __declspec( dllexport ) __stdcall char * Hello() {
//c++ code
return "dsjfkldsj\0";
}

In VB:
Private Declare Function Hello Lib "d:\c++programmingtest\\test.dll" () As
long

the long returned is now a pointer to a null-terminated string, use
copymemory to extract it, this website in the hexdump code as a nice
function to convert a long to a string:
http://www.mvps.org/vb/index2.html?samples.htm

This works better than what i was doing for returning an int:

extern "C" __declspec( dllexport ) __stdcall int runmefunc();

extern "C" __declspec( dllexport ) __stdcall int runmefunc() {
return runme();
}

everything else stays the same as below.

thanks to me in retrospect...

regards
jason

"Jason" <ja***********@btinternet.com> wrote in message
news:bu**********@titan.btinternet.com...
Hello,

I am using Dev c++ to create a dll in c++ on windows xp pro. It provided me with a template and I added a simple function to return an int as a test.
It compiled the dll ok and I added a reference to a Visual basic 6 project, yet when I call it VB complains about run time error 453, "cant find dll
entry point 'funcname'". Can anybody show me what I am doing wrong, do I
need to create a definition file and if so how?

I have included the declaration in VB and the c++ code below:

Thanks for any help or advice.
Private Declare Function runme Lib "d:\c++programmingtest\\test.dll" () As
Integer
dll.h file:

#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 */
class DLLIMPORT DllClass
{
public:
DllClass();
virtual ~DllClass(void);
int runme(void);

private:

};

#endif /* _DLL_H_ */

dllmain.cpp file:

/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>

DllClass::DllClass()
{

}
DllClass::~DllClass ()
{

}

int DllClass::runme() {
return 9000;
}
BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ , DWORD reason /* Reason this function is being called. */ ,
LPVOID reserved /* Not used. */ )
{
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;
}

Jul 17 '05 #3

"Jason" <ja***********@btinternet.com> wrote in message
news:bu**********@hercules.btinternet.com...

This works better than what i was doing for returning an int:
extern "C" __declspec( dllexport ) __stdcall int runmefunc();
extern "C" __declspec( dllexport ) __stdcall int runmefunc() {
return runme();
}
class DLLIMPORT DllClass
{
public:
DllClass();
virtual ~DllClass(void);
int runme(void);
};

int DllClass::runme() {
return 9000;
}


I don't get the concept of defining runme() as a member of a class, and
then being able to export just that function. Is that a feature of the
DLLIMPORT keyword?
Jul 17 '05 #4

"Steve Gerrard" <no*************@comcast.net> wrote in message
news:Jd********************@comcast.com...

"Jason" <ja***********@btinternet.com> wrote in message
news:bu**********@hercules.btinternet.com...

This works better than what i was doing for returning an int:
extern "C" __declspec( dllexport ) __stdcall int runmefunc();
extern "C" __declspec( dllexport ) __stdcall int runmefunc() {
return runme();
}
class DLLIMPORT DllClass
{
public:
DllClass();
virtual ~DllClass(void);
int runme(void);
};

int DllClass::runme() {
return 9000;
}

I don't get the concept of defining runme() as a member of a class, and
then being able to export just that function. Is that a feature of the
DLLIMPORT keyword?


Perhaps I misled you. runme does not get exported, runmefunc does reflected
in any VB declarations. the extern c functions wrap around any
object-oriented c++ code so windows can use it as a c function, as it cant
deal with objects and member functions.

Jul 17 '05 #5

"Jason" <ja***********@btinternet.com> wrote in message
news:bu**********@sparta.btinternet.com...

"Steve Gerrard" <no*************@comcast.net> wrote in message
news:Jd********************@comcast.com...

"Jason" <ja***********@btinternet.com> wrote in message
news:bu**********@hercules.btinternet.com...

This works better than what i was doing for returning an int:
extern "C" __declspec( dllexport ) __stdcall int runmefunc();
extern "C" __declspec( dllexport ) __stdcall int runmefunc() {
return runme();
}
> class DLLIMPORT DllClass
> {
> public:
> DllClass();
> virtual ~DllClass(void);
> int runme(void);
> };
>
> int DllClass::runme() {
> return 9000;
> }
I don't get the concept of defining runme() as a member of a class, and then being able to export just that function. Is that a feature of the DLLIMPORT keyword?


Perhaps I misled you. runme does not get exported, runmefunc does

reflected in any VB declarations. the extern c functions wrap around any
object-oriented c++ code so windows can use it as a c function, as it cant deal with objects and member functions.


I think that is what surprises me. It seems like the wrapper runmefunc
is able to call the function runme, without bothering to create an
instance of the DllClass in which it is defined.
Jul 17 '05 #6

"Steve Gerrard" <no*************@comcast.net> wrote in message
news:H8********************@comcast.com...

"Jason" <ja***********@btinternet.com> wrote in message
news:bu**********@sparta.btinternet.com...

"Steve Gerrard" <no*************@comcast.net> wrote in message
news:Jd********************@comcast.com...

"Jason" <ja***********@btinternet.com> wrote in message
news:bu**********@hercules.btinternet.com...
>
> This works better than what i was doing for returning an int:
> extern "C" __declspec( dllexport ) __stdcall int runmefunc();
> extern "C" __declspec( dllexport ) __stdcall int runmefunc() {
> return runme();
> }
> > class DLLIMPORT DllClass
> > {
> > public:
> > DllClass();
> > virtual ~DllClass(void);
> > int runme(void);
> > };
> >
> > int DllClass::runme() {
> > return 9000;
> > }

I don't get the concept of defining runme() as a member of a class, and then being able to export just that function. Is that a feature of the DLLIMPORT keyword?

Perhaps I misled you. runme does not get exported, runmefunc does

reflected
in any VB declarations. the extern c functions wrap around any
object-oriented c++ code so windows can use it as a c function, as it

cant
deal with objects and member functions.


I think that is what surprises me. It seems like the wrapper runmefunc
is able to call the function runme, without bothering to create an
instance of the DllClass in which it is defined.

oops i just realised what i did. i did not compile that bit...i jsut added
it into the email to illustrate the wrapper function, forgetting to create
the object first - doh.

Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
117
by: Peter Olcott | last post by:
www.halting-problem.com
18
by: Ian Stanley | last post by:
Hi, Continuing my strcat segmentation fault posting- I have a problem which occurs when appending two sting literals using strcat. I have tried to fix it by writing my own function that does the...
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
0
by: =?Utf-8?B?am8uZWw=?= | last post by:
Hello All, I am developing an Input Methop (IM) for PocketPC / Windows Mobile (PPC/WM). On some devices the IM will not start. The IM appears in the IM-List but when it is selected from the...
1
by: sherifbk | last post by:
Problem description ============== - I have 4 clients and 1 server (SQL server) - 3 clients are Monitoring console 1 client is operation console - Monitoring console collects some data from...
9
by: AceKnocks | last post by:
I am working on a framework design problem in which I have to design a C++ based framework capable of solving three puzzles for now but actually it should work with a general puzzle of any kind and I...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.