1 | {==============================================================================|
|
---|
2 | | Project : Ararat Synapse | 001.001.001 |
|
---|
3 | |==============================================================================|
|
---|
4 | | Content: Utils for FreePascal compatibility |
|
---|
5 | |==============================================================================|
|
---|
6 | | Copyright (c)1999-2007, Lukas Gebauer |
|
---|
7 | | All rights reserved. |
|
---|
8 | | |
|
---|
9 | | Redistribution and use in source and binary forms, with or without |
|
---|
10 | | modification, are permitted provided that the following conditions are met: |
|
---|
11 | | |
|
---|
12 | | Redistributions of source code must retain the above copyright notice, this |
|
---|
13 | | list of conditions and the following disclaimer. |
|
---|
14 | | |
|
---|
15 | | Redistributions in binary form must reproduce the above copyright notice, |
|
---|
16 | | this list of conditions and the following disclaimer in the documentation |
|
---|
17 | | and/or other materials provided with the distribution. |
|
---|
18 | | |
|
---|
19 | | Neither the name of Lukas Gebauer nor the names of its contributors may |
|
---|
20 | | be used to endorse or promote products derived from this software without |
|
---|
21 | | specific prior written permission. |
|
---|
22 | | |
|
---|
23 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
---|
24 | | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
---|
25 | | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
---|
26 | | ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR |
|
---|
27 | | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
---|
28 | | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
|
---|
29 | | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
|
---|
30 | | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
---|
31 | | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
---|
32 | | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
|
---|
33 | | DAMAGE. |
|
---|
34 | |==============================================================================|
|
---|
35 | | The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
|
---|
36 | | Portions created by Lukas Gebauer are Copyright (c)2003-2007. |
|
---|
37 | | All Rights Reserved. |
|
---|
38 | |==============================================================================|
|
---|
39 | | Contributor(s): |
|
---|
40 | |==============================================================================|
|
---|
41 | | History: see HISTORY.HTM from distribution package |
|
---|
42 | | (Found at URL: http://www.ararat.cz/synapse/) |
|
---|
43 | |==============================================================================}
|
---|
44 |
|
---|
45 | {:@exclude}
|
---|
46 |
|
---|
47 | {$IFDEF FPC}
|
---|
48 | {$MODE DELPHI}
|
---|
49 | {$ENDIF}
|
---|
50 | {$H+}
|
---|
51 |
|
---|
52 | unit synafpc;
|
---|
53 |
|
---|
54 | interface
|
---|
55 |
|
---|
56 | uses
|
---|
57 | {$IFDEF FPC}
|
---|
58 | dynlibs, sysutils;
|
---|
59 | {$ELSE}
|
---|
60 | {$IFDEF WIN32}
|
---|
61 | Windows;
|
---|
62 | {$ELSE}
|
---|
63 | SysUtils;
|
---|
64 | {$ENDIF}
|
---|
65 | {$ENDIF}
|
---|
66 |
|
---|
67 | {$IFDEF FPC}
|
---|
68 | type
|
---|
69 | TLibHandle = dynlibs.TLibHandle;
|
---|
70 |
|
---|
71 | function LoadLibrary(ModuleName: PChar): TLibHandle;
|
---|
72 | function FreeLibrary(Module: TLibHandle): LongBool;
|
---|
73 | function GetProcAddress(Module: TLibHandle; Proc: PChar): Pointer;
|
---|
74 | function GetModuleFileName(Module: TLibHandle; Buffer: PChar; BufLen: Integer): Integer;
|
---|
75 | {$ELSE}
|
---|
76 | type
|
---|
77 | {$IFDEF CIL}
|
---|
78 | TLibHandle = Integer;
|
---|
79 | {$ELSE}
|
---|
80 | TLibHandle = HModule;
|
---|
81 | {$ENDIF}
|
---|
82 | {$IFDEF VER100}
|
---|
83 | LongWord = DWord;
|
---|
84 | {$ENDIF}
|
---|
85 | {$ENDIF}
|
---|
86 |
|
---|
87 | procedure Sleep(milliseconds: Cardinal);
|
---|
88 |
|
---|
89 |
|
---|
90 | implementation
|
---|
91 |
|
---|
92 | {==============================================================================}
|
---|
93 | {$IFDEF FPC}
|
---|
94 | function LoadLibrary(ModuleName: PChar): TLibHandle;
|
---|
95 | begin
|
---|
96 | Result := dynlibs.LoadLibrary(Modulename);
|
---|
97 | end;
|
---|
98 |
|
---|
99 | function FreeLibrary(Module: TLibHandle): LongBool;
|
---|
100 | begin
|
---|
101 | Result := dynlibs.UnloadLibrary(Module);
|
---|
102 | end;
|
---|
103 |
|
---|
104 | function GetProcAddress(Module: TLibHandle; Proc: PChar): Pointer;
|
---|
105 | begin
|
---|
106 | Result := dynlibs.GetProcedureAddress(Module, Proc);
|
---|
107 | end;
|
---|
108 |
|
---|
109 | function GetModuleFileName(Module: TLibHandle; Buffer: PChar; BufLen: Integer): Integer;
|
---|
110 | begin
|
---|
111 | Result := 0;
|
---|
112 | end;
|
---|
113 |
|
---|
114 | {$ELSE}
|
---|
115 | {$ENDIF}
|
---|
116 |
|
---|
117 | procedure Sleep(milliseconds: Cardinal);
|
---|
118 | begin
|
---|
119 | {$IFDEF WIN32}
|
---|
120 | {$IFDEF FPC}
|
---|
121 | sysutils.sleep(milliseconds);
|
---|
122 | {$ELSE}
|
---|
123 | windows.sleep(milliseconds);
|
---|
124 | {$ENDIF}
|
---|
125 | {$ELSE}
|
---|
126 | sysutils.sleep(milliseconds);
|
---|
127 | {$ENDIF}
|
---|
128 |
|
---|
129 | end;
|
---|
130 |
|
---|
131 | end.
|
---|