Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does my winsock control not function correctly in vb6 within the context of a Form_QueryUnload?
    primarykey
    data
    text
    <p>My goal is to have this program send a logout command when the user is logging off or shutting down their pc.</p> <p>The program is connected to a server application via a tcp socket using a Winsock object. Calling <code>singleSock.SendData "quit" &amp; vbCrLf</code> is simply a way of logging out. I am going to start capturing data with Wireshark, but I'd like to know if I'm trying to do something fundamentally wrong.</p> <p>Oddly enough, if I set Cancel to True, and allow a timer I have running to do the logout command, then call another unload, it works, however in testing this configuration (different code), this prevents the user from logging out the first time. They have to initiate a logout, it doesn't do anything, then they logout again and my program is gone at that point. Also oddly enough, in Vista the logout goes through after briefly displaying a screen saying my program was preventing the logout. Most of my deployment is on XP, which has the two logouts problem.</p> <pre><code> Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) If UnloadMode = vbFormControlMenu Then Me.WindowState = vbMinimized Cancel = True Else If SHUTDOWN_FLAG = True Then Cancel = False Else Cancel = True SHUTDOWN_FLAG = True End If tmrSocket.Enabled = False SHUTDOWN_FLAG = True Sleep (1000) singleSock.SendData "quit" &amp; vbCrLf Call pUnSubClass 'If singleSock.state &lt;&gt; sckConnected Then ' singleSock.Close ' tmrSocket.Enabled = False ' LogThis "tmrSocket turned off" 'End If DoEvents End If End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload