473,406 Members | 2,345 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,406 software developers and data experts.

VB and Callback functions

Hi all,
I am trying to write a simple DLL that calls back to the VB app that
called it in the first place.
Below is the code in the DLL
// start of code
FARPROC addr1 = NULL;
FARPROC addr2 = NULL;

extern "C" long _stdcall EXPORT Store (FARPROC a1, FARPROC a2)
{
addr1=a1;
addr2=a2;
return 0;
}

extern "C" long _stdcall EXPORT Execute (FARPROC addr)
{

long result;

if (addr1 == NULL)
return -1;
result = addr1();
result = addr2();
return result;
}

extern "C" long _stdcall EXPORT Execute2 (FARPROC addr , long value)
{
long result;
result = addr( value);
return result;
}
// end of code.

Now Store and Execute run OK.
Execute2 won't compile. I get the following error message:

"...Pointers.cpp(93) : error C2197: 'int (__stdcall *)(void)' : too many
actual parameters"
with the line 'result = addr(value);' producing the error.
What am I not doing correctly?

TIA
Geoff Turner.
Jul 17 '05 #1
2 5666
MRe
> extern "C" long _stdcall EXPORT Execute2 (FARPROC addr , long value)
{
long result;
result = addr( value);
return result;
}
// end of code.

Now Store and Execute run OK.
Execute2 won't compile. I get the following error message:

"...Pointers.cpp(93) : error C2197: 'int (__stdcall *)(void)' : too many
actual parameters"
with the line 'result = addr(value);' producing the error.
What am I not doing correctly?

FARPROC is defined as...

typedef int (FAR WINAPI *FARPROC)();

....thus takes no parameters! Use something likes...

typedef long (WINAPI* FURTHERPROC)(long Value);

extern "C" long _stdcall EXPORT Execute2 (FURTHERPROC addr , long value)
Regards,
MRe
Jul 17 '05 #2

"MRe" <re************@dublin.ie> wrote in message
news:dw*****************@news.indigo.ie...
extern "C" long _stdcall EXPORT Execute2 (FARPROC addr , long value)
{
long result;
result = addr( value);
return result;
}
// end of code.

Now Store and Execute run OK.
Execute2 won't compile. I get the following error message:

"...Pointers.cpp(93) : error C2197: 'int (__stdcall *)(void)' : too many
actual parameters"
with the line 'result = addr(value);' producing the error.
What am I not doing correctly?

FARPROC is defined as...

typedef int (FAR WINAPI *FARPROC)();

...thus takes no parameters! Use something likes...

typedef long (WINAPI* FURTHERPROC)(long Value);

extern "C" long _stdcall EXPORT Execute2 (FURTHERPROC addr , long value)
Regards,
MRe


Thank you very much, that's just want I want.

Regards,
Geoff.
Jul 17 '05 #3

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

Similar topics

6
by: Eric Entressangle | last post by:
Hi all, is there any trouble setting an C++ static class method as callback function for a C program or library ? Thanks
5
by: Pratik | last post by:
what are callback functions? Where we require callback functions? In what scenario we require callback functions?
11
by: ajay.sonawane | last post by:
Hello ther I read somewhere that callback function should be global or static member function. 1: I could use static member functions but how could I access members of class which ar not static....
15
by: Felix Kater | last post by:
Hi, in a given library I register callback functions with this function: bool set_callback(int index, int (*callback_function)(long)); I need the callback function to also pass the index...
4
by: Jimmy | last post by:
I need to use Asynchronous Socket functions in a server application and am learning from sources such as the MSDN2 (http://msdn2.microsoft.com/en-us/library/bbx2eya8.aspx). What I observed is that...
4
by: Edwin Gomez | last post by:
I'm a C# developer and I'm new to Python. I would like to know if the concept of Asynchronous call-backs exists in Python. Basically what I mean is that I dispatch a thread and when the thread...
6
by: smmk25 | last post by:
Before I state the problem, I just want to let the readers know, I am knew to C++\CLI and interop so please forgive any newbie questions. I have a huge C library which I want to be able to use in...
2
by: Evan Burkitt | last post by:
Hi, all. I have a Windows DLL that exports a number of functions. These functions expect to receive a pointer to a callback function and an opaque void* parameter. The callback functions are...
1
by: kikivenkat | last post by:
Hi, I understand the concept of function pointers. I am a little confused with the call back functions. 1.If a function is invoked using a function pointer, then does it mean the function...
5
by: Jef Driesen | last post by:
I have a C DLL that I want to use from a C# project. The C header file contains these declarations: typedef void (*callback_t) (const unsigned char *data, unsigned int size, void *userdata);...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.