Results 1 to 2 of 2

Thread: Keeping an ActiveX exe alive without a form?

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Posts
    14

    Keeping an ActiveX exe alive without a form?

    Hi,

    I was just wondering if there is any way of keeping an ActiveX exe running without having to resort to adding a form to the project and loading it in the background or by executing an endless loop.

    I'm running a ActiveX exe program which listens on a UDP port for messages, but also supplies objects to other classes. The exe needs to be started in order for it to listen on the UDP port.

    When the Exe is started, it runs Sub Main, but without loading a form in Sub Main, the Exe simply exits. I guess this is by design, but is there any way of keeping it alive, so it can listen for connections on a port?

    I appreciate any help you can give,

    Cheers,

    Trev.
    ~~~~~~~~~~~~~~~~~~~
    ~Trev "Code Monkey" Hunter
    ~"It works on My Machine!"
    ~~~~~~~~~~~~~~~~~~~

  2. #2

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Posts
    14

    Fix Found...

    Thanks to Dewayne Christensen for this Fix posted in another newsgroup:

    Do something like this:
    VB Code:
    1. Private Declare Function WaitMessage Lib "User32" () As Long
    2.     Private m_bDone As Boolean
    3.  
    4.     Public Sub Main()
    5.  
    6.         m_bDone = False
    7.         Call OpenSocket()
    8.  
    9.         While Not m_bDone
    10.             WaitMessage
    11.             DoEvents
    12.         Wend
    13.  
    14.         Call CloseSocket()
    15.  
    16.     End Sub

    If you're planning on the app staying up forever (until reboot), scrap the m_bDone flag and just use "While True" (and you might as well get rid of the CloseSocket call, too). If the app will shut down in response to some signal received over the socket, just set m_bDone to True whenever that signal comes in.

    ~~~~~~~~~~~~~~~~~~~
    ~Trev "Code Monkey" Hunter
    ~"It works on My Machine!"
    ~~~~~~~~~~~~~~~~~~~

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width