|
-
Feb 7th, 2002, 02:45 PM
#1
Thread Starter
New Member
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!"
~~~~~~~~~~~~~~~~~~~
-
Feb 7th, 2002, 04:02 PM
#2
Thread Starter
New Member
Fix Found...
Thanks to Dewayne Christensen for this Fix posted in another newsgroup:
Do something like this:
VB Code:
Private Declare Function WaitMessage Lib "User32" () As Long
Private m_bDone As Boolean
Public Sub Main()
m_bDone = False
Call OpenSocket()
While Not m_bDone
WaitMessage
DoEvents
Wend
Call CloseSocket()
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|