to squiffy:
  thank your sugguest!
 请问:如何强制转换函数指针

解决方案 »

  1.   

    比如由一个函数:
    long func(char *p,int a,int b)
    p是返回的指针,那么用:
    (long (char *,int,int))p来转换
      

  2.   

    比如(有多个参数):
    typedef long(* MY_FUNCTION) (char *a1, int *b1, int *b2, char *a2); 
    然后在使用时用
    MY_FUNCTION pMyFunc = (MY_FUNCTION)::GetProcAddress(hUser32, "SetLayeredWindowAttributes");
      

  3.   

    假设一个DLL中的函数定义是这样的:dllfun(ULONG i);而你需要传递进函数a、b、c,三个变量,你可以这样实现:
    typedef struct test
    {
      int a;
      char b;
      short c;
    }PARA_S;PARA_S para;some func:
    {
       dllfunc( (ULONG)(&param) );
    }
    这样的话你在截取了dllfun之后,在你的dllfun里面就可以如下:
    dllfun(ULONG i)
    {
        PARA_S *P = (PARA_S *)i;
    ......
    }
    如上你不是就可以解决了使用一个参数传递多个参数的问题了吗?只是注意指针的有效范围就是了。