HBControlMod.DLL Weirdness

Have an idea for a new feature? Voice your opinion here.
Post Reply
MediaStorm
Member
Posts: 30
Joined: Sat Jun 28, 2003 1:58 pm

HBControlMod.DLL Weirdness

Post by MediaStorm »

OK I'm losing my mind...



I'm trying to get this very simple VB code to work which worked before but now it fails. Strangely though, the ASP templates work fine so the control is obviously registered. I double checked the reference in VB as well.. HBControl.exe works fine too. :?



Any ideas??


Code: Select all

Option Explicit

Dim Obj As HBControl
Dim szRsp As String
Dim szVal As String

Private Sub Form_Load()
    Set Obj = CreateObject("HBControlMod.HBControl")
End Sub

Private Sub Command1_Click()
    szRsp = Obj.Connect(1234, "127.0.0.1", "pwd")
    szVal = Obj.GetDeviceList("|")
    
    Text1.Text = "szRsp: " + szRsp + vbCrLf + "szVal: " + szVal
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set Obj = Nothing
End Sub


Results from code above:



szRsp: Unable to connect to HouseBot computer. Port = 1234, IP = 127.0.0.1, Error = Either the application has not called WSAStartup, or WSAStartup failed.



szVal: **Error**
ScottBot
Site Admin
Posts: 2787
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

The reason that your VB codes is not working is because I initialize the socket resources (with WSAStartup()) in a method (OnStartPage()) that is called by IIS when the web page is loaded. I also clean up the socket resources in a method that is called by the web server when the page is unloaded. Since your VB code is not calling these methods, it is failing.



It was an oversight by me in designing and coding with ASP samples only. I've updated the control to now be a bit more flexable and allow the socket resources to be initialized when it is needed. I haven't done much testing with this, but it was a fairly simple change and will hopefully work for you.



I've also added a doConnect(...) method that simply calls the old/existing Connect(...) method.



You can download the latest control here. Let me know how this works for you.



Scott
MediaStorm
Member
Posts: 30
Joined: Sat Jun 28, 2003 1:58 pm

Post by MediaStorm »

Scott,



Was this changed in the last version or two? The code worked previously and then I realized I updated the external control and then it broke.



I'll test the new version and let you know how it works out but was curious if the change was recent as I know it worked before.
MediaStorm
Member
Posts: 30
Joined: Sat Jun 28, 2003 1:58 pm

Post by MediaStorm »

ScottBot wrote:The reason that your VB codes is not working is because I initialize the socket resources (with WSAStartup()) in a method (OnStartPage()) that is called by IIS when the web page is loaded. I also clean up the socket resources in a method that is called by the web server when the page is unloaded. Since your VB code is not calling these methods, it is failing.

It was an oversight by me in designing and coding with ASP samples only. I've updated the control to now be a bit more flexable and allow the socket resources to be initialized when it is needed. I haven't done much testing with this, but it was a fairly simple change and will hopefully work for you.

I've also added a doConnect(...) method that simply calls the old/existing Connect(...) method.

You can download the latest control here. Let me know how this works for you.

Scott


Bingo!



We have a winner.. It worked first time out. I had modified the Delphi TLB import by hand and changed the original connect method to doConnect instead of the override of connect1. I tested the new version using the modified doConnect TLB calling the original connect method and it worked the first time out.



Any Delphi users who try to import the new version will get two functions in the auto generation process. They'll get the original connect method renamed as connect1 and the new doConnect method as well.



Should work perfectly and require no hand tweaking or modification to the TLB units to make it work.



Great job!
Post Reply