问题描述
大家好:-)
i有以下问题(我认为这是一个函数指针问题)
i必须在程序中设置DLLSPLIT
DLLSPLIT定义如下:
typedef int(WINAPI DLLSPLIT)(LPSTR);
i必须这样做:
DLLSPLIT * dllsplit = ....(这里写什么????)
i尝试定义一个函数:
int foo(LPSTR bla)
{
//做点什么
}
然后是dllsplit =&foo;
但这不起作用....
有人可以帮助我吗?
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?
推荐答案
int __stdcall foo(LPSTR bla)
这是指定为WINAPI的指针的要求。
还要注意,如果你在一个类中,那么foo应该是静态的并且声明为__stdcall,因为在类中,defualt调用约定是__thiscall。
或者,作为其他用户如上所述,
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,
int WINAPI foo (LPSTR bla)
所有WINAPI只是__stdcall的定义
afer all WINAPI is just a define for __stdcall
这篇关于如何使用函数指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!