Using Winsock in a HTA 
Author Message
 Using Winsock in a HTA

hi all

is this possible for the first thing ?

secondly, are there any examples ?

many thanks



Sun, 28 Aug 2005 23:49:40 GMT  
 Using Winsock in a HTA

hi all

is this possible for the first thing ?

secondly, are there any examples ?

many thanks

If you have a licensed Winsock control, sure.

Winsock programming is complicated and is reallya function of how it works, not
VBScript.  Most VB examples should work as long as they are converted to
loosely-typed, late-bound code.  You can find the prior discussions of WInsock
scripting in the scripting newsgroups here:

http://groups.google.com/groups?as_q=Winsock&as_ugroup=microsoft.publ...

--
Please respond in the newsgroup so everyone may benefit.
 http://dev.remotenetworktechnology.com
(email requests for support contract information welcomed)
 ----------
 Subscribe to Microsoft's Security Bulletins:
 http://www.microsoft.com/technet/security/bulletin/notify.asp



Mon, 29 Aug 2005 07:48:54 GMT  
 Using Winsock in a HTA

Quote:
> If you have a licensed Winsock control, sure.

> Winsock programming is complicated and is reallya function of how it works, not
> VBScript.  Most VB examples should work as long as they are converted to
> loosely-typed, late-bound code.  You can find the prior discussions of WInsock
> scripting in the scripting newsgroups here:

> http://groups.google.com/groups?as_q=Winsock&as_ugroup=microsoft.publ...

And from a previous post by you :-)

<quote>
Monte Hansen wrote  a free DLL which can be used as a replacement for the
licensed Winsock.  You can download it from:

http://www.killervb.com/WinsockLib.aspx

You need to make only minor modifications to scripts which would depend on the
Microsoft Winsock control; I haven't mastered use of it myself yet, but it
"feels" even more lightweight than the MS Winsock from my light usage.
</quote>

--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page Scripting
Guide: http://www.microsoft.com/technet/scriptcenter



Mon, 29 Aug 2005 08:12:56 GMT  
 Using Winsock in a HTA
thanks

it's just that i was getting strange error messages
and i do have the correct licence to use these controls
(it cost me enough) but it's worth it, so no complaints

the fault must lie within my code then, so what's new :-(

i'm afraid to post my code, because people don't
like client and server applications, but i still need help

is their someone willing to help me complete my HTA

Beris



Quote:

> > If you have a licensed Winsock control, sure.

> > Winsock programming is complicated and is reallya function of how it
works, not
> > VBScript.  Most VB examples should work as long as they are converted to
> > loosely-typed, late-bound code.  You can find the prior discussions of
WInsock
> > scripting in the scripting newsgroups here:

http://groups.google.com/groups?as_q=Winsock&as_ugroup=microsoft.publ...
pting.*
Quote:

> And from a previous post by you :-)

> <quote>
> Monte Hansen wrote  a free DLL which can be used as a replacement for the
> licensed Winsock.  You can download it from:

> http://www.killervb.com/WinsockLib.aspx

> You need to make only minor modifications to scripts which would depend on
the
> Microsoft Winsock control; I haven't mastered use of it myself yet, but it
> "feels" even more lightweight than the MS Winsock from my light usage.
> </quote>

> --
> torgeir
> Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of the 1328 page
Scripting
> Guide: http://www.microsoft.com/technet/scriptcenter



Tue, 30 Aug 2005 06:13:21 GMT  
 Using Winsock in a HTA
By all means, post the error and the code where it comes from.  That's why we're
here...

--
Please respond in the newsgroup so everyone may benefit.
 http://dev.remotenetworktechnology.com
(email requests for support contract information welcomed)
 ----------
 Subscribe to Microsoft's Security Bulletins:
 http://www.microsoft.com/technet/security/bulletin/notify.asp


Quote:
> thanks

> it's just that i was getting strange error messages
> and i do have the correct licence to use these controls
> (it cost me enough) but it's worth it, so no complaints

