| | |
Its a matter of converting it i guess...
Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2007
Posts: 100
Reputation:
Solved Threads: 2
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.
Any help would certainly be appreciated... Again, If this needs to be somewhere else, I do apologize in advance.
Thank you.
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.
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
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.
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.
•
•
Join Date: Nov 2007
Posts: 100
Reputation:
Solved Threads: 2
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:
The Delphi code i used that 'does' work is as follows:
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.
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)
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
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.
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
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.
•
•
Join Date: Nov 2007
Posts: 100
Reputation:
Solved Threads: 2
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.
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.
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
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.
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.
•
•
Join Date: Nov 2007
Posts: 100
Reputation:
Solved Threads: 2
I think you have a good point... But if I dont put them within the "" , it returns an error as follows:
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.
Pascal and Delphi Syntax (Toggle Plain Text)
Compile Error: 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.
![]() |
Similar Threads
- fstream Tutorial (C++)
- Quicktime Buffer Overrun Error (Viruses, Spyware and other Nasties)
- HELP - can't access Yahoo Mail (Viruses, Spyware and other Nasties)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: Problem "..system32\adortl100.bpl can't be installed..
- Next Thread: looking for server client example or help delphi
Views: 1297 | Replies: 18
| Thread Tools | Search this Thread |
Tag cloud for Pascal and Delphi






