Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old January 19th, 2007, 03:15 AM
phutrek phutrek is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 72 phutrek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 46 m 10 sec
Reputation Power: 5
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...

Reply With Quote
  #2  
Old January 22nd, 2007, 03:08 AM
phutrek phutrek is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 72 phutrek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 46 m 10 sec
Reputation Power: 5
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.

Reply With Quote
  #3  
Old January 22nd, 2007, 04:25 PM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 46th Plane (27500 - 27999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,932 Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)  Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 12 h 17 m 53 sec
Reputation Power: 2002
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.

Reply With Quote
  #4  
Old January 22nd, 2007, 08:28 PM
phutrek phutrek is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 72 phutrek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 46 m 10 sec
Reputation Power: 5
Quote:
Originally Posted by Shadow Wizard
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.


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.

Reply With Quote
  #5  
Old January 23rd, 2007, 01:46 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 46th Plane (27500 - 27999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,932 Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)  Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 12 h 17 m 53 sec
Reputation Power: 2002
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?

Reply With Quote
  #6  
Old January 24th, 2007, 10:42 PM
phutrek phutrek is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 72 phutrek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 46 m 10 sec
Reputation Power: 5
Quote:
Originally Posted by Shadow Wizard
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?


if i set this to true, will i need a form for this for it to interact with?

Reply With Quote
  #7  
Old January 25th, 2007, 12:49 AM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 57 m 26 sec
Reputation Power: 181
Quote:
Originally Posted by phutrek
if i set this to true, will i need a form for this for it to interact with?
You may need a form to act as a container for the mscomm control, but you don't need the form to be visible. I have some activex.exe components I wrote with VB6, that use non-visible forms to act as containers for controls like timers and other controls, but the forms are never visible, and the entire component has no gui at all even though it contains forms.
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #8  
Old January 25th, 2007, 08:43 PM
phutrek phutrek is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 72 phutrek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 46 m 10 sec
Reputation Power: 5
Quote:
Originally Posted by Doug G
You may need a form to act as a container for the mscomm control, but you don't need the form to be visible. I have some activex.exe components I wrote with VB6, that use non-visible forms to act as containers for controls like timers and other controls, but the forms are never visible, and the entire component has no gui at all even though it contains forms.


can i run it as service?

Reply With Quote
  #9  
Old January 25th, 2007, 11:07 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 57 m 26 sec
Reputation Power: 181
Quote:
Originally Posted by phutrek
can i run it as service?
MS doesn't recommend VB6 to create services, but my guess is using srvany or something you'll be ok. Give it a try.

Reply With Quote
  #10  
Old January 25th, 2007, 11:20 PM
phutrek phutrek is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 72 phutrek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 46 m 10 sec
Reputation Power: 5
Quote:
Originally Posted by Doug G
MS doesn't recommend VB6 to create services, but my guess is using srvany or something you'll be ok. Give it a try.


ok. is it for free? please send to kertuhp@yahoo.com. thanks a lot. hope this solves my problem.

Reply With Quote
  #11  
Old January 26th, 2007, 05:18 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 57 m 26 sec
Reputation Power: 181
Is what free?

Reply With Quote
  #12  
Old January 28th, 2007, 05:21 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 46th Plane (27500 - 27999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,932 Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)  Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 12 h 17 m 53 sec
Reputation Power: 2002
I think he refers to this:
Quote:
Originally Posted by Doug
I have some activex.exe components I wrote with VB6

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Serial port...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump