Hi Stefano,<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
if KLone has been started by the Service Manager the ctx-&gt;hServiceStatus will be set:<br>
<br>
--------------------------------------------------<br>
#include &lt;klone/context.h&gt;<br>
if(ctx-&gt;hServiceStatus)<br>
        ; /* service mode */<br>
else<br>
        ; /* application mode */<br>
--------------------------------------------------<br></blockquote><div><br>perfect, it&#39;s exactly what I wanted :)<br></div><div><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">


<br>
Also &quot;GetModuleFileName(GetModuleHandle(NULL), buffer, bufsz)&quot; should return the full path of the kloned executable; I&#39;m not 100% sure that it works properly in service mode but it&#39;s worth a try :)<br></blockquote>

<div><br>it&#39;s ok in application and service mode.<br><br>The problem is solved.<br><br>Thank you at all team.<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">


<br>
bye,<br>
<font color="#888888">stefano<br>
</font><div><div class="h5"><br>
<br>
On 26/nov/2009, at 11.30, Mickael Auger wrote:<br>
<br>
&gt; Hi,<br>
&gt;<br>
&gt; I agree with you.<br>
&gt;<br>
&gt; For my issue, I don&#39;t know in advance the installation directory (it&#39;s a customer choice), so I cannot use the &quot;chroot&quot; key in internal kloned.conf and I want not use an external (visible/editable) kloned.conf.<br>


&gt;<br>
&gt; When kloned is launched, the execution directory is either the installation directory (in application mode) or fixed by Windows (in service mode).<br>
&gt; So in the service mode, I must call SetCurrentDirectory() with the value of ImagePath key that I determine myself (without touch source code of kloned).<br>
&gt;<br>
&gt; I want just know if kloned.exe is launched in application mode or service mode (as global boolean flag).<br>
&gt;<br>
&gt; Greetings.<br>
&gt;<br>
&gt; 2009/11/26 Steven Dorigotti &lt;<a href="mailto:dorigotti@koanlogic.com">dorigotti@koanlogic.com</a>&gt;<br>
&gt; Dear Mickaël,<br>
&gt;<br>
&gt;  what you are suggesting, to detect whether KLone is running in<br>
&gt; service mode or not, is definitely feasible but shouldn&#39;t be necessary<br>
&gt; for transparency. It&#39;s not usually the responsibility of an<br>
&gt; application to know how it was launched, rather such job could be done<br>
&gt; by a higher installation layer. It would also require more<br>
&gt; windows-specific code.<br>
&gt;<br>
&gt;  If you set a fixed chroot path in the configuration file and let<br>
&gt; KLone change directory for you as with our last patch you have a<br>
&gt; generic solution for knowing where KLone is being executed which works<br>
&gt; under all environments.<br>
&gt;<br>
&gt;  Or is your issue still out of sight?<br>
&gt;<br>
&gt; let us know,<br>
&gt; sd<br>
&gt;<br>
&gt; 2009/11/26 Mickael Auger &lt;<a href="mailto:mickael.auger@gmail.com">mickael.auger@gmail.com</a>&gt;:<br>
&gt; &gt; Hi,<br>
&gt; &gt;<br>
&gt; &gt; thank you for your patch.<br>
&gt; &gt;<br>
&gt; &gt; Hovewer, in Windows service mode I will search the<br>
&gt; &gt; &quot;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\kloned\ImagePath&quot; key in<br>
&gt; &gt; Windows registry to know the kloned.exe installation directory and call<br>
&gt; &gt; SetCurrentDirectory to it in &quot;server_init&quot; hook.<br>
&gt; &gt;<br>
&gt; &gt; So, I would like know the kloned execution mode (application or service).<br>
&gt; &gt; Have you a solution to distinct this execution mode (kloned launched with<br>
&gt; &gt; WinMain() or ServiceMain() functions in entry.c) ?<br>
&gt; &gt;<br>
&gt; &gt; Bye.<br>
&gt; &gt;<br>
&gt; &gt; 2009/11/25 Steven Dorigotti &lt;<a href="mailto:dorigotti@koanlogic.com">dorigotti@koanlogic.com</a>&gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Hi!<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;  Ok, your problem is more clear to us now.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;  Please try the attached patch (using KLONE_TARGET_PATCH_FILE for<br>
&gt; &gt;&gt; local build or KLONE_HOST_PATCH_FILE for cross-compilation) and setup<br>
&gt; &gt;&gt; your base path in the kloned configuration file as follows:<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;  chroot    c:/your/base/dir<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;  The server will then do the SetCurrentDirectory() on MinGW as you<br>
&gt; &gt;&gt; suggested.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; cheers,<br>
&gt; &gt;&gt; sd<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; 2009/11/25 Mickael Auger &lt;<a href="mailto:mickael.auger@gmail.com">mickael.auger@gmail.com</a>&gt;:<br>
&gt; &gt;&gt; &gt; Hi Steven,<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; thank you for response but it&#39;s my question (sorry :(  ).<br>
&gt; &gt;&gt; &gt; For example, I have an installation folder &quot;C:\ProgramFiles\KLoneApp&quot;<br>
&gt; &gt;&gt; &gt; what<br>
&gt; &gt;&gt; &gt; contains :<br>
&gt; &gt;&gt; &gt; - kloned.exe<br>
&gt; &gt;&gt; &gt; - config.ini (this file will be modify by another application)<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; If I launch &quot;kloned.exe&quot; as standard application in MS-DOS console, the<br>
&gt; &gt;&gt; &gt; execution folder is &quot;C:\ProgramFiles\KLoneApp&quot;.<br>
&gt; &gt;&gt; &gt; But if I install kloned as a Windows service and I launch &quot;kloned.exe&quot;<br>
&gt; &gt;&gt; &gt; with<br>
&gt; &gt;&gt; &gt; &quot;net start kloned&quot; command line, the execution folder is<br>
&gt; &gt;&gt; &gt; &quot;C:\windows\system32&quot;.<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; To read my &quot;config.ini&quot; file, I have this index.klx.<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; ================================<br>
&gt; &gt;&gt; &gt; &lt;html&gt;<br>
&gt; &gt;&gt; &gt; &lt;body&gt;<br>
&gt; &gt;&gt; &gt; &lt;%<br>
&gt; &gt;&gt; &gt; FILE *file;<br>
&gt; &gt;&gt; &gt; file = fopen(&quot;config.ini&quot;,&quot;r); //local file in<br>
&gt; &gt;&gt; &gt; &quot;C:\ProgramFiles\KLoneApp&quot;<br>
&gt; &gt;&gt; &gt; if(file)<br>
&gt; &gt;&gt; &gt; {<br>
&gt; &gt;&gt; &gt;   ...<br>
&gt; &gt;&gt; &gt;   fclose(file);<br>
&gt; &gt;&gt; &gt; }<br>
&gt; &gt;&gt; &gt; %&gt;<br>
&gt; &gt;&gt; &gt; &lt;/body&gt;<br>
&gt; &gt;&gt; &gt; &lt;/html&gt;<br>
&gt; &gt;&gt; &gt; ================================<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; I would be known this installation directory which contains &quot;kloned.exe&quot;<br>
&gt; &gt;&gt; &gt; to<br>
&gt; &gt;&gt; &gt; change the execution path by calling SetCurrentDirectory() Windows<br>
&gt; &gt;&gt; &gt; function.<br>
&gt; &gt;&gt; &gt; This installation directory is stored in Windows registry (in ImagePath<br>
&gt; &gt;&gt; &gt; key).<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; This way, my KLone application could be execute regardless of standard<br>
&gt; &gt;&gt; &gt; application or service mode.<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; Can you have a function (or a solution) to know this installation<br>
&gt; &gt;&gt; &gt; directory,<br>
&gt; &gt;&gt; &gt; please ?<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; 2009/11/25 Steven Dorigotti &lt;<a href="mailto:dorigotti@koanlogic.com">dorigotti@koanlogic.com</a>&gt;<br>
&gt; &gt;&gt; &gt;&gt;<br>
&gt; &gt;&gt; &gt;&gt; Hi Mickaël,<br>
&gt; &gt;&gt; &gt;&gt;<br>
&gt; &gt;&gt; &gt;&gt;  so you managed to cross-compile or in this case did you also compile<br>
&gt; &gt;&gt; &gt;&gt; on<br>
&gt; &gt;&gt; &gt;&gt; win?<br>
&gt; &gt;&gt; &gt;&gt;<br>
&gt; &gt;&gt; &gt;&gt;  The win service should point to the directory from which you ran<br>
&gt; &gt;&gt; &gt;&gt; &quot;kloned -i&quot;, so that should be your reference executable.<br>
&gt; &gt;&gt; &gt;&gt;<br>
&gt; &gt;&gt; &gt;&gt;  In order to access content on your local file system you need to<br>
&gt; &gt;&gt; &gt;&gt; make sure the sup fs was setup correcly upon build, so:<br>
&gt; &gt;&gt; &gt;&gt;<br>
&gt; &gt;&gt; &gt;&gt; KLONE_CONF_ARGS += --enable_fs<br>
&gt; &gt;&gt; &gt;&gt;<br>
&gt; &gt;&gt; &gt;&gt;  and make sure the document root is setup correctly in your<br>
&gt; &gt;&gt; &gt;&gt; configuration<br>
&gt; &gt;&gt; &gt;&gt; file:<br>
&gt; &gt;&gt; &gt;&gt;<br>
&gt; &gt;&gt; &gt;&gt; dir_root        /path/to/dir/www<br>
&gt; &gt;&gt; &gt;&gt;<br>
&gt; &gt;&gt; &gt;&gt;  where the path should be relative to the msys installation  (in this<br>
&gt; &gt;&gt; &gt;&gt; case for example c:\msys\1.0\path\to\dir\www)<br>
&gt; &gt;&gt; &gt;&gt;<br>
&gt; &gt;&gt; &gt;&gt;  Have you already done these steps and still have trouble?<br>
&gt; &gt;&gt; &gt;&gt;<br>
&gt; &gt;&gt; &gt;&gt; bye,<br>
&gt; &gt;&gt; &gt;&gt; Steven<br>
&gt; &gt;&gt; &gt;&gt;<br>
&gt; &gt;&gt; &gt;&gt;<br>
&gt; &gt;&gt; &gt;&gt; 2009/11/24 Mickael Auger &lt;<a href="mailto:mickael.auger@gmail.com">mickael.auger@gmail.com</a>&gt;:<br>
&gt; &gt;&gt; &gt;&gt; &gt; Hi,<br>
&gt; &gt;&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt;&gt; &gt; I compile and execute KLone as a Windows service, but I need to two<br>
&gt; &gt;&gt; &gt;&gt; &gt; informations.<br>
&gt; &gt;&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt;&gt; &gt; How can I know and / or change the run directory of kloned ?<br>
&gt; &gt;&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt;&gt; &gt; How can I know the folder containing the kloned binary ?<br>
&gt; &gt;&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt;&gt; &gt; Know this folders could me to manage a lot of personal file provided<br>
&gt; &gt;&gt; &gt;&gt; &gt; with<br>
&gt; &gt;&gt; &gt;&gt; &gt; kloned binary (in the install folder).<br>
&gt; &gt;&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt;&gt; &gt; Bye.<br>
&gt; &gt;&gt; &gt;&gt; &gt; --<br>
&gt; &gt;&gt; &gt;&gt; &gt; Mickaël AUGER<br>
&gt; &gt;&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt;&gt; &gt; _______________________________________________<br>
&gt; &gt;&gt; &gt;&gt; &gt; Klone-users mailing list<br>
&gt; &gt;&gt; &gt;&gt; &gt; <a href="mailto:Klone-users@koanlogic.com">Klone-users@koanlogic.com</a><br>
&gt; &gt;&gt; &gt;&gt; &gt; <a href="http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users" target="_blank">http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users</a><br>
&gt; &gt;&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt;&gt;<br>
&gt; &gt;&gt; &gt;&gt; _______________________________________________<br>
&gt; &gt;&gt; &gt;&gt; Klone-users mailing list<br>
&gt; &gt;&gt; &gt;&gt; <a href="mailto:Klone-users@koanlogic.com">Klone-users@koanlogic.com</a><br>
&gt; &gt;&gt; &gt;&gt; <a href="http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users" target="_blank">http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users</a><br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; --<br>
&gt; &gt;&gt; &gt; Mickaël AUGER<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; _______________________________________________<br>
&gt; &gt;&gt; &gt; Klone-users mailing list<br>
&gt; &gt;&gt; &gt; <a href="mailto:Klone-users@koanlogic.com">Klone-users@koanlogic.com</a><br>
&gt; &gt;&gt; &gt; <a href="http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users" target="_blank">http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users</a><br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; _______________________________________________<br>
&gt; &gt;&gt; Klone-users mailing list<br>
&gt; &gt;&gt; <a href="mailto:Klone-users@koanlogic.com">Klone-users@koanlogic.com</a><br>
&gt; &gt;&gt; <a href="http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users" target="_blank">http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users</a><br>
&gt; &gt;&gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; --<br>
&gt; &gt; Mickaël AUGER<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; Klone-users mailing list<br>
&gt; &gt; <a href="mailto:Klone-users@koanlogic.com">Klone-users@koanlogic.com</a><br>
&gt; &gt; <a href="http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users" target="_blank">http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users</a><br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Klone-users mailing list<br>
&gt; <a href="mailto:Klone-users@koanlogic.com">Klone-users@koanlogic.com</a><br>
&gt; <a href="http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users" target="_blank">http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; Mickaël AUGER<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Klone-users mailing list<br>
&gt; <a href="mailto:Klone-users@koanlogic.com">Klone-users@koanlogic.com</a><br>
&gt; <a href="http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users" target="_blank">http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users</a><br>
<br>
<br>
_______________________________________________<br>
Klone-users mailing list<br>
<a href="mailto:Klone-users@koanlogic.com">Klone-users@koanlogic.com</a><br>
<a href="http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users" target="_blank">http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users</a><br>
</div></div></blockquote><br></div><br><br clear="all"><br>-- <br>Mickaël AUGER<br><br>