     DLL:  

     

    DLL  Dynamic Link Library (  ) - 
 ,    ,    . DLL 
   ,  ,    
      .     
       ,   , 
      .  
DLL     ,    ,  
^"""- Delphi  , , ,  C++. 
      DLL   _  
,       
(Application Programming Interface  API),     - 
      ,      
 .          
  (  ),  DLL (, ) 
    ,    . 
    DLL       .   
          
. ,         
  .      DLL,   
     ,   .	/-^ 
     ,   Delphi      
ActiveX      (Visual Component Library 
VCL).          
  DLL. 

     25 

     DLL    Win32 

       Win32   DLL 

       DLL 

     ,        
   DLL. 

    DLL    

           . 

      DLL 

        DLL,     . 

591


    DLL     Win32 

    DLL      Windows,    WinNT  
Win95.     DLL    
  ,       
     .   
 DLL. 
    	CPL- (  ) 
    	  Win95  WinNT 
    	  Win32,   KERNEL32  GDI32 
    	 ,   COMM.DRV 
    	    16-   32-   
    	  NT 
    	 OLE 
     , ,   .    Win95  NT 4.0 
     ,      
 . 
     Win95  NT  /-,       
 ,        
  Windows.        
,   DLL.      DLL, 
         . 
          20, 
" OLE". 

      16- Windows 

    ,  ,        Windows, 
   WinNT  Win95.     
  Delphi,  ,  ,    1.0  2.0.   
  Delphi 3.0.      ,     
,   ,    Windows 3.x.  WinNT 
 Win95 16-    ,     , 
      ,   
Win32.            , 
 ,     
.~"~ """ "" 
     Borland      
,      .    
        
-,      ,  Delphi. 
    \ 
    I  1 

     DLL  Win 16 

     Win32  ,     
DLL.       ,  ,   
 ,    .   Win32 
16- ,       
DLL,     ,        
   . 
      Win32      
 ,      .  
16-  Windows  DLL    
,     ,    
    . 16-  
DLL     ,    
    64 .  ,    
LoadLibrary          
        , 
 Windows.     DLL   
FreeLibrary,      ,    
  0,     . 

    592	 VI.   


      Huge 

    Pascal     Huge,    
  C++.  ~    
,   16-  Windows,  4- 
     .     
 ,      64 ,  
     . " ' 
      ,     64 , 
      '  
   .      
 100 ,   ,     
     ( ^^),   
    .   
         . 
  ,     -  . 
    8JUU032    .    Win32 
  ,       
  ,      
.  Win32  -   4 ,    
jaio .     ,    
,      . 
          
,        DLL   
   .    DLL  
          
      .    
 DLL       ,  
          . 
      ,   ,   ( 
 ,         
).  Win32  ,     DLL   
-^ .      , 
  DLL,       

     DLL  Win32 

     Win32    .    
,      ,  
  .   4    
,     .    
      .   
    ,     , 
       . 
      , ..^ 
  RAM    ,      
 .	' 

     
     DLL     -   
DLL.    16- DLL    ,   
32-         ( 
 "  "  ). 

             
       ,    
  DLL,   -.     DLL 
        .     
DLL     .    DLL , 
  ,   DLL,      
 .      ,   
     . 
     ,       .  
,,      ,   
  DLL,   ,   ^    
  ,   ..    
            DLL. 
          DLL-  
       .  
    -      
 ,      ,   , 
 . 

     25.  DLL: 	593 

     Win32 DLL        
     .    DLL 
   . DLL  Win32 -   
   ,      
     .   32- DLL 
      ,   
16-  Windows     
,        . 
_ 31^?-_?   ,  
      . , 
    . 

       

     Win32 ^       
  .      
 .       . 
         wm_CopyData.     
        ,  
 DLL.        32, 
"  ". 
         16-   32-.  
  DLL   ,       
.        32, "  ". 
         .  DLL     
  FileMap-ping    dll_Process_Attach. 
        26. " DLL:  
".     OLE.  OLE-     
 .        20, 
" OLE". 
        ,   ,   
,    ,   Win32. 
    .        
  .         
 ,        
 . 

      

     Delphi     DLL-. DLL-   
 DPR-. - ,_ .  ,  
  .       , 
  File^New. 

    . 25.1.   New Items     DLL- 

        DLL-.     
Delphi  File^New,    ,   . 25.1. 

    594  VI.   

         DLL,    ,  
 ,    25.1.      
BAREBONES. DPR    . 

    !   25.1. \UDELPHI3\CHP25\BAREBONES. DPR.  BareBones 
    Library BareBones; { 

          DLL.  DLL  
       ,  
ShareMem  ^   Uses  __ _.  
  ,    DLL,    ,    
    .  ShareMem   
   DELPHIMM.DLL,    
   DLL..  
?11̧?11,.,1*-1-..13,..,,     
   PChar  ShortString.

    uses 
    SysUtils, 
    Classes; begin end. 

       25.1   ,  
 DLL,          DLL 
 DELPHIMM.DLL. Delphi      
DELPHIMM    ShareMem.    
.___.,?   Ansi String,  DLL  - 
(  DLL)  .	~* 

     AnsiString 

       DeiBhi     Ansistring   
,  OTj--   Pascal ,    
 .  ,  ^   '5] 
 ,   12- ;,_.. , 
-| ^ JJ     .    
 , '"""-1"  Ҩ    
 .  , ._  
AnsiStringJ- PChar. 
     12- ,   Ansistring,_ 
, ^^-  _ , _^,0,  
 !1    * '  
        .  
  DLL ^^    
^^^^^^^^    DELPHIMM.DLL.     
      DLL    .   
 "" DLL,    .   
    , ,      ;  
,      DLL,     
.      (  ) DLL. 

      DLLMain 

      Delphi     DLL     
  begin   end.    DLL  
,     DPR-.    
    .  ,  DLL 
     ,   
    .   DLL _- 
.  . ^^^^.. 
     DLLMain (    )  , 
   "	Win32  C++.  B^Delphi  
,   Win32,  -    
^  >>.^"  Pascal.  , 
         
Microsoft (CTlcr6bft Developers Network  MSDN),     
 ,     Internet. , ,  , 
       C++.   ,     
  Pascal.    ,    
   Pascal,   . 

     25.  DLL: 	595 

      DLLEntryPoint,   DLLMain.    
Win32       C++.  ,   
     DLLEntryPoint   .  
  ,      (  
)    .    ,  
,        .  
     DLL   -, 
,  ,     .   C++ 
  DLLEntryPoint   : 

    BOOL WINAPI   DLLEntryPoint(HINSTANCE  hlnst,   DWORD  dwReason,   LPVOID  
 IpvReserved); 

     Delphi    (   Pascal),   
     .    
 ,     begin  
 end  DPR-.         
  DLL    . 

     DLLMain  Delphi 

     Delphi    DLLMain    C++,    
    .   
  Delphi    25.2. 

    |  25.2. DLLMAIN.  DLLMain  Delphi 

    library DLLEntry; uses 
    ShareMem, Windows, SysUtils, Classes; 
    procedure DLLMain(dwReason: DWORD); begin 
    case dwReason of 
    dll_Process_Attach : {.}; dll_Process_Detach : {.}; 
dll_Thread_Attach  : {.}; dll_Thread_Detach  : {.}; end; 
end; begin 
    DLLProc := @DLLMain; DLLMain(dll_Process_Attach); end. 

     ,        
ShareMem   DELPHIMM.DLL.   uses   ShareMem  
Windows.     dll_-KOHCT3HT.   
 uses    DLLMain. 
     Delphi  DLLMain    dwReason  .  
       0  3.   Windows 
     . ,  
~     . 25.1. 

    	                                 

    dll_Process_Attach       \                        DLL  
	    . 	 
   DLL    	   
    dll_Thread_Attach         2	   -       
    (  	  
  ) 

    596  VI.   


     . 25.1 ] 

    	           ___ ___    

    dll_Thread_Detach        3	                        
   DLL    ,   
      , __          
                                     
    dll_Process_Detach      	DLL    -      
  
      ,  	,    , - 
                                   
    dll_Process_Attach 

     DLLMain   ,     
    ,   . 25.1.   
   DLL     
  DLLMain   dll_Process_Attach. ,  
   DLL,  DLLMain    dll_Process_Detach. 

      ) 
       DLL      .  
 DLL         
.       , 
   .  DLLMain   
dll_Process_Attach       . 

      sarpjQicaeT J)LL ,_ _  ,     
        ( 
 )   .      
(     0)    DLLMain 
  dll_Process_Detach. 
     DLL   ,  DLLMain  
 dll_Process_Attach       
 ,       dll_Process_Detach   
   0   . 
     DLLMain   dll_Process_Attach    
    .   DLL  
        ,  
DLLMain   dll_Process_Detach     
 .    DLL    dll_Thread_Detach. 

     
      ,     DLLMain   
dil_Thread_Detach        
dii_Thread_Attach.   ,   DLL,   . 

    ,      ,   
 DLL.          
DLLMain   dll_Thread_Detach,         
    dii_Thread_Attach. 

     DLLProc 

      25.2  ,     DLL,  
  DLLMain.       uses, 
      .   ,  
 DLLMain   ,      
 ,, C++,    Delphi   DLLMain?  
   DLLProc, 
    ¸    ,    
System.     ,   Pascal.   
System      _StartLib,  ^ 
.     ,    
DLLProc. DLLProc   , 

     25.  DLL:  597 

      , oil.    DLL  
      DLLMain.   
 DLLMain   .  
-  . 

    begin 
    DLLProc := DLLMain; 
    DLLMain(dll_Process_Attach); end. 

    14       .  
  _   DLLProc  
    DLLMain.  Delphi   , 
  DPR-  DLL,  ^: 
dll_Process_Attach.   ,   D 
    LLMain , ,    ,     
.     ,   
  DLLProc. 

     DLLMain  DLL 

       DLL  DLLMain   ,  
 .        
  ,       DLL.  
 25.3     DLLMain   
   . 

     25.3. DLLECXEPT. DPR.     DLLMain 

    library DLLExcept; uses 
    ShareMem, 
    Windows,	N SysUtils, Forms, Classes; type 
    TAppHandler = class 
    procedure HandlerProc(Sender: TObject; E: Exception); end; 
    procedure TAppHandler.HandlerProc(Sender: TObject; E: Exception); begin 
    {  . } end; var 
    AppHandler: TAppHandler; procedure DLLMain(dwReason: DWORD); begin 
    case dwReason of 
    dll_Process_Attach : begin 
    AppHandler := TAppHandler.Create; 
    Application.OnException := AppHandler.HandlerProc; end; 
    dll_Process_Detach : begin 
    Application.OnException := nil; AppHandler.Free; end; 
    dll_Thread_Attach  : {.}; dll_Thread_Detach  : {.}; end; 
end; begin 
    DLLProc := J_DLLMa.in; DLLMain (dll_P"roc'ess_Attach) ; ericf." 


    598	 VI.   

        25.2,     . 
       (Forms).     
  Application.   Forms   ,  
  .  Application   
 -ception.   ,   ., 
 try. . . ecxept,   OnException  Application. 
  OnException   ,    
      ,   . 
        Application   OnException 
   5, "  ". 
      25.3   uses   ,   
  TAppHandler    HandlerProc.   
      ,      
   . 
       HandlerProc    
 AppHandler  TAppHandler.     
AppHandler    DLLMain. 
         case,     
  dll_Process_Attach    
 AppHandler.     Application. OnException 
  HandlerProc.     ,   
,   dll_Process_Detach,  Application. 
OnException   nil,    AppHandler 
.   DLLMain   , 
 -MbieDLL       . 

       

             
.        , 
      .     
, _   ,  (  
) ^        
      . 
     . 25.2     ,  Delphi, 
           . 

     25.2.   ,  Delphi 

    	 	  

    Fast-Call    ()	 	  
    StdCall	 	  
    Pascal	 	  
    Cdecl	 	  
    Safecall	 	  

    ,_  16-  Delphi 1.0  
Pascal   _   Fast-Call   
  .        
    .    
(     Fast-Call   ).  , 
  ,    Pascal. 

     
     Fast-Call ( )   Delphi  
C++  Borland,     .   
Fast-call ^^ BQrlanct^yHMJSQbtia, -    
 "*"7       
  . ,     
,     DLL    Fast-Call, 
     (callback).    Fast-Call 
   ,   Delphi. 

        Windows 3.x,    Delphi 1.0, 
    Pascal.      
,   DLL.  Win32    StdCall. 
 Delphi      Fast-Call,     
   . 

     25.  DLL:  599 

           . 25.2,     ,  
 Cdecl,   -  .   
       -?  
     32 ,      
        .    
   32 .       
 .        
     .  ,  
,     ,   . 
              
 DLL.   16-  Delphi   
        Pascal. 
     Delphi 2.0  3, ^ 
   Fast-Call.      ,   
         , 
    DLL,   ,   
    DLL,    C++. 
     DLL        . 
    ,    
   .    DLL   
 StdCall,      Pascal, ,   
,     .     
           . 
          StdCall,    
,    C++,  Cdecl,  ,   . 
        , 
      .    
,   ,     
   .      
    .   .elphi 
    Cdecl,     
  -.       
  Delphi    -,    , 
   .     Cdecl  ,       
     30, 

    " Delphi  C++". 

          .   
,      .    
Win32    StdCall,  Fast-Call  , 
   Delphi. 

     

     DLL  ,      
        .   
   DLL     
 ,      DLL   
  ,    ( DLL).  
-     ,  DLL . 
      DLL      
,     DLL.     
      DLL    
  .   DLL    
   ,      
.       25.4. 
        Delphi     
 . -,      interface 
.  ,   *   exports. , 
-,       implementation.   
    EXPORTU1. PAS,    25.4. 

     25.4. \UDELPHI3\CHP25\EXPORTSU1. PAS. ExportsUl    
Exporting, dpr       

    unit   EXPORTSU1;	 
    . interface                             (-4/V1      (*-#<-? 
    uses 
    SysUtils,   Windows; 
    procedure ExSetVolumeLabel(pcName:   PChar);   StdCall; exports 


    600	 VI.   


    ExSetVolumeLabel; implementation 
    procedure  ExSetVolumeLabel(pcName :   PChar); begin	~'              "    
     ' 
    if not Assigned(pcName)   then 
    Raise Exception.Create('Name passed to  LabelDiskVolume  is  nil'); if not 
 SetVolumeLabel(nil,pcName)   then 
    Raise Exception.Create('Cant  set volume  label.   GetLastError  reports   '+ 
    IntToStr(GetLastError)); end; end. 

     Win32     .  ,  
 True    ,    False. 
,     Delphi,   
         
:    ,    
   ;     
,   try. . .except.    
   25.4,  _^11  Win32   
  ExSetVolumeLabel. 
     ,       interface . 
   ,      
  , .. StdCall.       
StdCall    .    StdCall  
 implementation  . 
       Delphi 1.0,  ,    
  far  export. 
          Delphi   .   
  ,  

     

    0_2? :_  _ . 
 ,   export     , 
 ,     . 
       ExSetVolumeLabel   exports,  
   ExSetVolumeLabel.   exports  
     . 
     exports      interface , 
  .  Delphi 1.0    
  DPR-.         
^:        ,   
      ,     . 
      exports       
,        .  
       . 

    exports 
    ExSetVolumeLabel index 1; 

              
   (   1).    
  ,         
.         .   
      .   ,   
Microsoft   JJIJSOB  .  
  - ,      " 
      ~ ". 
        Delphi 1.0     
Resident.   Win32      exports,  
 ,       
  . 
     Winl6,^^afifl?goMj^pjgiMaTe_NE^New Executable)    
  .   ,   
Resident,   ,       
,        . __> 
_? (Portable Executable)      
,    "9/^^5__.   
 DLT^-    . edata  .  
           26, 
" DLL:  ". 
    
    I  1 


     25.  DLL: 	601 

      implementation    
ExSetVolumeLabel.        
SetVolumeLabel  Win32,       . 
@**  ,     . 
   nil,      
  . 
    |||   Delphi 3    16- Delphi 1.0    
,      DLL       
 try. . . except  try. . . finally.         *^     
 Delphi 2.0,  Win32     
,  Delphi.  16-  Windows   . 
      pcName   nil,   SetVolumeLabel  
Win32.          
 ExSetVolumeLabel.      
     ,       GetLastError. 
         DLL_HJUi^OBce__OTKa3biBaeTCfl 
  ,        
.  ,   DLL   , , 
       .  
 26, " DLL:  ",    
Turbo Dump,         DLL  
   . 
          DLL     26, 
" DLL:  ".    
    5, "  ". 
  Turbo Dump    26, " DLL: 
 ". 

       DLL 

      DLL,       
.      LoadLibrary  LoadLibraryEx  
  Win32.  LoadLibrary  (  
)  16-  Windows.    LoadLibraryEx, 
      LoadLibrary     
32- . 
    ,  DLL      ,   , 
     .  Delphi   ,   
 .    Delphi    
    LoadLibrary  FreeLibrary (   
).     DLL     . 
    Delphi   LoadLibrary  LoadLibraryEx   Windows. 
 LoadLibrary   : 

    function  LoadLibrary(LibFileName:   PChar):   HMODULE;   stdcall; 

      LoadLibrary .      
PChar,      DLL.  DLL   
,      .    
LibFileName      ,  DLL   
 . 
    1.   ,    . 
    2.    . 
    3.    \WINDOWS\SYSTEM (   NT \Windows\System32,  
   16-  \System). 
    4.    \WINDOWS. 
    5.    ,    PATH ( autoexec. bat). 
     DLL   ,   0.    
 ,    GetLastError  Win32, 
  . 
     LoadLibraryEx   LoadLibrary,    
.   Windows     . 

    function  LoadLibraryEx(LibFileName:   PChar;   hFile:   THandle; 
    dwFlags:   DWORD):   HMODULE;   stdcall; 


    602	 VI.   

     GetLastError      . 
          
  .  -    ,    
Windows, pas   \\DELPHI3\SOURCE\RTL\WIN.       
    . ,   
   Win32   ,     GetLastError 
   15,     "15"   Windows . pas. 
   . (The system cannot find the drive specified}	"""" 

    ERROR_INVALID_DRIVE  =   15; 

            ;   
     . 
    ,*~ SyltJtiis"  SysErrorMessage,  
    ,      
.         
Windows .pas. 
     ,     LoadLibrary,   DLL-,  
      DLL.    
    ,        
 .  ,      0 
(       Get LastError). 
      LoadLibraryEx    .   
 , LibFileName,       LoadLibrary. 
    0 (  ).   
  DWORD      . 

     Dont_Resolve_DLL_References 

     Dont_Resolve_DLL_References      
  LoadLibraryEx.       , 
     Win95  WinNT. 
      Dont_Resolve_DLL_Ref erences    
    DLL (      LoadLibrary). 
    1.     DLLMain. 
    2.    DLL     DLL,     
       DLL    . 
    3.       DLL     DLL ( ). 
      DLL   .      
        
(    DLL   ),     
   Load_Library_As_DataFile,    
.    Load_Library_As_DataFil 
e|^1      Win95  WinNT. 

     Load_Library_As_DataFile 

     Load_Library_As_DataFile      
  LoadLibraryEx.    ,  
       ,   
     Windows.        
   ,  DLLMain  , 
,^_.       
 ,   LoadLibraryEx.    
  ,     . 
      1^??^^^?_^^13^?[. (, 
)  DLL-  -. ,   
LoadLibraryEx,       LoadResource, 
   .      
   LockResource,     
      ICO-.     
  LoadLibrary -      
  DLLMain      . 

      I 

     25.  DLL: 	603 

       Load_Library_As_DataFile  DLL  
 -.     LoadLibrary      
,      _StartLib,   
DLLMain,   ,      -.   
  Load_Library_As_DataFile     ^ 
   , -      
,  " '     . 

     LoadJtfith_Altered_Search_Path 

     Load_With_Altered_Search_Path      
  LoadLi-braryEx.     LoadLibraryEx ( 
,     )   DLL-,   
  .    ,  ,  
   LibFileName,    . 
    1.   ,    LibFileName. 
    2.    . 
    3.    \WINDOWS\SYSTEM (   NT \Windows\System32,  
   16-  \System). 
    4.    \WINDOWS. 
    5.    ,    PATH ( autoexec. bat). 
       DLL       
  ,     .    
 ,      .      
   -,        .  
Load_With_Altered_Search_Path       
  DLL,          
.    Load_With_Altered_Search_Path  
        ;    
   ,   . 

        FreeLibrary 

     LoadLibrary  LoadLibraryEx    HModule ( 
,     THandle).       0. 
       Windows 
      ,     
.      . 
    	EnumResourceNames 
    	LoadResource 
    	EnumResTypeProc 
    	FreeLibraryAndExitThread 
    	FindResourceEx 
    	GetProcAddress 
    	FreeLibrary 
       .    DLL  
  ,  Load-Library    
HMODUKE.       (   
LoadLibrary)   DLL  ,     
HMODULE,    .  
    DLL     .      
    LoadLibrary  LoadLibraryEx   1 
  .  ,    
  ,         
 . 
     DLL      ,   
     0.  ,  ,  
,  DLL  .    Win32   FreeLibrary.  
        DLL   , 
      I.      
FreeLibrary     0,     
  .   FreeLibrary,  
 Windows,   . 

    function  FreeLibrary(hLibModule:   HMODULE):   BOOL;   stdcall; 

     FreeLibrary     HMODULE. ,  , 
   ,   LoadLibrary  
LoadLibraryEx   DLL.      
FreeLibrary  True,   False.      
     GetLastError  Win32. 

    604	 VI.   

        LoadLibrary  FreeLibrary  
    DLL.       DLL  
 .    ,  DLL. ! 

     

      DLL,   ,   
 ,   DLL.     
 .   .  ...   , , 
  ,  DLL,       
,      (   
 DLL)   .     DLL   
 _. 
        ,   -.  
        ,  
  ,    .     
           
.           
.   .  ,     
 ,  . 
     Delphi         DLL. 
       . DLL       
  ,    Delphi   . 
       . DLL        
LoadLibrary,   -     
 GetProcAddress.	~, 
           . 
        ,  
, .   ,   ,   
      .   
 ,        . 

      

            Win32 
 LoadLibrary  LoadLibraryEx   DLL,   FreeLibrary  
 . Delphi    , 
    :LoadLikrary  FreeLibrary, 
  . 
     , Delphi         
    .     
Delphi        DLL  
    -.    
   -     , Windows 
        DLL,  , 
      . 
      Windows ,     DLL,  
  LoadLibrary.       DLL- , 
  ,  .   DLL ,   
     .   Windows 
     DLL-,    
  DLL .        , 
   ,  DLL    
   . 
       (Portable Executable)  
^^^^      32- 
 (  DLL) .   1" -     
    .     
    ,    
   .    , , 
     . 
      ,    (^jHMeHyeMbiH.-^data}, 
 ,       , 
 .    (. idata)    
  DLL       DLL  
 ' ". 
             
         .  
         . 
               26, 
" DLL:  ". 

     25.  DLL: 	605 

     ,   ^-   
  DLL-.    , 
" ,    ~ 
^-    DLL,    .  
 - Windows     ^.  
   .     , 
  . 
        .    
   DLL.    Delphi 
(VCL)      Win32.   , 
       Windows: Kernel32.dll, 
User32.dll, GDI32.dll  .    ,  
   DLL.         
 Windows   .  ,     DLL 
  .     .   
  . 25.2. 

     


    . 25.2.       DLL,  
.        DLL   DLL 
   

        GetNetUserlD  DLL NETTOOLS.DLL  
    . 
    function  GetNetUserlD(aUserName:   string):   longint;   StdCall; 
external   'NetTpols.^jdll'   Name   'GetNetUserlDA1; 
       ,  GetNetUserlD  . 
         procedure  
function.    (    GetNetUserlD).  
  ,    ^^^^  Name  
 ).    ~"1    
 ( ).         
.  ,       
,  .       
  ,    .   
"Wrri32;"TO   DLL Win32    
 StdCall.         
 external.    -,    
 DLL,   .      
! L    ,     
 DLL. 
      external       
Name.      -,    
 (~    function  procedure)  
: .^,      DLL.   
     Get-^   
  GetNetUserlDA.        
    GetNetUserlD. 

          '  

      Win32        
.    MessageBoxA  MessageBoxW.      
 ANSI, W  Wide (Wide Char).   Windows   
  . 

    function MessageBoxA;	external	'user32'   name	'MessageBoxA1; 
    function MessageBoxW;	external	'user32'   name	'MessageBoxW'; 
    function MessageBox;	external	'user32'   name	'MessageBoxA'; 

                
.  ,    MessageBox  
 ANSI.    ,   Wide Char, 
   MessageBoxW. 

    606  VI.   

    ^)&   , ?^ ^^^?_1525? 
̰-       ,   , 
^^^1^_?|1"6,'    , 
 , -^^^',    ,  
  . 

    var	 
    Forml: TForml; 
    function GetNetUserlD(aUserName: string): longint; StdCall; implementation 
{$R *.DFM} function GetNetUserlD; external 'NetTools.dll' Name 'GetNetUserlDA'; 
    end. 

           . 
     GetNetUserlD: 

    function GetNetUserlD(aUserName:   string):   longint;   StdCall; 
    external   'NetTools.dll'   index 25; 

          ,  
   ,       
  .         .  
 , ^ ^,   Microsoft    
   ,        
       . 
        _ .   
,       GetNetUserlD, a 
GetNetUserlDA.    ?    index   
   .     exports DLL   
511. "1~   25 
       , DLL    25 
  GetNetUserlDA.    ,    
,     .   
!         25,  . 
          ,  
      LoadLibrary, LoadLibraryEx  
FreeLibrary.      DLL  
     ,    
 .     DLL  
  .      DLL 
      .    
   DLL      
(i :        
     ,   .  
       . 

      

        ,  ^}1?|;_ 
J^^jr??Addj:.&s s    Win32     
_^ KaK_l,oadLibrary, LoadLibraryEx  FreeLibrary. ' 
      .   
   -   .  
  Pascal      ; 
        .   , 
 ,    25.5.  EXPORTING. DLL  
    . 

     25.5. \UDELPHI3\CHP25\LOADERU1. PAS.  EXPORTING. DLL 
 LoaderEXE 

    unit LoaderUl; 
    interface 
    uses 
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; 


     25.  DLL: 	607 


    type 
    TExSetVolumeLabgl^= procedure(pcName: PChar); StdCall; TForml = 
class(TForm)'" Buttonl: TButton; 
    procedure ButtonlClick(Sender: TObject); private 
    { Private declarations } public 
    { Public declarations } end; var 
    Forml: TForml; implementation {$R *.DFM} 
    procedure TForml.ButtonlClick(Sender: TObject); var .ExSetVolumeLabel: TExSetVolumeLabel; 
    hDHInst: THandleT""'"" begin 
    hDHInst := LoadLibrary( 'Exporting.dll '); if hDHInst <="Tf"then 
    Raise Exception.Create('[LoadLibrary Fail] GetLastError reports: '+ 
    IntToStr(GetLastError)) ; try' 
    _?ExSetVolumeLabel := GetPrQ,cAddress (hDHInst, 'ExSetVolumeLabel' ) ; if 
not Assigned(ExSetVolumeLabel) then 
    Raise Exception.Create('[GetProcAddress Fail] GetLastError reports: '+ 
    IntToStr(GetLastError)); ExS^etVolvmeLabel (' BOOT DRIVE1) ; 
finally	- -.. 
    FreeLibrary(hDHInst) ; end;  ~*~-~  
    end; end. 

           Delphi  
    .    
,     type: 

    TExSetVolumeLabel  = procedure(pcName:   PChar);   StdCall; 

          TExSetVolumeLabel,  
   StdCall     PChar.   
   ExSetVolumeLabel,   
Exporting. dll.      .   
     ,   pcName. 
      25.4   DLL,   
ExSetVolumeLabel.  
    	     ExportUl ^-; 
_._ porting,     
Exporting.dll.    ,      , 
    . 
            . 
    TForml.. ButtonClick   
    DLL,   ExSetVolumeLabel 
  Exporting. dll   DLL. 
         : 

    var  ExSetVolumeLabel:   TExSetVolumeLabel; hDHInst:   THandle; 

     ,   ExSetVolumeLabel   
TExSetVolumeLabel.       DLL.   
 hDHInst     LoadLibrary. 

    hDHInst   := LoadLibrary ('Exporting.dll1 ); if hDHInst =  0  then 
    Raise Exception.Create('[LoadLibrary Fail]   GetLastError  reports:   '   + 
    IntToStr(GetLastError)); 


    608	 VI.   

      LoadLibrary.       
 Exporting.dll.  Win32  LoadLibrary  0,  DLL  
 .      .  
 hDHInst   ,   
.        ,   
  Win32 GetLastError. 
     DLL  ,   GetProcAddress, 
      ExSetVolumeLabel, 
   Exporting.dll. 

    @ExSetVolumeLabel   :=  GetProcAddress(hDHInst,    'ExSetVolumeLabel1); if 
 not  Assigned(ExSetVolumeLabel)   then 
    Raise  Exception.Create('[GetProcAddress   Fail]   GetLastError  reports:  
  '   + 
    IntToStr(GetLastError)); 

     ExSetVolumeLabel   ,     
 ^,  -     '/ |   ,  ,  
 GetProcAddress,    ExSetVolumeLabel.  j   
    GetProcAddress   DLL, 
  Load-Library,     , 
 DLL.     GetProcAddress  
,  ExSetVolumeLabel   nil. 
       ExSetVolumeLabel  nil   
  Assigned.    nil,    
       ,   
Win32 GetLastError.   ExSetVolumeLabel   nil,  
 ExSetVolumeLabel.         
 "BOOT DRIVE": 

    ExSetVolumeLabel('BOOT   DRIVE'); 

        ExSetVolumeLabel    
FreeLibrary,   

    Exporting.dll: 
    FreeLibrary (hDHInst) ; 

      25.5     DLL.  
 ,   ,   . ,  TForml. 
ButtonlClick    .       
.     ,    
:       
          
LoadLibrary  FreeLibrary?     ,    
  -"^ . 

     

               DLL  
,     ,     
16- DLL   Win32.  ,    
  ,    .     
     . 

     25.  DLL: 	609 
    20  Delphi 3.   