> the fault must lie within my code then, so what's new :-(

> i'm afraid to post my code, because people don't
> like client and server applications, but i still need help

> is their someone willing to help me complete my HTA

> Beris




> > > If you have a licensed Winsock control, sure.

> > > Winsock programming is complicated and is reallya function of how it
> works, not
> > > VBScript.  Most VB examples should work as long as they are converted to
> > > loosely-typed, late-bound code.  You can find the prior discussions of
> WInsock
> > > scripting in the scripting newsgroups here:

> http://groups.google.com/groups?as_q=Winsock&as_ugroup=microsoft.publ...
> pting.*

> > And from a previous post by you :-)

> > <quote>
> > Monte Hansen wrote  a free DLL which can be used as a replacement for the
> > licensed Winsock.  You can download it from:

> > http://www.killervb.com/WinsockLib.aspx

> > You need to make only minor modifications to scripts which would depend on
> the
> > Microsoft Winsock control; I haven't mastered use of it myself yet, but it
> > "feels" even more lightweight than the MS Winsock from my light usage.
> > </quote>

> > --
> > torgeir
> > Microsoft MVP Scripting and WMI, Porsgrunn Norway
> > Administration scripting examples and an ONLINE version of the 1328 page
> Scripting
> > Guide: http://www.microsoft.com/technet/scriptcenter



Tue, 30 Aug 2005 07:30:34 GMT  
 Using Winsock in a HTA
this is the VB code that i'm trying make
work in my HTA chat program, i'm not having
much luck...

the error's i get are:
once connected, instantly disconected
so i'm even doubtful as to if any connection
took place.

i would be very grateful if this could be
made to work

many thanks

(w1 = winsock1)

Sub Command1_Click()
If oform.Text1.value = "" Then Exit Sub
w1.SendData oform.Text1.value
DoEvents
oform.List1.AddItem "Client : " & oform.Text1.value
ofrom.Text1.value = ""
End Sub

Sub Command2_Click()
On Error Resume Next
w1.Close
w1.LocalPort = 188
w1.Listen
End Sub

Sub window_Load()
w1.LocalPort = 188
w1.Listen
End Sub

Sub w1_Close()
oform.List1.AddItem "Disconnected"
End Sub

Sub w1_ConnectionRequest()
If w1.State <> sckClosed Then w1.Close
w1.Accept requestID
oform.List1.AddItem "Connected"
End Sub

Sub w1_DataArrival(ByVal bytesTotal As Long) ' (ByVal bytesTotal As Long)
Dim dat
w1.GetData dat
oform.List1.AddItem "Client : " & dat
End Sub



Quote:
> By all means, post the error and the code where it comes from.  That's why
we're
> here...

> --
> Please respond in the newsgroup so everyone may benefit.
>  http://dev.remotenetworktechnology.com
> (email requests for support contract information welcomed)
>  ----------
>  Subscribe to Microsoft's Security Bulletins:
>  http://www.microsoft.com/technet/security/bulletin/notify.asp



> > thanks

> > it's just that i was getting strange error messages
> > and i do have the correct licence to use these controls
> > (it cost me enough) but it's worth it, so no complaints

> > the fault must lie within my code then, so what's new :-(

> > i'm afraid to post my code, because people don't
> > like client and server applications, but i still need help

> > is their someone willing to help me complete my HTA

> > Beris




> > > > If you have a licensed Winsock control, sure.

> > > > Winsock programming is complicated and is reallya function of how it
> > works, not
> > > > VBScript.  Most VB examples should work as long as they are
converted to
> > > > loosely-typed, late-bound code.  You can find the prior discussions
of
> > WInsock
> > > > scripting in the scripting newsgroups here:

http://groups.google.com/groups?as_q=Winsock&as_ugroup=microsoft.publ...

- Show quoted text -

Quote:
> > pting.*

> > > And from a previous post by you :-)

> > > <quote>
> > > Monte Hansen wrote  a free DLL which can be used as a replacement for
the
> > > licensed Winsock.  You can download it from:

> > > http://www.killervb.com/WinsockLib.aspx

> > > You need to make only minor modifications to scripts which would
depend on
> > the
> > > Microsoft Winsock control; I haven't mastered use of it myself yet,
but it
> > > "feels" even more lightweight than the MS Winsock from my light usage.
> > > </quote>

> > > --
> > > torgeir
> > > Microsoft MVP Scripting and WMI, Porsgrunn Norway
> > > Administration scripting examples and an ONLINE version of the 1328
page
> > Scripting
> > > Guide: http://www.microsoft.com/technet/scriptcenter



Thu, 01 Sep 2005 22:09:22 GMT  
 Using Winsock in a HTA
Beris,

One of the problems is that this is VB code, not VBScript.

VBScript doesn't have DoEvents and it doesn't allow data typing.  So just
picking out a few things that will fail below:

+ Sub Command1_Click will {*filter*}before the oform.List1.AddItem  call, and should
throw an error.

+ There is presumably a problem with Sub Command2_Click since you have an On
Error Resume Next there.  I assume this is because your call to Close will fail
if the socket is closed, so you may want to test w1.State first, then only call
Close if it is not 0.

+ Calls to Sub w1_DataArrival will throw an error immediately since you declare
the type for the variable.  Presumably, that event handler will never even be
seen, or the app bombs when it hits it.  Change it to Sub
w1_DataArrival(bytesTotal).

Make sure you don't have On Error Resume Next _anywhere_ and that you have
debugging for IE (and consequently HTAs) turned on, and we can see where you
have errors pop up.


Quote:
> this is the VB code that i'm trying make
> work in my HTA chat program, i'm not having
> much luck...

> the error's i get are:
> once connected, instantly disconected
> so i'm even doubtful as to if any connection
> took place.

> i would be very grateful if this could be
> made to work

> many thanks

> (w1 = winsock1)

> Sub Command1_Click()
> If oform.Text1.value = "" Then Exit Sub
> w1.SendData oform.Text1.value
> DoEvents
> oform.List1.AddItem "Client : " & oform.Text1.value
> ofrom.Text1.value = ""
> End Sub

> Sub Command2_Click()
> On Error Resume Next
> w1.Close
> w1.LocalPort = 188
> w1.Listen
> End Sub

> Sub window_Load()
> w1.LocalPort = 188
> w1.Listen
> End Sub

> Sub w1_Close()
> oform.List1.AddItem "Disconnected"
> End Sub

> Sub w1_ConnectionRequest()
> If w1.State <> sckClosed Then w1.Close
> w1.Accept requestID
> oform.List1.AddItem "Connected"
> End Sub

> Sub w1_DataArrival(ByVal bytesTotal As Long) ' (ByVal bytesTotal As Long)
> Dim dat
> w1.GetData dat
> oform.List1.AddItem "Client : " & dat
> End Sub

--
Please respond in the newsgroup so everyone may benefit.
  http://www.*-*-*.com/
(email requests for support contract information welcomed)
 ----------
 Subscribe to Microsoft's Security Bulletins:
  http://www.*-*-*.com/


Sat, 03 Sep 2005 18:24:47 GMT  
 Using Winsock in a HTA
thanks Alex.

i'll make those and see what happens.
i'm not exactly shure what is transferable from
VB to VBScript, so it's still hit and miss.

Beris



Quote:
> Beris,

> One of the problems is that this is VB code, not VBScript.

> VBScript doesn't have DoEvents and it doesn't allow data typing.  So just
> picking out a few things that will fail below:

> + Sub Command1_Click will {*filter*}before the oform.List1.AddItem  call, and
should
> throw an error.

> + There is presumably a problem with Sub Command2_Click since you have an
On
> Error Resume Next there.  I assume this is because your call to Close will
fail
> if the socket is closed, so you may want to test w1.State first, then only
call
> Close if it is not 0.

> + Calls to Sub w1_DataArrival will throw an error immediately since you
declare
> the type for the variable.  Presumably, that event handler will never even
be
> seen, or the app bombs when it hits it.  Change it to Sub
> w1_DataArrival(bytesTotal).

> Make sure you don't have On Error Resume Next _anywhere_ and that you have
> debugging for IE (and consequently HTAs) turned on, and we can see where
you
> have errors pop up.



> > this is the VB code that i'm trying make
> > work in my HTA chat program, i'm not having
> > much luck...

> > the error's i get are:
> > once connected, instantly disconected
> > so i'm even doubtful as to if any connection
> > took place.

> > i would be very grateful if this could be
> > made to work

> > many thanks

> > (w1 = winsock1)

> > Sub Command1_Click()
> > If oform.Text1.value = "" Then Exit Sub
> > w1.SendData oform.Text1.value
> > DoEvents
> > oform.List1.AddItem "Client : " & oform.Text1.value
> > ofrom.Text1.value = ""
> > End Sub

> > Sub Command2_Click()
> > On Error Resume Next
> > w1.Close
> > w1.LocalPort = 188
> > w1.Listen
> > End Sub

> > Sub window_Load()
> > w1.LocalPort = 188
> > w1.Listen
> > End Sub

> > Sub w1_Close()
> > oform.List1.AddItem "Disconnected"
> > End Sub

> > Sub w1_ConnectionRequest()
> > If w1.State <> sckClosed Then w1.Close
> > w1.Accept requestID
> > oform.List1.AddItem "Connected"
> > End Sub

> > Sub w1_DataArrival(ByVal bytesTotal As Long) ' (ByVal bytesTotal As
Long)
> > Dim dat
> > w1.GetData dat
> > oform.List1.AddItem "Client : " & dat
> > End Sub

> --
> Please respond in the newsgroup so everyone may benefit.
>   http://www.*-*-*.com/
> (email requests for support contract information welcomed)
>  ----------
>  Subscribe to Microsoft's Security Bulletins:
>   http://www.*-*-*.com/



Sat, 03 Sep 2005 22:29:41 GMT  
 Using Winsock in a HTA

Quote:
> thanks Alex.

> i'll make those and see what happens.
> i'm not exactly shure what is transferable from
> VB to VBScript, so it's still hit and miss.

It's like riding a bike - hard to explain, but you get the feel for it after a
while.  VB coders using script and vice-versa usually have intense vertigo for a
few days, then it gets really easy because you see how the two relate to each
other. Some simple rules of thumb that can help -

+ You should never see the word "As" in a script.  That nails 90% of the errors
cross-coders get going from VB to VBScript.  You can set Option Explicit (and
should) and then pretend that everything is a Variant, and it will work.

+ Never suppress errors when you're crosscoding in VBScript after using VB.
VBScript is much more forgiving than VB for various reasons, so it will quite
happily let you chop its legs off and then try to run.
In the case of HTA/IE hosted script, you may have to go to extra work digging
into IE to make it stop on errors.

--
Please respond in the newsgroup so everyone may benefit.
 http://dev.remotenetworktechnology.com
(email requests for support contract information welcomed)
 ----------
 Subscribe to Microsoft's Security Bulletins:
 http://www.microsoft.com/technet/security/bulletin/notify.asp



Sat, 03 Sep 2005 22:42:46 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Deploying ActiveX controls used in HTA App

2. GetData using MSWinsock.Winsock

3. Using the Put() function/Using Winsock

4. Using the Put() function/Using Winsock

5. Using the Put() function/Using Winsock

6. How can I link to another page using MSHTA (HTA Extension)

7. IE in HTA using ASP

8. Mini File Explorer using HTA

9. Using ActiveX or Script to Access Remote Mail Server via HTA Application

10. WScript.Run from HTA using vbscript: File not found

11. Read/write registry key using .asp or .hta

12. Get ScriptFullNameand ScriptName using VBScript in an HTA

 

 
Powered by phpBB® Forum Software