1 karl 1.5 //%2003////////////////////////////////////////////////////////////////////////
|
2 chip 1.1 //
|
3 karl 1.5 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development
4 // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
|
7 chip 1.1 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
|
14 karl 1.5 //
|
15 chip 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
16 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
18 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24 //==============================================================================
25 //
26 // Author: Chip Vincent (cvincent@us.ibm.com)
27 //
28 // Modified By:
29 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #include "DynamicLibrary.h"
33
34 PEGASUS_NAMESPACE_BEGIN
35
|
36 chip 1.2 Boolean DynamicLibrary::load(void)
|
37 chip 1.1 {
|
38 chip 1.4 // ensure the module is not already loaded
39 PEGASUS_ASSERT(isLoaded() == false);
|
40 chip 1.1
|
41 chip 1.4 CString cstr = _fileName.getCString();
|
42 chip 1.1
|
43 chip 1.4 _handle = LoadLibrary(cstr);
|
44 chip 1.1
|
45 chip 1.4 return(isLoaded());
|
46 chip 1.1 }
47
|
48 chip 1.2 Boolean DynamicLibrary::unload(void)
|
49 chip 1.1 {
|
50 chip 1.4 // ensure the module is loaded
51 PEGASUS_ASSERT(isLoaded() == true);
52
53 FreeLibrary(_handle);
54
55 _handle = 0;
|
56 chip 1.1
|
57 chip 1.4 return(isLoaded());
58 }
|
59 chip 1.1
|
60 chip 1.4 Boolean DynamicLibrary::isLoaded(void) const
61 {
62 return(_handle != 0);
|
63 chip 1.1 }
64
65 DynamicLibrary::LIBRARY_SYMBOL DynamicLibrary::getSymbol(const String & symbolName)
66 {
67 LIBRARY_SYMBOL func = 0;
68
|
69 chip 1.4 if(isLoaded())
|
70 chip 1.1 {
71 // convert Char16 data to ascii
72 CString cstr = symbolName.getCString();
73
|
74 chip 1.4 func = (LIBRARY_SYMBOL)GetProcAddress(_handle, (const char *)cstr);
|
75 chip 1.1 }
76
77 return(func);
78 }
79
80 PEGASUS_NAMESPACE_END
|