1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = glib-Windows-Compatibility-Functions.html
27  * outPack = glib
28  * outFile = WindowsUtils
29  * strct   = 
30  * realStrct=
31  * ctorStrct=
32  * clss    = WindowsUtils
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_win32_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * structWrap:
48  * module aliases:
49  * local aliases:
50  * overrides:
51  */
52 
53 module glib.WindowsUtils;
54 
55 public  import gtkc.glibtypes;
56 
57 private import gtkc.glib;
58 private import glib.ConstructionException;
59 
60 
61 private import glib.Str;
62 
63 
64 
65 
66 /**
67  * Description
68  * These functions provide some level of UNIX emulation on the Windows platform.
69  * If your application really needs the POSIX APIs, we suggest you try the Cygwin
70  * project.
71  */
72 public class WindowsUtils
73 {
74 	
75 	/**
76 	 */
77 	
78 	/**
79 	 * Translate a Win32 error code (as returned by GetLastError()) into
80 	 * the corresponding message. The message is either language neutral,
81 	 * or in the thread's language, or the user's language, the system's
82 	 * language, or US English (see docs for FormatMessage()). The
83 	 * returned string is in UTF-8. It should be deallocated with
84 	 * g_free().
85 	 * Params:
86 	 * error = error code.
87 	 * Returns: newly-allocated error message
88 	 */
89 	public static string errorMessage(int error)
90 	{
91 		// gchar * g_win32_error_message (gint error);
92 		return Str.toString(g_win32_error_message(error));
93 	}
94 	
95 	/**
96 	 * The setlocale() function in the Microsoft C library uses locale
97 	 * names of the form "English_United States.1252" etc. We want the
98 	 * UNIXish standard form "en_US", "zh_TW" etc. This function gets the
99 	 * current thread locale from Windows - without any encoding info -
100 	 * and returns it as a string of the above form for use in forming
101 	 * file names etc. The returned string should be deallocated with
102 	 * g_free().
103 	 * Returns: newly-allocated locale name.
104 	 */
105 	public static string getlocale()
106 	{
107 		// gchar * 		 g_win32_getlocale (void);
108 		return Str.toString(g_win32_getlocale());
109 	}
110 	
111 	/**
112 	 * This function tries to determine the installation directory of a
113 	 * software package based on the location of a DLL of the software
114 	 * package.
115 	 * hmodule should be the handle of a loaded DLL or NULL. The
116 	 * function looks up the directory that DLL was loaded from. If
117 	 * hmodule is NULL, the directory the main executable of the current
118 	 * process is looked up. If that directory's last component is "bin"
119 	 * or "lib", its parent directory is returned, otherwise the directory
120 	 * itself.
121 	 * It thus makes sense to pass only the handle to a "public" DLL of a
122 	 * software package to this function, as such DLLs typically are known
123 	 * to be installed in a "bin" or occasionally "lib" subfolder of the
124 	 * installation folder. DLLs that are of the dynamically loaded module
125 	 * or plugin variety are often located in more private locations
126 	 * deeper down in the tree, from which it is impossible for GLib to
127 	 * deduce the root of the package installation.
128 	 * The typical use case for this function is to have a DllMain() that
129 	 * saves the handle for the DLL. Then when code in the DLL needs to
130 	 * construct names of files in the installation tree it calls this
131 	 * function passing the DLL handle.
132 	 * Since 2.16
133 	 * Params:
134 	 * hmodule = The Win32 handle for a DLL loaded into the current process, or NULL
135 	 * Returns: a string containing the guessed installation directory for the software package hmodule is from. The string is in the GLib file name encoding, i.e. UTF-8. The return value should be freed with g_free() when not needed any longer. If the function fails NULL is returned.
136 	 */
137 	public static string getPackageInstallationDirectoryOfModule(void* hmodule)
138 	{
139 		// gchar * g_win32_get_package_installation_directory_of_module  (gpointer hmodule);
140 		return Str.toString(g_win32_get_package_installation_directory_of_module(hmodule));
141 	}
142 	
143 	/**
144 	 * Returns version information for the Windows operating system the
145 	 * code is running on. See MSDN documentation for the GetVersion()
146 	 * function. To summarize, the most significant bit is one on Win9x,
147 	 * and zero on NT-based systems. Since version 2.14, GLib works only
148 	 * on NT-based systems, so checking whether your are running on Win9x
149 	 * in your own software is moot. The least significant byte is 4 on
150 	 * Windows NT 4, and 5 on Windows XP. Software that needs really
151 	 * detailled version and feature information should use Win32 API like
152 	 * GetVersionEx() and VerifyVersionInfo().
153 	 * Since 2.6
154 	 * Returns: The version information.
155 	 */
156 	public static uint getWindowsVersion()
157 	{
158 		// guint g_win32_get_windows_version (void);
159 		return g_win32_get_windows_version();
160 	}
161 	
162 	/**
163 	 * Converts a filename from UTF-8 to the system codepage.
164 	 * On NT-based Windows, on NTFS file systems, file names are in
165 	 * Unicode. It is quite possible that Unicode file names contain
166 	 * characters not representable in the system codepage. (For instance,
167 	 * Greek or Cyrillic characters on Western European or US Windows
168 	 * installations, or various less common CJK characters on CJK Windows
169 	 * installations.)
170 	 * In such a case, and if the filename refers to an existing file, and
171 	 * the file system stores alternate short (8.3) names for directory
172 	 * entries, the short form of the filename is returned. Note that the
173 	 * "short" name might in fact be longer than the Unicode name if the
174 	 * Unicode name has very short pathname components containing
175 	 * non-ASCII characters. If no system codepage name for the file is
176 	 * possible, NULL is returned.
177 	 * The return value is dynamically allocated and should be freed with
178 	 * g_free() when no longer needed.
179 	 * Since 2.8
180 	 * Params:
181 	 * utf8filename = a UTF-8 encoded filename.
182 	 * Returns: The converted filename, or NULL on conversion failure and lack of short names.
183 	 */
184 	public static string localeFilenameFromUtf8(string utf8filename)
185 	{
186 		// gchar * g_win32_locale_filename_from_utf8 (const gchar *utf8filename);
187 		return Str.toString(g_win32_locale_filename_from_utf8(Str.toStringz(utf8filename)));
188 	}
189 }