Darren DICK
d.dick at uws.edu.au
Tue Feb 22 17:44:07 CST 2005
Gustav is a legend Chacha chacha cha
Outstanding this is perfect
For anyone who cares
This is going to be part of any app I deploy.
The code reads the text file and if the contents of the text file is -1 then
the
App stops running
If the contents of the text file 0 then the app just keeps opening as normal
It is a (simple) method I intend to use to 'stop' users of my software who
don't pay
I have a special folder on my website for their app for updates etc
So if they don't pay I also have the special "Have or Have not paid" text
file in that folder
When they are late paying or refuse to pay I ftp to my website and change
the contents
of the text file from 0 to -1. Next time the user loads the app it reads -1
from the text
File and halts and alerts the users.
Code is
If
OpenURL("http://www.somedomain.com.au/updates/AppName/PaidOrNot.txt") = "-1"
Then
Msgbox "No pay? - No go", vbGotcha,"Pay or Else"
ElseIf
OpenURL("http://www.somedomain.com.au/updates/AppName/PaidOrNot.txt") = "0"
Then
'Do nothing let the app load
End If
Of course this depends on an active internet connection but I can test for
that in code too
It is very simple and can be easily 'gotten around' if you know how, but
most people won't know how
Many many thanks Gustav
Thanks to all the others who replied
Andy - I'll give you a call in the next day or so to bring you up to speed
SYWYE
Many thanks
This list is awesome
Darren
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: Wednesday, 23 February 2005 4:05 AM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] Read contents of Text File form Web Site
Hi Darren and Andy
This line must be uncommented; but I'm not sure what sAgent is, could be
empty:
hInet = InternetOpenA(vbNullString, OpenType, vbNullString, vbNullString,
0)
Then this call reads a file off our web server:
? OpenURL("http://www.cactus.dk/Files/Access2/Acc2Date/ReadMe.txt")
/gustav
>>> Gustav at cactus.dk 22-02-2005 17:38:01 >>>
Hi Darren and Andy
Here's some code to read the file off the web server using winnet.dll:
Option Compare Database
Option Explicit
Private Declare Function URLDownloadToFile Lib "urlmon" Alias
"URLDownloadToFileA" ( _
ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) _
As Long
Private Declare Function InternetGetConnectedState Lib "wininet.dll" ( _
ByRef lpSFlags As Long, _
ByVal dwReserved As Long) _
As Long
Const INTERNET_CONNECTION_MODEM = 1
Const INTERNET_CONNECTION_LAN = 2
Const INTERNET_CONNECTION_PROXY = 4
Const INTERNET_CONNECTION_MODEM_BUSY = 8
Const INTERNET_RAS_INSTALLED = 16
' Atomic clock.
Private Declare Sub InternetCloseHandle Lib "wininet.dll" ( _
ByVal hInet As Long)
Private Declare Function InternetOpenA Lib "wininet.dll" ( _
ByVal sAgent As String, _
ByVal lAccessType As Long, _
ByVal sProxyName As String, _
ByVal sProxyBypass As String, _
ByVal lFlags As Long) _
As Long
Private Declare Function InternetOpenUrlA Lib "wininet.dll" ( _
ByVal hOpen As Long, _
ByVal sUrl As String, _
ByVal sHeaders As String, _
ByVal lLength As Long, _
ByVal lFlags As Long, _
ByVal lContext As Long) _
As Long
Private Declare Sub InternetReadFile Lib "wininet.dll" ( _
ByVal hFile As Long, _
ByVal sBuffer As String, _
ByVal lNumBytesToRead As Long, _
ByRef lNumberOfBytesRead As Long)
'
Public Function OpenURL( _
ByVal URL As String, _
Optional ByVal OpenType As Long) _
As String
Const IOTPreconfig As Long = 0
Const IOTDirect As Long = 1
Const IOTProxy As Long = 3
Const INET_RELOAD = &H80000000
Dim hInet As Long
Dim hURL As Long
Dim Buffer As String * 2048
Dim Bytes As Long
Select Case OpenType
Case IOTPreconfig, IOTDirect, IOTProxy
' OK
Case Else
Exit Function
End Select
'Inet-Connection öffnen:
' hInet = InternetOpenA("VB-Tec:INET", OpenType, vbNullString,
vbNullString, 0) ' hInet = InternetOpenA("Cactus:INET", OpenType,
vbNullString, vbNullString, 0)
hURL = InternetOpenUrlA(hInet, URL, vbNullString, 0, INET_RELOAD, 0)
'Daten sammeln:
Do
InternetReadFile hURL, Buffer, Len(Buffer), Bytes
If Bytes = 0 Then Exit Do
OpenURL = OpenURL & Left$(Buffer, Bytes)
Loop
'Inet-Connection schließen:
InternetCloseHandle hURL
InternetCloseHandle hInet
End Function
/gustav
> What code do I need to read that text file from the website and return
> the Contents of the text file to my dB? Ie the -1 or the Zero?
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com