2 * util.c: Simple runtime tools for the Win32 platform
7 * (C) 2002 Ximian, Inc. (http://www.ximian.com)
11 #include <mono/metadata/metadata.h>
12 #include <mono/metadata/assembly.h>
13 #include <mono/os/util.h>
16 #undef GetModuleFileName
17 #define GetModuleFileName ceGetModuleFileNameA
19 DWORD ceGetModuleFileNameA(HMODULE hModule, char* lpFilename, DWORD nSize)
22 wchar_t* wbuff = (wchar_t*)LocalAlloc(LPTR, nSize*2);
23 res = GetModuleFileNameW(hModule, wbuff, nSize);
25 int len = wcslen(wbuff);
26 WideCharToMultiByte(CP_ACP, 0, wbuff, len, lpFilename, len, NULL, NULL);
36 * Informs the runtime of the root directory for the Mono installation,
40 mono_set_rootdir (void)
42 gunichar2 moddir [MAXPATHLEN];
43 gchar *bindir, *installdir, *root, *utf8name, *config;
45 GetModuleFileNameW (NULL, moddir, MAXPATHLEN);
46 utf8name = g_utf16_to_utf8 (moddir, -1, NULL, NULL, NULL);
47 bindir = g_path_get_dirname (utf8name);
48 installdir = g_path_get_dirname (bindir);
49 root = g_build_path (G_DIR_SEPARATOR_S, installdir, "lib", NULL);
51 config = g_build_filename (root, "..", "etc", NULL);
52 mono_set_dirs (root, config);