home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 September / PCO_0998.ISO / filesbbs / os2 / fml2_142.arj / FMSTRUCT.ZIP / DELPHI.ZIP / CFGFILEC.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-02-02  |  3.0 KB  |  132 lines

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