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