Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 Program Update

Note: You must be registered in order to post a reply.

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List Spell Checker
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

   Insert an File
Check here to include your profile signature.
Check here to subscribe to this topic.
    

T O P I C    R E V I E W
Crash Posted - Feb 22 2005 : 4:50:46 PM
This has NOTHING at all to do with DirectX, plz dont kill me but i get alot faster resonces here than elsewhere so i decided to ask here =X.
I am making my application have the ability to update, in order to do so i read another pages (hosted by me) source code. The sites sourcecode is similar to this:
<html>  
<head>  
<title>Program's By Crash</title>  
</head>  
<body>  
<b>Title : Project1 1.0.0</b><br>  
<b>Title : Project2 1.0.0</b><br>  
<b>Title : Project3 1.0.0</b><br>  
<b>Title : Project4 1.0.0</b><br>  
</body>  
</html>  


What im trying to do using my program is the following:
-Check Programs Version at site.
-Make Sure program is listed at site.

I have come this close: | |. To completing the application but i wanted to add a couple of features and i got my code and mind all screwed up.

I have an Inet Control, Inet1, A textbox, txthtml, a command button, cmdCheck, and a label, lblVer, placed on my forum.
the code for the Inet Control to retrieve a page's source code is:
Private Sub Inet1_StateChanged(ByVal State As Integer)  
   If State = 12 Then
      HTML = Inet1.GetChunk(1024)  
      txthtml.Text = HTML  
      Do Until HTML = Empty  
         HTML = Inet1.GetChunk(1024)  
         txthtml.Text = txthtml.Text & HTML  
      Loop
         txthtml.Text = Replace(txthtml.Text, Chr(13), vbCrLf)  
         txthtml.Text = Replace(txthtml.Text, Chr(10), vbCrLf)  
   ElseIf State = icTimeout Then
      Status = "Timeout"  
   End If
End Sub


Command Buttons Code:
Private Sub cmdCheck_Click()  
lbl.Caption = "Checking for update please wait ..."  
Check  
End Sub


Function Called in Command Button:
Public Function Check()  
'Getting Source Code Of Specified Site
txthtml.Text = Empty  
Call Inet1.Execute("http://localhost/Test/index.htm", "GET")  
  Do While txthtml = Empty  
    DoEvents  
Loop
  
'Checking Programs Current Version, Making Sure It Isn't Disabled
'strTitle = InStr(txthtml.Text, App.Title) 'Get The Applications Title, Started getting confused about this function so i commented it
strCVersion = Mid(txthtml.Text, 222, 5) 'Replace 222 with where the version starts  
'Version = InStr(txthtml.Text, App.Title & " : " & App.Major & App.Minor & App.Revision) 'Old function, i thought it worked - now im just confused =X
  
' If strTitle = 0 Then
'    lbl.Caption = "This Program Has Been Taken Down!"
' End If
  
If strCVersion = App. Then
    MsgBox "No new update", vbInformation, "No Update available"  
    Status = "You Have The Newest Version XD!"  
   Exit Function
Else
    MsgBox "There Is A New Update" & vbCrLf & "Current Version: " & nVersion1, vbInformation, "No Update available"  
    lblver.Caption = "Please Goto 3ikon.com and download the newest version"  
End If
  
End Function


The update works however if you looked at that mid function for strCVersion... it is DEFFINITLEY not compatible with another project without extreme editing(counting up till you get to the new project =X). If you know how to use the InStr() function then please tell me if it would be possible to make this updater more compatible by using it, and how to use it.
Current Ideas / Possibilities:
-InStr(1, txthtml.Text, App.Title, 1) - A textual comparison that searches for the applications title. I dont know / understand the binary comparison all to well (i experimented with it) so i used a textual comparison.
-Is it possible to do something like... On the line that App.title is on -> define that as a variable?
4   L A T E S T    R E P L I E S    (Newest First)
Crash Posted - Mar 10 2005 : 3:50:39 PM
Im creating an archieve of information right now, so excuse the header. For all that want to know how to do this then please look below.

'Title: String Searcher
'Description: Searches for a string between two things.
'Author: Crash

Public Sub StringSearch(ByVal mainString As String, ByVal left As String, ByVal right As String)
Dim TN(0 To 1) As Long
Dim str(0 To 1) As String
TN(0) = InStr(1, mainString, left) + Len(left)
TN(1) = InStr(TN(0), mainString, right)
StringSearch = Mid$(mainString, TN(0), TN(1) - TN(0))
End Sub

This will search for a string between 2 charachters, i have many variations that can get every instance and much more - however, i am sure you all know how to do alot of stuff here so i posted that in order to allow you to modify it without having to much stuff going on at once.
Furthermore, for my program i created a PHP page that is blank and only accepts postdata and when it recieves the programs name - it outputs all the information that is stored in a dabase relating to the program. This has been implemented because i am creating a program registration process in my programs that needs to be as secure as possible and i would not consider a text file secure, i have put many more implements security wise in my program (ie. 15+ Hardware Fingerprints, Machine ID, Serial Number, Machine Name, LAN ID, and much more).
Eric Coleman Posted - Feb 24 2005 : 6:24:00 PM
why do you instsit on putting program information in an html page? A simple text file is easier to create, and much easier to parse. If each file is on it's own line, use the Split command to split the file by CRLF. Then go through the array and find your file. If you want to update a program, chances are you'll want to not only update the .exe file, but any other files used by the program as well, such as graphics and sounds. Keeping a seperate index file on your server for each program is easiest. If you want to have all your programs use the same file, then you'll need to add another field to designate what program the file belongs to. Instead of "sound.wav,1.0", use "sound.wav,1.0,programID" where program ID is whatever you want to use. The reason for version numbers is so that you can keep track of files localy, i.e. their versions, and then compare them to what's on the server so that you only need to download the newest files.
Crash Posted - Feb 23 2005 : 8:49:43 PM
Hello Eric, thank you for your help. However i have chosen to use a webpage for security related issues. Also, i have read up on all of the string manipulation methods inside of my book labeled "Sams Teach Yourself VisualBasic In 24 Hours". I know that book isnt the best most likley but it does tell you the syntax of a command and how to use it however, the problem i came to while making this is that i already learned InStr but when i read it in my book, the technical definition of it threw me way off so i kinda just got 'lost' so to say. Also in your helper loop could you explain it abit more cause im not 100% stupid when it comes to looping but i am rather new. Lastly (maybe), i do not know before hand what the text file will contain, example below.

I have to make sure that the applications name is in the webpage, which i believe is a simple InStr function.
I also have to extract the string that is like:
<b>Title : <Applications Name> <Current Version></b><br>
and there are many of them .... so if you have a function that can letsay... extract the line that the applications name is on then that would be helpful.

If you wouldnt mind, please contact me on AIM: BORN L3ET or MSN: omar.alkurd@gmail.com rather than replying here as i will be able to ask alot more questions very rapidly and assess the best way to fix my 'dilema'.

Edit 1 : Sorry if my last message / reply was 'blurred' i was kinda sleepy. Here is a better example of what i am saying, using your comma deliminated example.
project1.exe,1.0
stuff.bmp,1.1
sound.wave,2.0
Those would be the current versions and due to that, my program will not no to search for the string stuff.bmp,1.1 my programs current version is 1.0, so unless if you know how to extract a 'row' of text then i have no clue what to do.
Also, i havnt messed with debug yet so would you mind explaining the debug.print method?

Thank You, for your help.

Edit 2 : I dont know everything about loops as stated above but dosnt a Do... Loop need some 'method' so it can be terminated? (eg. Do while expression.... Loop)

Edit 3 : I Just did some research on subclassing and figured out what debug.print does. Oh and i have one thing to say... SUBCLASSING IS POWERFUL AS HELL!!!!!!!
Eric Coleman Posted - Feb 23 2005 : 10:02:34 AM
A = 1
Do
A = InStr(A, string, word)
If A = 0 then exit do
Debug.Print Mid(string, A, len(word))
Loop

Although to make it easier for program updates, don't download a webpage, just have a simple text file with the file to download. The only person that needs to access it is the program that's looking for a new update, so just a update.txt file that's comma delimited.

Example
  
project1.exe,1.0  
stuff.bmp,1.1  
sound.wave,2.0  
  


I suggest you read more about Split, Join, InStr, Mid, Left, Right, InStrRev. VB is really great at manipulating strings.

VBGamer © Go To Top Of Page
This page was generated in 0.19 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.