|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Serial port...
hi guys/gals?
is there an api call equivalent to the mscomm control? if there is, what is it and how can i use it? thanks in advance... |
|
#2
|
|||
|
|||
|
let me elaborate...
im making a window service that needs the mscomm control. basically my problem is, when using mscomm control in a normal app (with forms, etc) it works, but when converting it to a service it seems the control is giving me a different result. code below is a simple input/output to modem using a mscomm control on a form: Code:
Set MSComm = CreateObject("MSCOMMLib.MSComm")
Dim tmpout As Variant
tmpout = "ats=0" & vbCr
With MSComm
If .PortOpen Then .PortOpen = False
'set the active serial port
.CommPort = 1
'set the badurate,parity,databits,stopbits for the connection
.Settings = "9600,N,8,1"
'set the DRT and RTS flags
.DTREnable = True
.RTSEnable = True
'enable the oncomm event for every reveived character
.RThreshold = 1
'disable the oncomm event for send characters
.SThreshold = 0
'open the serial port
.PortOpen = True
.Output = tmpout
Select Case .CommEvent
Case 2 '=comEvReceive
'display incoming event data to displaying textbox
strInput = .Input
Text1.SelText = strInput
End Select
End With
Set MSComm = Nothing
with this code in a form, i get my desired output as 'OK' from the modem (external). the .CommEvent always gives me the case '2' in the select case statement but when converting to a service, i always get a '0' in the select case statement. hope this makes it clearer. if there's no need to use api, and just stick to mscomm control then it will be alright. thanks again. |
|
#3
|
||||
|
||||
|
the problem is that service is not guaranteed to have GUI.
it's working even when the user is not logged in to Windows. you can try clicking allow service to interact with desktop (Services --> right click your service --> Log On --> Local system account) but I'm not sure that's good or correct solution. |
|
#4
|
|||
|
|||
|
Quote:
if you look at the code, the object is not on the form, its created by the createobject code. meaning the object itself is not on the form. also when i converted it to a service, the app itself has no forms in it. just modules. also, results of the app are stored on a log. that's why i know that they generate different results. Last edited by phutrek : January 22nd, 2007 at 08:30 PM. |
|
#5
|
||||
|
||||
|
yes I know, but from what I've read this control is expecting GUI.
so when there isn't, it result in weird behavior. did you try setting the service to interact with the desktop? |
|
#6
|
|||
|
|||
|
Quote:
if i set this to true, will i need a form for this for it to interact with? |
|
#7
|
|||
|
|||
|
Quote:
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#8
|
|||
|
|||
|
Quote:
can i run it as service? |
|
#9
|
|||
|
|||
|
Quote:
|
|
#10
|
|||
|
|||
|
Quote:
ok. is it for free? please send to kertuhp@yahoo.com. thanks a lot. hope this solves my problem. |
|
#11
|
|||
|
|||
|
Is what free?
|
|
#12
|
||||
|
||||
|
I think he refers to this:
Quote:
![]() |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Serial port... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|