⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bcjq012.txt

📁 c++ builder 的一些txt文档
💻 TXT
字号:

C++ Builder开发者:程序员之家
var how_many_ads = 3;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
 
  
  
    
      
        
          
            首页   
              | 控件天堂 | 控件使用                 
              | 编程技巧                  
              |  源代码 |  编程工具 |      
               系统补丁 |  电子书籍 | 技术论坛                  
              |  相关链接               
                         
                       
                     
                   
                   
                     
                       
                         
                           
                         
               
       if (ad==1) {document.write(''+'');}             
       if (ad==2) {document.write(''+'');}             
       if (ad==3) {document.write(''+'');}             
                            
                         
                      
                                  
                      
                    
                  
                
                
                  
                    
                      
                        
                     
                   
var marqueecontents=''+scroll_text+''         
if (document.all)         
document.write(''+marqueecontents+'')         
function regenerate(){         
window.location.reload()         
}         
function regenerate2(){         
if (document.layers){         
setTimeout("window.onresize=regenerate",450)         
intializemarquee()         
}         
}         
function intializemarquee(){         
document.cmarquee01.document.cmarquee02.document.write(marqueecontents)         
document.cmarquee01.document.cmarquee02.document.close()         
thelength=document.cmarquee01.document.cmarquee02.document.height         
scrollit()         
}         
function scrollit(){         
if (document.cmarquee01.document.cmarquee02.top>=thelength*(-1)){         
document.cmarquee01.document.cmarquee02.top-=speed         
setTimeout("scrollit()",100)         
}         
else{         
document.cmarquee01.document.cmarquee02.top=marqueeheight         
scrollit()         
}         
}         
window.onload=regenerate2         
                     
                       
                     
                   
                 
               
               
                 
                   
                     
                       
                         
                           
                             
                  当前位置
  
  
                    编程技巧          
                          
                        
                      
                      
                      
                        
                          
                            
                    怎样在C++Builder中创建使用DLL        
                          
                    
                      
                        
                          
                          自从C++Builder从去年浪漫情人节上市以来,吸引了大量的Delphi、VC、Vb的程序员到它的怀抱,大量的C、C++程序员感叹道:总算有了C的可视化开发工具,对我也是一样,从BC、Delphi到C++Builder。
  
                              动态链接库(DLL)是Windows编程常遇到的编程方法,下面我就介绍一下在BCB     
            (C++Builder下简称BCB) 中如何创建使用DLL和一些技巧。
    
                              一、创建:
                              使用BCB File|NEW建立一个新的DLL工程,并保存好文件BCB,生成一个DLL的程序框架。
    
                              1.DllEntryPoint函数为一个入口方法,如果使用者在DLL被系统初始化或者注销时被调用,用来写入对DLL的初始化程序和卸载程序;参数:hinst用来指示DLL的基地址;reason用来指示DLL的调用方式,用于区别多线程单线程对DLL的调用、创建、卸载DLL;
                              2.在程序中加入自己所要创建的DLL过程、函数;
                              3.用dllimport描述出口;
                              例程序如下:
                              #include
                              #pragma hdrstop
    
                              extern “C” __declspec(dllexport) int test();
    
                              int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long     
            reason, void*)
    
                              {
                               return 1;
    
                              }
                              int test()
    
                              {
                               return 3;
    
                              }
                              注意:动态链接库中调用过程、函数时有不同的CALL方式     
            __cdecl、 __pascal, __fastcall、__stdcall,BCB中默认的方式为__cdecl(可不写),如果考虑兼容性可用时__stdcall声明方法为:
    
                              extern “C” __declspec(dllexport) int __stdcall test();
    
                              对于其中过程、函数也改为:
                              int __stdcall test()
    
                              二、使用DLL
                              在BCB中使用DLL有两种方法:
                              1.用静态调用法
                              首先需要在BCB的项目中加入输入接口库(import     
            library),打开工程项目,使用BCB View|Project Manager打开项目列表,向项目中加入接口库(*.lib)。
    
                              其次在头文件中加入接口声明。
                              例程序如下:
                               //define in include file
    
                              extern “C” __declspec(dllimport) int __cdecl test();
    
                              //use function in main program
    
                              int I;
    
                              I=test();
                              注意:
                              (1)动态链接库调用过程、函数时CALL方式     
            与创建时方式一样不写为__cdecl,其它需要声明。
    
                              (2)BCB创建的DLL有对应的输入接口库(import library),如只有DLL而无库时,可用BCB的implib工具产生:implib     
            xxx.lib xxx.dll;另外可用:tlib xxx.lib,xxx.lst 产生DLL的内部函数列表,许多Windows的未公开技术就是用这种方法发现的。
    
                              2.动态调用法
                              动态调用法要用Windows API 中的LoadLibrary()和GetProcAddress()来调入DLL库,指出库中函数位置,这种方法较常见。
    
                              例程序如下:
                               HINSTANCE dd;
    
                               int _stdcall (*ddd)(void);
    
                               dd=LoadLibrary(“xxx.dll”);
    
                               ddd=GetProcAddress(dd,“test”);
    
                               Caption=IntToStr(ddd());
    
                              FreeLibrary(dd);
                              三、注意:
                              创建DLL时编译链接时注意设置Project Options。
    
                              Packages标签:去除Builder with runtime packages检查框。
    
                              Linker标签:去除Use dynamic RTL检查框。
    
                              否则创建的DLL需要Runtime packages or Runtime library。   
                           
                         
                             
                     
                           
                             
                           
                  if (ad==1) {document.write(''+'');}           
                  if (ad==2) {document.write(''+'');}           
                  if (ad==3) {document.write(''+'');}           
                                             
                           
                         
                       
                     
                
                 
                   
                     
                   
                   
                       
                   
                 
                    
                  
                
              
            
            
              
                
                  
                    
            C++ Builder开发者®         
              2000年06月01日 站长:唐朝         
                   
                 
               
             
             
               
             
           
           
         
         
         
         

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -