home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 September / PCO_0998.ISO / filesbbs / dos / fmail142.exe / FMSTRUCT.ZIP / DELPHI.ZIP / CFGFILE.PAS next >
Encoding:
Pascal/Delphi Source File  |  1998-02-02  |  3.0 KB  |  131 lines

  1. unit CFGFILE;
  2. interface
  3. uses
  4. {$IFDEF WIN32}
  5.   Windows;
  6. {$ELSE}
  7.   Wintypes, WinProcs;
  8. {$ENDIF}
  9.  
  10.  
  11. {=> CFGFILE.H <=}
  12.  
  13. {+// }
  14. {-CFGFILE.H }
  15.  
  16. {-Config file interface header file for FMail 1.42g }
  17. {-Copyright (C) 1998 Folkert J. Wijnstra. All rights reserved. }
  18.  
  19. {-All information in this document is subject to change at any time }
  20. {-without prior notice! }
  21. {= }
  22.  
  23.  
  24. const
  25.   CFG_GENERAL = 0;
  26. const
  27.   CFG_NODES = 1;
  28. const
  29.   CFG_ECHOAREAS = 2;
  30. const
  31.   CFG_AREADEF = 3;
  32. const
  33.   MAX_CFG_FILES = 4;
  34.  
  35. var
  36.   openConfig: function(fileType: U16; 
  37.                        var header: HEADERTYPE*; 
  38.                        var buf: Pointer): S16 cdecl  {$IFDEF WIN32} stdcall {$ENDIF}; 
  39. var
  40.   getRec: function(fileType: U16; 
  41.                    index: S16): S16 cdecl  {$IFDEF WIN32} stdcall {$ENDIF}; 
  42. var
  43.   putRec: function(fileType: U16; 
  44.                    index: S16): S16 cdecl  {$IFDEF WIN32} stdcall {$ENDIF}; 
  45. var
  46.   insRec: function(fileType: U16; 
  47.                    index: S16): S16 cdecl  {$IFDEF WIN32} stdcall {$ENDIF}; 
  48. var
  49.   delRec: function(fileType: U16; 
  50.                    index: S16): S16 cdecl  {$IFDEF WIN32} stdcall {$ENDIF}; 
  51. var
  52.   chgNumRec: function(fileType: U16; 
  53.                       number: S16): S16 cdecl  {$IFDEF WIN32} stdcall {$ENDIF}; 
  54. var
  55.   closeConfig: function(fileType: U16): S16 cdecl  {$IFDEF WIN32} stdcall {$ENDIF}; 
  56.  
  57.  
  58. var
  59.   DLLLoaded: Boolean { is DLL (dynamically) loaded already? }
  60.     {$IFDEF WIN32} = False; {$ENDIF}
  61.  
  62. implementation
  63.  
  64. var
  65.   SaveExit: pointer;
  66.   DLLHandle: THandle;
  67. {$IFNDEF MSDOS}
  68.   ErrorMode: Integer;
  69. {$ENDIF}
  70.  
  71.   procedure NewExit; far;
  72.   begin
  73.     ExitProc := SaveExit;
  74.     FreeLibrary(DLLHandle)
  75.   end {NewExit};
  76.  
  77. procedure LoadDLL;
  78. begin
  79.   if DLLLoaded then Exit;
  80. {$IFNDEF MSDOS}
  81.   ErrorMode := SetErrorMode($8000{SEM_NoOpenFileErrorBox});
  82. {$ENDIF}
  83.   DLLHandle := LoadLibrary('CFGFILE.DLL');
  84.   if DLLHandle >= 32 then
  85.   begin
  86.     DLLLoaded := True;
  87.     SaveExit := ExitProc;
  88.     ExitProc := @NewExit;
  89.     @openConfig := GetProcAddress(DLLHandle,'openConfig');
  90.   {$IFDEF WIN32}
  91.     Assert(@openConfig <> nil);
  92.   {$ENDIF}
  93.     @getRec := GetProcAddress(DLLHandle,'getRec');
  94.   {$IFDEF WIN32}
  95.     Assert(@getRec <> nil);
  96.   {$ENDIF}
  97.     @putRec := GetProcAddress(DLLHandle,'putRec');
  98.   {$IFDEF WIN32}
  99.     Assert(@putRec <> nil);
  100.   {$ENDIF}
  101.     @insRec := GetProcAddress(DLLHandle,'insRec');
  102.   {$IFDEF WIN32}
  103.     Assert(@insRec <> nil);
  104.   {$ENDIF}
  105.     @delRec := GetProcAddress(DLLHandle,'delRec');
  106.   {$IFDEF WIN32}
  107.     Assert(@delRec <> nil);
  108.   {$ENDIF}
  109.     @chgNumRec := GetProcAddress(DLLHandle,'chgNumRec');
  110.   {$IFDEF WIN32}
  111.     Assert(@chgNumRec <> nil);
  112.   {$ENDIF}
  113.     @closeConfig := GetProcAddress(DLLHandle,'closeConfig');
  114.   {$IFDEF WIN32}
  115.     Assert(@closeConfig <> nil);
  116.   {$ENDIF}
  117.   end
  118.   else
  119.   begin
  120.     DLLLoaded := False;
  121.     { Error: CFGFILE.DLL could not be loaded !! }
  122.   end;
  123. {$IFNDEF MSDOS}
  124.   SetErrorMode(ErrorMode)
  125. {$ENDIF}
  126. end {LoadDLL};
  127.  
  128. begin
  129.   LoadDLL;
  130. end.
  131.