473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 5704
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.