Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all:-)

i have the following Problem (i think it is a function pointer Problem)

i have to set in a Programm "DLLSPLIT"

DLLSPLIT is defined as follows:

typedef int (WINAPI DLLSPLIT) (LPSTR);

i have to do:

DLLSPLIT* dllsplit= .... (what to write here????)

i tried define a function:

int foo(LPSTR bla)
{
//do something
}

and then dllsplit= &foo;

but that doesnt work....

can someone help me?
Posted
Updated 19-Nov-14 22:53pm
v3
Comments
nv3 20-Nov-14 5:07am    
Define foo as:
int WINAPI foo (LPSTR p)
{
...
}
You must exactly match the definition in the typedef!
If that doesn't help, then show the exact error messages you are getting. "That doesn't work" is not a good starting point for others to help you.

Given the appearance of the WINAPI define, it's likely a matter of calling convention mismatch (see here[^] for instance) but without more detail about exactly how it "doesn't work" we can't help.
 
Share this answer
 
Please post the exact error message given by the compiler.

Note that the default calling convention for C/C++ functions is __cdecl, you probably want to define foo as

C++
int __stdcall foo(LPSTR bla)


that is the requirement for the pointers declared as WINAPI.

Note also that if you're in a class then foo should be static and declared as __stdcall, because in classes the defualt calling convention is __thiscall.

Or, as the other users said above,
C++
int WINAPI foo (LPSTR bla)

afer all WINAPI is just a define for __stdcall
 
Share this answer
 
v2
Comments
Member 10781325 20-Nov-14 5:25am    
thx to you all, i just didnt write the WINAPI:-)
i thougt i was doing something completly wrong...

thank u guys!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900