如果我要封装系统dll中的函数和数据结构,我怎样才能够得到这些信息呢?比如我要封装maip32.dll中的函数,我就要知道给我们提供了一些什么函数?他所定义的数据结构是什么?否则我怎么能够封装呢?

解决方案 »

  1.   

    查阅 M$ Platform SDK文档。
      

  2.   

    把要准备给别的程序用的函数对象和数据.........声明成这样DLL端准备给别的程序用的函数申明成这样(导出函数)__declspec(dllexport)  int a(,,,,,);//只要在普通函数声明前加上__declspec(dllexport) __declspec(dllexport) CString str;
    .
    .
    .
    .
    .
    在调用该DLL端申明成这样__declspec(dllimport)  int a(,,,,,,); 所以有时候为了简单,叫DLL端和调用端共用一个头文件
    下面是个全局钩子DLL头文件的例子
    在DLL端设置一环境变量HOOK_EXPORTS,这样就可以根据不同环境(DLL端和调用端)用不同的定义了。
    #ifdef HOOK_EXPORTS
    #define HOOK_API __declspec(dllexport)
    #else
    #define HOOK_API __declspec(dllimport)
    #endif
        HOOK_API MOUSEHOOKSTRUCT  b;
       // HOOK_API MOUSEHOOKSTRUCT  getpoint();
    HOOK_API BOOL EnableMouseProcCapture();
    HOOK_API BOOL DisableMouseProcCapture();
    // This class is exported from the HOOK.dll
    class HOOK_API CHOOK {
    public:
    CHOOK(void);
    // TODO: add your methods here.
    };extern HOOK_API int nHOOK;HOOK_API int fnHOOK(void);