天天看点

SQL存储过程调用DLL

dll程序源码为:  

  头文件:  

  #ifndef   UNIT1H  

  #define   UNIT1H  

  extern   "C"   __declspec(dllexport)   __stdcall   void   messbox();  

  #endif  

  cpp文件:  

  #include   <vcl.h>  

  #include   <windows.h>  

  #pragma   hdrstop  

  #include   "unit1.h"  

  #pragma   argsused  

  int   WINAPI   DllEntryPoint(HINSTANCE   hinst,   unsigned   long   reason,   void*   lpReserved)  

  {  

          return   1;  

  }  

  //---------------------------------------------------------------------------  

  void   __stdcall   test()  

  {   

  }  

  make后,把生成的DLL放入了system32目录下。  

  然后在查询分析器里执行:  

  sp_addextendedproc   'test'   ,   'Project1.dll'  

  exec   test   

注意:SQL调用扩展存储过程不能有与用户交互的信息(因为是不可能弹出任何窗口的)