From: Henning on
Hi, me again...

My app with a .bas and a .cls module now (thx to all) compiles and runs as
expected.
New problem: How do I catch Windows tell me to shut down, to clean-up before
ending?

I have not yet added the RunAsAService.

/Henning


From: Schmidt on

"Henning" <computer_hero(a)coldmail.com> schrieb im Newsbeitrag
news:hu6cll$455$1(a)news.eternal-september.org...
> Hi, me again...
>
> My app with a .bas and a .cls module now (thx to all)
> compiles and runs as expected.
Oh, that was fast - is that .cls already hosting one (or
another) MS-Comm-replacement?


> New problem: How do I catch Windows tell me to shut down,
> to clean-up before ending?
> I have not yet added the RunAsAService.

If you'd use Sergeys Service-approach, then you will get
notified about System-Shutdown by an appropriate
SCM (ServiceControlManager)-Event.

In his Code-examples he already sets appropriate
"notification-flags" in
module: NTService.bas
function: ServiceMain
module-variable: ServiceStatus.dwControlsAccepted = ...

The reaction to these Events takes place in:
Private Sub Handler(...)
in the same NTService.bas module.

Currently there's no differentiation between:
Service_Control_Shutdown And Service_Control_Stop
in the above function - the Select Case treats them
the same.

If you are fine with that (Service-Stop == SystemShutdown)
with regards to your cleanup-actions, then you don't need
to change anything in the "default-demo".

Would test and check this out though of course...
Maybe in a first try only with the simple demo and the
already exisiting SytemEvent-logging-routine,
whilst shutting down your machine, having an
already upstarted and running "demo-service".

Olaf


From: Karl E. Peterson on
Henning expressed precisely :
> Hi, me again...
>
> My app with a .bas and a .cls module now (thx to all) compiles and runs as
> expected.
> New problem: How do I catch Windows tell me to shut down, to clean-up before
> ending?

You'll want to watch for WM_QUERYENDSESSION and/or WM_ENDSESSION.

Example: http://vb.mvps.org/samples/SysInfo

That class hooks the hidden top-level window created for all VB6 apps,
so there's no need to add a form or create another window.

--
..NET: It's About Trust! http://vfred.mvps.org
Customer Hatred Knows No Bounds at MSFT
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Free usenet access at http://www.eternal-september.org


From: Henning on

"Schmidt" <sss(a)online.de> skrev i meddelandet
news:hu6fl1$kfl$1(a)speranza.aioe.org...
>
> "Henning" <computer_hero(a)coldmail.com> schrieb im Newsbeitrag
> news:hu6cll$455$1(a)news.eternal-september.org...
>> Hi, me again...
>>
>> My app with a .bas and a .cls module now (thx to all)
>> compiles and runs as expected.
> Oh, that was fast - is that .cls already hosting one (or
> another) MS-Comm-replacement?

Yes,
A Reference to MSComm32.ocx

--------------
In a Class: MSCommClass
Option Explicit

Public WithEvents mComm As MSComm

Private Sub Class_Initialize()
Set mComm = CreateObject("MSCOMMLIB.MSCOMM")
End Sub

Private Sub mComm_OnComm()
Comm1_OnComm
End Sub

---------------
In Module1 .bas module:
Public Comm1 As New MSCommClass

Sub Init()
.....
With Comm1.mComm
If .PortOpen Then
.PortOpen = False
.CommPort = 1
' .Settings = "9600,N,8,1" 'Format(RSBaud) & ",N," & Format(RSBits) &
",2" ' "19200,N,8,2"
.DTREnable = True
.InputMode = comInputModeText
.OutBufferSize = 256
.PortOpen = True
Else
.CommPort = 1
' .Settings = "9600,N,8,1" 'Format(RSBaud) & ",N," & Format(RSBits) &
",2" ' "19200,N,8,2"
.DTREnable = True
.InputMode = comInputModeText
.OutBufferSize = 256
.PortOpen = True
End If
.RThreshold = 1
.SThreshold = 1
.InBufferCount = 0
End With

Public Sub Comm1_OnComm()
.....
With Comm1.mComm
msg = .CommEvent
If msg > 0 Then
Select Case msg
Case Is > 1000
' If Log2File Then
Beep
' Print #fil, Time & " * CommError: " & msg
' End If
Case Is = comEvSend
While Not GetPortBit(UART_LSR, TEMT)
Wend
TxOn = False
Case comEvReceive
If Not FirstByte Then
.InputLen = 1
buffer = .Input
If Len(buffer) = 1 Then
RxSize = Asc(buffer)
Select Case RxSize
Case 3, 4, 13, 15
.....

And a DBAccess.bas to handle a MySQL DB


>
>
>> New problem: How do I catch Windows tell me to shut down,
>> to clean-up before ending?
>> I have not yet added the RunAsAService.
>
> If you'd use Sergeys Service-approach, then you will get
> notified about System-Shutdown by an appropriate
> SCM (ServiceControlManager)-Event.
>
> In his Code-examples he already sets appropriate
> "notification-flags" in
> module: NTService.bas
> function: ServiceMain
> module-variable: ServiceStatus.dwControlsAccepted = ...
>
> The reaction to these Events takes place in:
> Private Sub Handler(...)
> in the same NTService.bas module.
>
> Currently there's no differentiation between:
> Service_Control_Shutdown And Service_Control_Stop
> in the above function - the Select Case treats them
> the same.
>
> If you are fine with that (Service-Stop == SystemShutdown)
> with regards to your cleanup-actions, then you don't need
> to change anything in the "default-demo".
>
> Would test and check this out though of course...
> Maybe in a first try only with the simple demo and the
> already exisiting SytemEvent-logging-routine,
> whilst shutting down your machine, having an
> already upstarted and running "demo-service".

Take that as the next step ;)

>
> Olaf
>
>

/Henning