comparison src/util_win.c @ 0:147b08bc7d64

Initial commit of a basic Application framework.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 23 Mar 2015 12:41:52 +0100
parents
children 9daf778feaf1
comparison
equal deleted inserted replaced
-1:000000000000 0:147b08bc7d64
1 #ifdef WIN32
2 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
3 * Software engineering by Intevation GmbH
4 *
5 * This file is Free Software under the GNU GPL (v>=2)
6 * and comes with ABSOLUTELY NO WARRANTY!
7 * See LICENSE.txt for details.
8 */
9
10 /**@file Linux implementation of functions declared in util.h */
11
12 #include "util.h"
13 #include "strhelp.h"
14
15 #include <windows.h>
16
17 char *
18 get_install_dir()
19 {
20 wchar_t wPath[MAX_PATH];
21 char *utf8path = NULL;
22 char *dirsep = NULL;
23
24 if (!GetModuleFileNameW (NULL, wPath, MAX_PATH - 1))
25 {
26 return NULL;
27 }
28
29 /* wPath might not be 0 terminated */
30 wPath[MAX_PATH - 1] = '\0';
31
32 utf8path = wchar_to_utf8 (wPath, wcsnlen(wPath, MAX_PATH));
33
34 if (utf8path == NULL)
35 {
36 return NULL;
37 }
38
39 /* Cut away the executable name */
40 dirsep = strrchr(utf8path, '\\');
41 if (dirsep == NULL)
42 {
43 return NULL;
44 }
45 *dirsep = '\0';
46 return utf8path;
47 }
48 #endif
49
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)