📄 glib-windows-compatibility-functions.html
字号:
</p><p>It thus makes sense to pass only the handle to a "public" DLL of asoftware package to this function, as such DLLs typically are knownto be installed in a "bin" or occasionally "lib" subfolder of theinstallation folder. DLLs that are of the dynamically loaded moduleor plugin variety are often located in more private locationsdeeper down in the tree, from which it is impossible for GLib todeduce the root of the package installation.</p><p>The typical use case for this function is to have a <code class="function">DllMain()</code> thatsaves the handle for the DLL. Then when code in the DLL needs toconstruct names of files in the installation tree it calls thisfunction passing the DLL handle.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>hmodule</code></em> :</span></p></td><td> The Win32 handle for a DLL loaded into the current process, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a></td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> a string containing the guessed installation directory forthe software package <em class="parameter"><code>hmodule</code></em> is from. The string is in the GLibfile name encoding, i.e. UTF-8. The return value should be freedwith <a class="link" href="glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a> when not needed any longer. If the function fails<a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> is returned.</td></tr></tbody></table></div><p class="since">Since 2.16</p></div><hr><div class="refsect2" lang="en"><a name="id3226821"></a><h3><a name="g-win32-get-package-installation-subdirectory"></a>g_win32_get_package_installation_subdirectory ()</h3><a class="indexterm" name="id3226835"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar">gchar</a>* g_win32_get_package_installation_subdirectory (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *package, const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *dll_name, const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *subdir);</pre><p>This function will be deprecated in the future. Use<a class="link" href="glib-Windows-Compatibility-Functions.html#g-win32-get-package-installation-directory-of-module"><code class="function">g_win32_get_package_installation_directory_of_module()</code></a> instead.</p><p>Returns a newly-allocated string containing the path of thesubdirectory <em class="parameter"><code>subdir</code></em> in the return value from calling<a class="link" href="glib-Windows-Compatibility-Functions.html#g-win32-get-package-installation-directory"><code class="function">g_win32_get_package_installation_directory()</code></a> with the <em class="parameter"><code>package</code></em> and<em class="parameter"><code>dll_name</code></em> parameters. See the documentation for<a class="link" href="glib-Windows-Compatibility-Functions.html#g-win32-get-package-installation-directory"><code class="function">g_win32_get_package_installation_directory()</code></a> for more details. Inparticular, note that it is deprecated to pass anything except NULLas <em class="parameter"><code>package</code></em>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>package</code></em> :</span></p></td><td> You should pass <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> for this.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>dll_name</code></em> :</span></p></td><td> The name of a DLL that a package provides, in UTF-8, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>subdir</code></em> :</span></p></td><td> A subdirectory of the package installation directory, also in UTF-8</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> a string containing the complete path to <em class="parameter"><code>subdir</code></em> insidethe installation directory of <em class="parameter"><code>package</code></em>. The returned string is inthe GLib file name encoding, i.e. UTF-8. The return value should befreed with <a class="link" href="glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a> when no longer needed. If something goes wrong,<a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> is returned.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3227067"></a><h3><a name="g-win32-get-windows-version"></a>g_win32_get_windows_version ()</h3><a class="indexterm" name="id3227083"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint">guint</a> g_win32_get_windows_version (void);</pre><p>Returns version information for the Windows operating system thecode is running on. See MSDN documentation for the <code class="function">GetVersion()</code>function. To summarize, the most significant bit is one on Win9x,and zero on NT-based systems. Since version 2.14, GLib works onlyon NT-based systems, so checking whether your are running on Win9xin your own software is moot. The least significant byte is 4 onWindows NT 4, and 5 on Windows XP. Software that needs reallydetailled version and feature information should use Win32 API like<code class="function">GetVersionEx()</code> and <code class="function">VerifyVersionInfo()</code>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> The version information.</td></tr></tbody></table></div><p class="since">Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id3227172"></a><h3><a name="g-win32-locale-filename-from-utf8"></a>g_win32_locale_filename_from_utf8 ()</h3><a class="indexterm" name="id3227188"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar">gchar</a>* g_win32_locale_filename_from_utf8 (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *utf8filename);</pre><p>Converts a filename from UTF-8 to the system codepage.</p><p>On NT-based Windows, on NTFS file systems, file names are inUnicode. It is quite possible that Unicode file names containcharacters not representable in the system codepage. (For instance,Greek or Cyrillic characters on Western European or US Windowsinstallations, or various less common CJK characters on CJK Windowsinstallations.)</p><p>In such a case, and if the filename refers to an existing file, andthe file system stores alternate short (8.3) names for directoryentries, the short form of the filename is returned. Note that the"short" name might in fact be longer than the Unicode name if theUnicode name has very short pathname components containingnon-ASCII characters. If no system codepage name for the file ispossible, <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> is returned.</p><p>The return value is dynamically allocated and should be freed with<a class="link" href="glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a> when no longer needed.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>utf8filename</code></em> :</span></p></td><td> a UTF-8 encoded filename.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> The converted filename, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on conversionfailure and lack of short names.</td></tr></tbody></table></div><p class="since">Since 2.8</p></div><hr><div class="refsect2" lang="en"><a name="id3227312"></a><h3><a name="G-WIN32-DLLMAIN-FOR-DLL-NAME:CAPS"></a>G_WIN32_DLLMAIN_FOR_DLL_NAME()</h3><a class="indexterm" name="id3227325"></a><pre class="programlisting">#define G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name)</pre><p>On Windows, this macro defines a <code class="function">DllMain()</code> function that stores the actual DLL name that the code being compiled will be included in.</p><p>On non-Windows platforms, expands to nothing.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>static</code></em> :</span></p></td><td>empty or "static".</td></tr><tr><td><p><span class="term"><em class="parameter"><code>dll_name</code></em> :</span></p></td><td>the name of the (pointer to the) char array where the DLL name will be stored. If this is used, you must also include <code class="filename">windows.h</code>. If you need a more complex DLL entry point function, you cannot use this.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3227399"></a><h3><a name="G-WIN32-HAVE-WIDECHAR-API:CAPS"></a>G_WIN32_HAVE_WIDECHAR_API()</h3><a class="indexterm" name="id3227415"></a><pre class="programlisting">#define G_WIN32_HAVE_WIDECHAR_API() TRUE</pre><p>On Windows, this macro defines an expression which evaluates to <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>if the code is running on a version of Windows where the widecharacter versions of the Win32 API functions, and the wide chaacterversions of the C library functions work. (They are always present inthe DLLs, but don't work on Windows 9x and Me.)</p><p>On non-Windows platforms, it is not defined.</p><p class="since">Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id3227457"></a><h3><a name="G-WIN32-IS-NT-BASED:CAPS"></a>G_WIN32_IS_NT_BASED()</h3><a class="indexterm" name="id3227472"></a><pre class="programlisting">#define G_WIN32_IS_NT_BASED() TRUE</pre><p>On Windows, this macro defines an expression which evaluates to <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the code is running on an NT-based Windows operating system.</p><p>On non-Windows platforms, it is not defined.</p><p class="since">Since 2.6</p></div></div><div class="refsect1" lang="en"><a name="id3227511"></a><div class="refsect2" lang="en"><a name="id3227512"></a></div><hr><div class="refsect2" lang="en"><a name="id3227513"></a></div></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -