CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  C/C++ >  工具平台和程序库

哪个在DEVCPP里编译使用DLL时成功过了

楼主twtfcu3(孤星乐)2005-05-30 12:31:38 在 C/C++ / 工具平台和程序库 提问

哪个在DEVCPP里编译使用DLL时成功过了  
   
  我试了好几次啊 问题点数:20、回复次数:3Top

1 楼twtfcu3(孤星乐)回复于 2005-05-30 12:40:24 得分 0

dll.h  
   
  #ifndef   _DLL_H_  
  #define   _DLL_H_  
   
  #if   BUILDING_DLL  
  #   define   DLLIMPORT   __declspec   (dllexport)  
  #else   /*   Not   BUILDING_DLL   */  
  #   define   DLLIMPORT   __declspec   (dllimport)  
  #endif   /*   Not   BUILDING_DLL   */  
   
   
  class   DLLIMPORT   DllClass  
  {  
      public:  
          DllClass();  
          virtual   ~DllClass(void);  
   
      private:  
   
  };  
   
   
  #endif   /*   _DLL_H_   */  
   
  DLLIMPORT   int   abc();  
   
   
  dll.cpp  
   
  /*   Replace   "dll.h"   with   the   name   of   your   header   */  
  #include   "dll.h"  
  #include   <windows.h>  
   
  DllClass::DllClass()  
  {  
   
  }  
   
   
  DllClass::~DllClass   ()  
  {  
   
  }  
   
   
  BOOL   APIENTRY   DllMain   (HINSTANCE   hInst           /*   Library   instance   handle.   */   ,  
                                                DWORD   reason                 /*   Reason   this   function   is   being   called.   */   ,  
                                                LPVOID   reserved           /*   Not   used.   */   )  
  {  
          switch   (reason)  
          {  
              case   DLL_PROCESS_ATTACH:  
                  break;  
   
              case   DLL_PROCESS_DETACH:  
                  break;  
   
              case   DLL_THREAD_ATTACH:  
                  break;  
   
              case   DLL_THREAD_DETACH:  
                  break;  
          }  
   
          /*   Returns   TRUE   on   success,   FALSE   on   failure   */  
          return   TRUE;  
  }  
   
  DLLIMPORT   int   abc(){return   MessageBox(0,0,0,0);}  
   
   
  main.cpp  
   
  #include   <windows.h>  
  typedef   int   (*dllfun)();  
   
  /*     Declare   Windows   procedure     */  
  LRESULT   CALLBACK   WindowProcedure   (HWND,   UINT,   WPARAM,   LPARAM);  
   
  /*     Make   the   class   name   into   a   global   variable     */  
  char   szClassName[   ]   =   "WindowsApp";  
   
  int   WINAPI   WinMain   (HINSTANCE   hThisInstance,  
                                          HINSTANCE   hPrevInstance,  
                                          LPSTR   lpszArgument,  
                                          int   nFunsterStil)  
   
  {  
          HWND   hwnd;                               /*   This   is   the   handle   for   our   window   */  
          MSG   messages;                         /*   Here   messages   to   the   application   are   saved   */  
          WNDCLASSEX   wincl;                 /*   Data   structure   for   the   windowclass   */  
   
          /*   The   Window   structure   */  
          wincl.hInstance   =   hThisInstance;  
          wincl.lpszClassName   =   szClassName;  
          wincl.lpfnWndProc   =   WindowProcedure;             /*   This   function   is   called   by   windows   */  
          wincl.style   =   CS_DBLCLKS;                                   /*   Catch   double-clicks   */  
          wincl.cbSize   =   sizeof   (WNDCLASSEX);  
   
          /*   Use   default   icon   and   mouse-pointer   */  
          wincl.hIcon   =   LoadIcon   (NULL,   IDI_APPLICATION);  
          wincl.hIconSm   =   LoadIcon   (NULL,   IDI_APPLICATION);  
          wincl.hCursor   =   LoadCursor   (NULL,   IDC_ARROW);  
          wincl.lpszMenuName   =   NULL;                                   /*   No   menu   */  
          wincl.cbClsExtra   =   0;                                             /*   No   extra   bytes   after   the   window   class   */  
          wincl.cbWndExtra   =   0;                                             /*   structure   or   the   window   instance   */  
          /*   Use   Windows's   default   color   as   the   background   of   the   window   */  
          wincl.hbrBackground   =   (HBRUSH)   COLOR_BACKGROUND;  
   
          /*   Register   the   window   class,   and   if   it   fails   quit   the   program   */  
          if   (!RegisterClassEx   (&wincl))  
                  return   0;  
   
          /*   The   class   is   registered,   let's   create   the   program*/  
          hwnd   =   CreateWindowEx   (  
                        0,                                       /*   Extended   possibilites   for   variation   */  
                        szClassName,                   /*   Classname   */  
                        "Windows   App",               /*   Title   Text   */  
                        WS_OVERLAPPEDWINDOW,   /*   default   window   */  
                        CW_USEDEFAULT,               /*   Windows   decides   the   position   */  
                        CW_USEDEFAULT,               /*   where   the   window   ends   up   on   the   screen   */  
                        544,                                   /*   The   programs   width   */  
                        375,                                   /*   and   height   in   pixels   */  
                        HWND_DESKTOP,                 /*   The   window   is   a   child-window   to   desktop   */  
                        NULL,                                 /*   No   menu   */  
                        hThisInstance,               /*   Program   Instance   handler   */  
                        NULL                                   /*   No   Window   Creation   data   */  
                        );  
   
          /*   Make   the   window   visible   on   the   screen   */  
          ShowWindow   (hwnd,   nFunsterStil);  
   
          /*   Run   the   message   loop.   It   will   run   until   GetMessage()   returns   0   */  
          while   (GetMessage   (&messages,   NULL,   0,   0))  
          {  
                  /*   Translate   virtual-key   messages   into   character   messages   */  
                  TranslateMessage(&messages);  
                  /*   Send   message   to   WindowProcedure   */  
                  DispatchMessage(&messages);  
          }  
   
          /*   The   program   return-value   is   0   -   The   value   that   PostQuitMessage()   gave   */  
          return   messages.wParam;  
  }  
   
   
  /*     This   function   is   called   by   the   Windows   function   DispatchMessage()     */  
   
  LRESULT   CALLBACK   WindowProcedure   (HWND   hwnd,   UINT   message,   WPARAM   wParam,   LPARAM   lParam)  
  {  
     
    static   HINSTANCE   hLibrary;  
    static   dllfun   a;  
          switch   (message)                                     /*   handle   the   messages   */  
          {  
    case   WM_CREATE:  
  hLibrary   =   LoadLibrary("goxl.dll");  
  a   =   (dllfun)GetProcAddress(hLibrary,"abc");    
  if(!a)MessageBox(0,"加载出错",0,0),exit(1);  
  a();  
  break;    
                  case   WM_DESTROY:  
                          PostQuitMessage   (0);               /*   send   a   WM_QUIT   to   the   message   queue   */  
                          break;  
                  default:                                             /*   for   messages   that   we   don't   deal   with   */  
                          return   DefWindowProc   (hwnd,   message,   wParam,   lParam);  
          }  
   
          return   0;  
  }  
   
  Top

2 楼tiesoftware(我想早恋----但是已经晚了:( )回复于 2005-05-30 18:01:43 得分 10

我也不能通过,帮顶一下Top

3 楼mostideal(三甲)回复于 2005-05-31 00:10:27 得分 10

dingTop

相关问题

  • 编译成dll
  • Dll反编译
  • Dll反编译
  • Dll反编译
  • 编译DLL问题
  • dll编译出错~~
  • dll编译出错
  • vb 调用 VC 编译成功的 DLL 字符串处理函数出错
  • JSP编译不成功
  • DLL编译问题。急!急!

关键词

  • dll
  • application
  • dllclass
  • wincl
  • dllimport
  • hinstance
  • reason
  • hwnd
  • building
  • break

得分解答快速导航

  • 帖主:twtfcu3
  • tiesoftware
  • mostideal

相关链接

  • C/C++ Blog
  • C/C++类图书
  • C/C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo