Its a matter of converting it i guess...

Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2007
Posts: 100
Reputation: squidd is an unknown quantity at this point 
Solved Threads: 2
squidd squidd is offline Offline
Junior Poster

Its a matter of converting it i guess...

 
0
  #1
Nov 6th, 2008
First off let me say if this is in the wrong forum i sincerely apologize. Since most people move from VB6 to Delphi, I figured this would be the proper place to put this question.

The code I did in delphi works without any problems whatsoever. Because I want to have this do the exact same thing in VB6, I am running into some problems of course...

this is what I have done thus far... i dont get any errors, but I also dont get the result I need either. The VB6 code for each 'sub' is above the delphi code for that procedure.

Private Sub Command1_Click()
Form1.Visible = True
Form3.Visible = False
' work on actually unloading form3 instead of hiding it
End Sub

'********** Delphi Equivalent *****************
'procedure TAuth.Button1Click(Sender: TObject);
'begin
'MainForm.Visible := True;
'Auth.Destroy;
'end;
'*********************************************************
'*********************************************************


Private Sub Form_Load()
Form3.Height = 1410
Form3.Width = 1695
Command1.Visible = False
Label1.Caption = "Checking..."
Text1.Text = "abc123"
Winsock5.Close
'Winsock5.Connect "A-WEBSITE.COM", "80"
Winsock5.RemoteHost = "A-WEBSITE.COM"
Winsock5.RemotePort = "80"
Winsock5.Connect
End Sub

'********** Delphi Equivalent *****************
'procedure TAuth.FormCreate(Sender: TObject);
'begin
'Button1.Visible := False;
'VerifySerial.Caption := 'Authorizing...';
'Edit1.Text := 'abc123';
'clientsocket1.Active := False;
'clientsocket1.Port := 80;
'clientsocket1.Host := 'A-WEBSITE.COM';
'clientsocket1.Active := True;
'end;
'*********************************************************
'*********************************************************

Private Sub Winsock1_Connect()
Dim s As String
s = "GET http://A-WEBSITE.COM/index.html HTTP/1.0" + "#$0D#$0A" + "Accept: */*" + "#$0D#$0A" + "Accept: text/html" + "#$0D#$0A" + "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" + "#$0D#$0A" + "#$0D#$0A"
Winsock5.SendData (s)
End Sub

'********** Delphi Equivalent *****************
'procedure TAuth.ClientSocket1Connect(Sender: TObject; Socket: TCustomWinSocket);
'Var
's : string;
'begin
's := 'GET http://A-WEBSITE.COM/index.html HTTP/1.0' + #$0D#$0A + 'Accept: */*' + #$0D#$0A + 'Accept: text/html' + #$0D#$0A + 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7' + #$0D#$0A + #$0D#$0A;
'clientsocket1.Socket.SendText(s);
'end;
'*********************************************************
'*********************************************************



Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim buffer As String
Pause (1500)
buffer = Winsock1.GetData
    If pos("abc123", buffer) > 0 Then
    Label1.Caption = "Authorized!"
        Else
        Label1.Caption = "NOT Authorized!"
            End If
    If Label1.Caption = "Authorized!" Then
    Form3.Height = 2130
    Command1.Visible = True
        Else
        Label1.Caption = "Denied!"
        Command1.Visible = False
        Pause (1500)
        UnloadMe
    End If
    End Sub
            
'********** Delphi Equivalent *****************
'procedure TAuth.ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
'Var
'buffer : string;
'begin
'Sleep(1500);
'buffer := clientsocket1.Socket.ReceiveText;
'if pos('abc123', buffer) > 0 then
'VerifySerial.Caption := 'Authorized!'
'Else
'VerifySerial.Caption := 'NOT Authorized!';
'if VerifySerial.Caption = 'Authorized!' then
'begin
'Auth.Height := 135;
'Button1.Visible := True;
'End
'Else
'begin
'if VerifySerial.Caption =  'Not Authorized!' then
'VerifySerial.Caption := 'NOT Authorized!';
'Auth.Caption := 'Denied!';
'Button1.Visible := False;
'Sleep(1500);
'Application.terminate;
'end;
'end;
'*********************************************************
'*********************************************************

Any help would certainly be appreciated... Again, If this needs to be somewhere else, I do apologize in advance.

Thank you.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Its a matter of converting it i guess...

 
0
  #2
Nov 6th, 2008
So, without my eyes burning holes, what difference do you get?
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 100
Reputation: squidd is an unknown quantity at this point 
Solved Threads: 2
squidd squidd is offline Offline
Junior Poster

Re: Its a matter of converting it i guess...

 
0
  #3
Nov 6th, 2008
Hello LizR,

The difference is that I dont get anything at all. It doesnt seem to do anything except for sit there checking to see if the info in the code matches the info at the website i have set up.

Nothing happens at all.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 100
Reputation: squidd is an unknown quantity at this point 
Solved Threads: 2
squidd squidd is offline Offline
Junior Poster

Re: Its a matter of converting it i guess...

 
0
  #4
Nov 7th, 2008
welp i hope someone can help me, i think i jes have the syntax wrong. anyone is certainly welcome to put their 2 cents in. Also, wysiwyg... i dont have any public/global variables set for this.
Last edited by squidd; Nov 7th, 2008 at 1:48 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Its a matter of converting it i guess...

 
0
  #5
Nov 7th, 2008
Do remember not all of us are in your timezone, and do have to sleep from time to time..

OK, looking at the code the first thing to do would be to check your winsock data arrival procedure is actually being called, and if so, what data you get.

Data doesnt always arrive as 1 chunk, which doesnt seem tobe accounted for in that proceedure overly well. In that the data could be split over a packet.

As long as the routine is being called you'll be able to track down why its not working - why you're moving to a language (eg vb for win32) which was dropped by MS.. im unsure, but, its your call.

You'll need to tell us if the data is returning the way you'd expect it to.

The other thing would be you've told the code to run in the onload not a button press so it snot goign to run on demand.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 100
Reputation: squidd is an unknown quantity at this point 
Solved Threads: 2
squidd squidd is offline Offline
Junior Poster

Re: Its a matter of converting it i guess...

 
0
  #6
Nov 7th, 2008
Thanks Lizr,

I dont really know how to find out what I am "getting back" from the program when i run it.

I think the line sub that isnt working right is this one:

Pascal and Delphi Syntax (Toggle Plain Text)
  1. Private Sub Winsock1_Connect()
  2. Dim s As String
  3. s = "GET http://A-WEBSITE.COM/index.html HTTP/1.0" + "#$0D#$0A" + "Accept: */*" + "#$0D#$0A" + "Accept: text/html" + "#$0D#$0A" + "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" + "#$0D#$0A" + "#$0D#$0A"
  4. Winsock5.SendData (s)
  5. End Sub

The Delphi code i used that 'does' work is as follows:

procedure TAuth.ClientSocket1Connect(Sender: TObject; Socket: TCustomWinSocket);
Var
s : string;
begin
s := 'GET http://A-WEBSITE.COM/index.html HTTP/1.0' + #$0D#$0A + Accept: */*' + #$0D#$0A + 'Accept: text/html' + #$0D#$0A + 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7' + #$0D#$0A + #$0D#$0A;
clientsocket1.Socket.SendText(s);
end;


I have no idea idea how this converts into a VB6 environment however.... so if you, or anyone else knows what I would need to do to make this delphi procedure work as a VB subroutine, that would likely solve this problem for me completely

Basically all I need is the proper way to read a specific 'password' off of a site that i created to protect programs that i write. so the procedure basically looks for a certain sequence of characters. If they are there on the website, then the program will open. if not, it wont open.

Thanks for any help.
Last edited by squidd; Nov 7th, 2008 at 8:41 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Its a matter of converting it i guess...

 
0
  #7
Nov 8th, 2008
Put a break point in, add a watch to th value.. basic stuff.. thats how you tell whats in it.
Last edited by LizR; Nov 8th, 2008 at 4:24 am.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 100
Reputation: squidd is an unknown quantity at this point 
Solved Threads: 2
squidd squidd is offline Offline
Junior Poster

Re: Its a matter of converting it i guess...

 
0
  #8
Nov 8th, 2008
thanks for the help with the watch to see what is happening. It looks like it does connect to the remost host because it returns an ip for that host. but it seems to get stuck in the subroutine.
So, im not sure what to do at this point. There isnt any reason i can see why it should do this. I know I must be doing something wrong or it would work.

Any suggestions are apprciated.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Its a matter of converting it i guess...

 
0
  #9
Nov 8th, 2008
which one does it get stuck in?

Only thing I can think of is
"#$0D#$0A" + "#$0D#$0A"


by putting in the " marks you're turning them to strings.. which isnt what you want. so its possibly not returning the data you want.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 100
Reputation: squidd is an unknown quantity at this point 
Solved Threads: 2
squidd squidd is offline Offline
Junior Poster

Re: Its a matter of converting it i guess...

 
0
  #10
Nov 8th, 2008
I think you have a good point... But if I dont put them within the "" , it returns an error as follows:

Pascal and Delphi Syntax (Toggle Plain Text)
  1. Compile Error:
  2.  
  3. Expected: expression

If you know of a way for a program written in VB6 to locate a specific pattern of text from a website and return a value of true or false (i.e. if it is there = true, if not there = false) to allow the program to run, I am all ears... (or eyes in this case... hehe) In this case, I am checking to see if the persons HDD volume ID is there or not.

thanks for your help once again.
Last edited by squidd; Nov 8th, 2008 at 6:33 pm.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Pascal and Delphi Forum


Views: 1297 | Replies: 18
Thread Tools Search this Thread



Tag cloud for Pascal and Delphi
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC