25
25
<link linkend="gchar">gchar</link>* <link linkend="g-win32-get-package-installation-directory">g_win32_get_package_installation_directory</link>
26
26
(const <link linkend="gchar">gchar</link> *package,
27
27
const <link linkend="gchar">gchar</link> *dll_name);
28
<link linkend="gchar">gchar</link>* <link linkend="g-win32-get-package-installation-directory-of-module">g_win32_get_package_installation_directory_of_module</link>
29
(<link linkend="gpointer">gpointer</link> hmodule);
28
30
<link linkend="gchar">gchar</link>* <link linkend="g-win32-get-package-installation-subdirectory">g_win32_get_package_installation_subdirectory</link>
29
31
(const <link linkend="gchar">gchar</link> *package,
30
32
const <link linkend="gchar">gchar</link> *dll_name,
171
173
</simpara></listitem></varlistentry>
172
174
</variablelist></refsect2>
176
<title><anchor id="g-win32-get-package-installation-directory-of-module" role="function" condition="since:2.16"/>g_win32_get_package_installation_directory_of_module ()</title>
177
<indexterm role="2.16"><primary>g_win32_get_package_installation_directory_of_module</primary></indexterm><programlisting><link linkend="gchar">gchar</link>* g_win32_get_package_installation_directory_of_module
178
(<link linkend="gpointer">gpointer</link> hmodule);</programlisting>
180
This function tries to determine the installation directory of a
181
software package based on the location of a DLL of the software
185
<parameter>hmodule</parameter> should be the handle of a loaded DLL or <link linkend="NULL:CAPS"><literal>NULL</literal></link>. The
186
function looks up the directory that DLL was loaded from. If
187
<parameter>hmodule</parameter> is NULL, the directory the main executable of the current
188
process is looked up. If that directory's last component is "bin"
189
or "lib", its parent directory is returned, otherwise the directory
193
It thus makes sense to pass only the handle to a "public" DLL of a
194
software package to this function, as such DLLs typically are known
195
to be installed in a "bin" or occasionally "lib" subfolder of the
196
installation folder. DLLs that are of the dynamically loaded module
197
or plugin variety are often located in more private locations
198
deeper down in the tree, from which it is impossible for GLib to
199
deduce the root of the package installation.
202
The typical use case for this function is to have a <link linkend="DllMain"><function>DllMain()</function></link> that
203
saves the handle for the DLL. Then when code in the DLL needs to
204
construct names of files in the installation tree it calls this
205
function passing the DLL handle.</para>
208
</para><variablelist role="params">
209
<varlistentry><term><parameter>hmodule</parameter> :</term>
210
<listitem><simpara> The Win32 handle for a DLL loaded into the current process, or <link linkend="NULL:CAPS"><literal>NULL</literal></link>
211
</simpara></listitem></varlistentry>
212
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> a string containing the guessed installation directory for
213
the software package <parameter>hmodule</parameter> is from. The string is in the GLib
214
file name encoding, i.e. UTF-8. The return value should be freed
215
with <link linkend="g-free"><function>g_free()</function></link> when not needed any longer. If the function fails
216
<link linkend="NULL:CAPS"><literal>NULL</literal></link> is returned.
218
</simpara></listitem></varlistentry>
219
</variablelist><para role="since">Since 2.16
174
222
<title><anchor id="g-win32-get-package-installation-subdirectory" role="function"/>g_win32_get_package_installation_subdirectory ()</title>
175
223
<indexterm><primary>g_win32_get_package_installation_subdirectory</primary></indexterm><programlisting><link linkend="gchar">gchar</link>* g_win32_get_package_installation_subdirectory
176
224
(const <link linkend="gchar">gchar</link> *package,