<br><br><div><span class="gmail_quote">On 11/17/06, <b class="gmail_sendername">Havoc Pennington</b> <<a href="mailto:hp@redhat.com">hp@redhat.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Ralf Habacker wrote:<br>> Havoc Pennington schrieb:<br>>> I don't know exactly, since I don't know how this works on Windows.<br>>> What is the "fd" you pass to the daemon's --print-addr-fd function? Is
<br>>> it a pipe or a socket or what is it? On UNIX autolaunch does a<br>>> fork/exec, what does it do on Windows?<br><br>btw what is the answer here? (where do you guys have the windows code<br>btw, can we look at the work in progress?)
<br><br>> We are thinking to store the recently used dbus address in the registry,<br>> which allows the autolaunch code to detect a running dbus-daemon and to<br>> be able to connect to it.<br><br>Maybe Windows should only have "autolaunch" and never start the daemon
<br>on login; unlike unix there might be a more reliable way to implement<br>autolaunch. How does the registry solution work in terms of locking,<br>i.e. say two buses start up simultaneously in the same session, one<br>should exit and not be used. Is there a way to lock a registry entry or
<br>something that allows that to work?<br><br>For the mugshot client we did single instance COM object with<br>RegisterActiveObject() - that seems like one option. I'm not sure how it<br>works if the user logs in multiple times (is that even possible?) though.
<br><br>Havoc</blockquote><div><br>A common way to guarantee a unique instance of a Windows application<br>is to use a well known mutex name. A simple example is:<br><br>DURING STARTUP<br><br> HANDLE hMutex = ::CreateMutex( NULL, FALSE, "UniqueDBusInstanceMutex" );
<br> if( !hMutex )
<br> {
<br> return( FALSE );
<br> }
<br> <br> DWORD GotMutex = ::WaitForSingleObject( hMutex, 10 );
<br> switch( GotMutex )
<br> {
<br> case WAIT_ABANDONED:
<br> ::ReleaseMutex( hMutex );
<br> ::CloseHandle( hMutex );
<br> return( FALSE );
<br> case WAIT_FAILED:
<br> case WAIT_TIMEOUT:
<br> return( FALSE );
<br> }
<br> // Save mutex handle for use during shutdown.
<br> m_hMutex = hMutex;
<br><br>DURING SHUTDOWN<br><br> // Relinquish control of the application mutex.
<br> ::ReleaseMutex( m_hMutex );
<br> ::CloseHandle( m_hMutex );
<br><br><br><br><br><br><br></div></div>