1 //===- Win32/DynamicLibrary.cpp - Win32 DL Implementation -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Reid Spencer and is distributed under the
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file provides the Win32 specific implementation of the DynamicLibrary
12 //===----------------------------------------------------------------------===//
19 //===----------------------------------------------------------------------===//
20 //=== WARNING: Implementation here must contain only Win32 specific code
21 //=== and must not be UNIX code
22 //===----------------------------------------------------------------------===//
24 DynamicLibrary::DynamicLibrary() : handle(0) {
25 handle = (void*) GetModuleHandle(NULL);
28 ThrowError("Can't GetModuleHandle: ");
32 DynamicLibrary::DynamicLibrary(const char*filename) : handle(0) {
33 handle = LoadLibrary(filename);
36 ThrowError("Can't LoadLibrary: ");
40 DynamicLibrary::~DynamicLibrary() {
41 assert(handle !=0 && "Invalid DynamicLibrary handle");
43 FreeLibrary((HMODULE*)handle);
46 void *DynamicLibrary::GetAddressOfSymbol(const char *symbolName) {
47 assert(handle !=0 && "Invalid DynamicLibrary handle");
48 return (void*) GetProcAddress((HMODULE*)handle, symbolName);
53 // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab