Add changes file for bug40642.
[tor.git] / src / lib / fs / winlib.c
blob827bc23f9b6002491e0f6446d51a498b43721502
1 /* Copyright (c) 2003, Roger Dingledine
2 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3 * Copyright (c) 2007-2021, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
6 /**
7 * \file winlib.c
9 * \brief Find and load windows system libraries.
11 * We use this function to dynamically load code at runtime that might not be
12 * available on all versions of Windows that we support.
13 **/
15 #ifdef _WIN32
16 #include "lib/fs/winlib.h"
18 HANDLE
19 load_windows_system_library(const TCHAR *library_name)
21 TCHAR path[MAX_PATH];
22 unsigned n;
23 n = GetSystemDirectory(path, MAX_PATH);
24 if (n == 0 || n + _tcslen(library_name) + 2 >= MAX_PATH)
25 return 0;
26 _tcscat(path, TEXT("\\"));
27 _tcscat(path, library_name);
28 return LoadLibrary(path);
30 #endif /* defined(_WIN32) */