Click here if you want to know more about the source and format of these pages.
This page is "browser friendly". Make your browser window as wide as you want it. The text will flow nicely for you. It is easier to read in a narrow window. With most browsers, pressing plus, minus or zero while the control key (ctrl) is held down will change the texts size. (Enlarge, reduce, restore to default, respectively.) (This is more fully explained, and there's another tip, at my Power Browsing page.)
In general, I adding third party components to my Delphi installation is something I avoid, but working with the HTTP protocol is not for the faint-hearted, and even after you summon your courage, you need something. No doubt the more "modern" (expensive, inaccessible to hobbyist) Delphis have some HTTP capability built in... but for those of us who buy our own software there are at least two possible answers.
The first is the excellent Internet Component Suite (ICS) by Francois Piette and the ICS community. Long established, well supported, free. I've written about it elsewhere. It is a little fussy about which version of Delphi you are using. Nothing insuperable. Delphi 7, at least, works well with it. I think you can make Delphi 4 work with it. I know the next suite works with Delphi 4.
In August 2013, I was looking for a way to do some TCP/IP things, and came across WinHTTP from down near the bottom of www.appcontrols.com/. (They seem to have a lot of neat things, not just components, but, on other pages, utilities for end users, etc.
I was impressed by their response to a question and by the clear, clean documentation of their product, and went straight to the purchase of a single user license, without sourcecode, for WinHTTP... only €18, about US$18. Simple ordering procedure. (They do it as shareware, too... but I think you have to do a re-install, rather than just put in a registration key. Everything else is clean and simple, so I suspect I am mistaken.)
Anyway, going my route, after sending off my money, an email came with a link to use to download my registered copies. I have three files in my downloads folder....
.. and a confession to make. I didn't record everything properly at the time. (But keep reading... later in this I will tell you, in detail, about a second install I did, with proper note taking!) I think I downloaded all three with the special link which I paid for... but the datestamps on the files make me wonder if that is true. I'm not sure I needed them all, but I wasn't sure I'd be able to use the link later, so downloaded all three, just in case. Before you pay for or install anything you can look at the excellent manual for the product via the link at http://www.appcontrols.com/manuals.html.
(For the second install, I used only one of the files. I may be "lacking" some helpfile material which I could provide for myself if I looked in the winhttp_help.zip file, but with just one of the files listed above, I built a "working" installation.)
Once you have those files on your computer (a computer which already has a Delphi set up on it) then you can set up your new tools. (The AppControls website says "Compatibility: Delphi 2/3/4/5/6/7/2005/2006/2007, C++ Builder 3/4/5/6/2006")
Further down the page, I will give you two accounts of setting up WinHTTP on your computer, in case I can save you some of the mistakes and puzzles got into when I did it. For now, let me talk a little more about WHY you would want to do it!
The first time I set WinHTTP up on one of my computers, I loaded their demo program into my Delphi 4 and compiled it. With it, un-tweaked, you can fetching stuff from the internet and saving it as a file. That's all I wanted to do, for now, so I was 90% done. (Of course, some little tweaks made the demo program do what I wanted to do more "my way"... but it fetched and saved without tweaks.) The package will do much, much more... but I leave that to you, or to me when a new "want" emerges....
(Since that first install, in January 2014, I used WinHTTP as the engine in a new version of an old program. With what I've written, I can visit my FarWatch pages, automatically, every 40 minutes (I can change the polling frequency), and see that the temperatures are above a critical value. If they aren't an alarm rings. So, if the furnace fails in winter, I will know about it before my pipes freeze.
TCP/IP transactions CAN be easy, even with "little 'ol" Delphi 4.
Buy the component suite... the authors deserve your $upport.
a) Many IPCams have a built-in URL which will serve up a jpeg of what the camera is looking at. These URLs can be accessed across the LAN the IPCam is on, or more widely, if the system admin chooses to allow it. I have several IPCams I can view with an ordinary web browser (I like Firefox) from anywhere on the internet.
With WinHTTP, you can write a simple program to "harvest" an image from any such IPCam according to any schedule you want to design. And, having harvested the image, you can save it to a hard disc, the cloud, etc, etc. You will have caught your rabbit.
b) If you have a PC based webserver... not rocket science... you can write programs to run on the PC, harvesting images or other data (temperature readings?)... and save them in a file in the server's "pages I serve" folder. (So far: Nothing involving WinHTTP).
With WinHTTP, you can then write programs to access those files from afar. I have, for instance, a computer at location "X" which runs the Apache web server. On that computer, a separate program reads the temperature in the house from time to time, and puts the numbers in a file in the right Apache folder. So far, nothing involving WinHTTP.
However, I have another program, which runs on a computer where I happen to be. That program "goes off" to the computer at "X" every 15 minutes, and checks the temperatures there, by looking at the file. If the temperature is too low (the heating has failed, and in winter I am on the way to frozen pipes), then the computer with the "watcher" program in it starts beeping, to alert me to the problem. It is this second program that you need WinHTTP, or something like it, to write.
c) It doesn't, these days, have to be a full blown PC running at the "location X" in scenario "c". You can have a little web server running, serving up a page with the temperatures embedded in some HTML for only about $50, and the cost of an always-on internet connection. I use an Arduino thus, but other micro-processors can do the same thing. Or you can buy a dedicated device, which is just a programmed Arduino (or similar) in a pre-configured "box".
As mentioned above, I've installed WinHTTP twice now. The first time, I did it badly, AND failed to take notes for creating an account of it for you. But I've left the account of that install first, below, as it may help you understand some things in the second account. The second time I did the install, I did it better, with fewer false starts, and recorded everything properly, with a view to providing the account to you. So skim the first account, and then slow down some when you get to the second account? I hope they save you some of the false steps I made.
One last prefatory comment: Nothing in what follows should be taken as disparaging what AppContols has provided. I found their documentation, etc, above average. But, you know, things could be made idiot proof, by vendors, if the idiots (e.g. me) weren't such CLEVER idiots... Sigh
Go to the manual for the product via the link at http://www.appcontrols.com/manuals.html. It includes very lucid installation instructions, with the variations needed for each version of Delphi. Each starts with "1. Create "..\Lib\WinHTTP" directory." Note the "..\Lib\" at the start of that. You have to install your Delphi before installing WinHTTP. When your Delphi installed, it created a folder, and many folders inside it... one of them called "Lib". It is inside this that you must, by hand, before doing the rest of the WinHTTP install, create a folder which the install will use.
By the way... I did the next bits specified in the manual with my Delphi 4 not running.
Humm... may have been false start. I then double-clicked on the winhttp_setup.exe file I had in my downloads folder. It too talked... if you read the bit we usually skip over... about a "by hand install". But when I ignored that, and clicked "next", it seemed to be going on to something that would to it all for me... but in a different folder. I left that at the default folder. Next came a "Select components" window. I deselected most things... but not everything except "WinHTTP for Delphi 4". There were three files at the bottom of the list that looked worth having, too.
In the "Program Group" window, I accepted the default "UtilMind\WinHTTP".
The setup program ran to completion. I had lots of new stuff in "C:\ProgramFiles\Utilmind Solutions", and a new entry in my Start Menu. ("UtilMind"). (The machine was running Windows XP)
I fired up my Delphi 4. Did File/Open, and drilled down to...
C:/ProgramFiles/ UtilMind Solutions/ WinHTTP/ Delphi4
... and there was the WinHttpD4.dpk the install instructions had promised. Opened it. Got a small window with a hierarchy of "stuff" ("Contains... WinHTTP... etc... down to Requires... vcl40.dcp")
Clicked the "Install" button... as instructed in the WinHTTP guide.
Got a nice message saying stuff had been installed, including two new components, TWinHTTP and TWinThread.
Started closing windows. Got "Save changes to project?"... said no, hoping that the setup was done for all time, and the offer to save the project was irrelevant.
Closed my Delphi. Reopened it. And there, hurrah, in the components palette, a tab for UtilMind. I'd SKIPPED the "Unzip files and copy to..." step mentioned a few places, and my ../Lib/WinHttp folder was empty. I suspect that the setup.exe program merely streamlined the copying of a selection of files for me. I also suspect that I could have created a folder "My3rdPartyAdditions" (or somesuch) in my Delphi folder. But what I have will work fine. (I deleted the empty ../Lib/WinHttp folder.)
I then tried to run the HTTPDemo which was supplied with the software. On first attempt to compile: "Fatal Error: File Not Found: WinHTTP.dcu"
Easily fixed that by making a copy of WinHTTP.dcu which was at....
C:\Program Files\Utilmind Solutions\ WinHTTP\Delphi4\WinHTTP.dcu
... and I copied to my....
... folder. Is this a flaw in the WinHTTP setup routines? Maybe, maybe not. Remember: I used a mix of their setup.exe and the "by hand" instructions. I also half remember something about some versions of Delphi not allowing the use of third party components. Maybe mine is supposedly "third party locked", but only weakly.
The "solution" I used will make WinHTTP.dcu for anything compiled on that machine... but it also slightly "confuses" my installation. (I prefer to put add-ons in an add-on directory.) No big deal. If you really, really don't want to put WinHTTP.dcu in the main library, you can put it in the project's folder. But if you go that route, and if you use a separate folder for each project, you will need multiple copies of WinHTTP.dcu.
Happy(?) middle ground: Put third party .dcus in your Delphi/Lib folder... but also maintain a text document explaining the ones you've added.
If you do what is described above, and try to compile the demo again, you'll get "Fatal Error: File Not Found: WinThread.dcu"
I suggest that you do what I did: Copy all the .dcu files across, so they'll be there when needed. (I found four when I did this 1 Sept 13)
After that, the demo compiled. I pointed it at a web page I maintain; left everything else at default. Then I clicked the "Go" button, and "presto", the HTML behind my page came up in the memo!
I then pointed the demo at a jpg image I have on a server and clicked "Go". Renamed C:/httptest.dat as testhttp.jpg, double-clicked on the file that the demo had put on my disc, and "presto" the image came up in my default image viewer!
Back when I did the first install and first version of this webpage, I finished with "Simple! Simple! This component is going to be a joy to me, if it keeps working so effortlessly."
In January 2014, I did a fresh install of WinHTTP on a different PC, this time one running Windows 7. On that computer, there was a tried and tested instance of Delphi 4, Standard, Build 5.108, with Update Pack 3 installed.
I may have misunderstood things, when I made my first trials, but it seemed that while you could try the product for free, if you then went on... for not very much money... to become a registered user, you then had, essentially, to reinstall the product from different setup files. (After you send them your money, you are given a link to download some files. Different, I think, from the ones you used to try out the product.
I don't like running setup files on my machines... who know what they will do?... so I try to "do it right" once, instead of using the "two- install" method.
In January 2014, I used the files I'd fetched back in September. There is, alas, some weakness in my notes of the history of those files. Here's what I had...
winhttp_pack.zip winhttp_setup.exe winhttp_help.zip
... I just can't promise you all I would like to be able to about them. I THINK all three were things I downloaded with my special "now that you've paid" download link.
Whatever the details: The good news: I have the stuff I need, on MY machine, what I need to set the suite up again, should anything happen. I won't be left just hoping that I'll be able to get the files from the AppControls at some future date.
So, my second attempt is different from my first trials in that I will skip the "install free version first" step.
To re-state something I hope I've made clear already: Be sure you have a healthy basic Delphi development environment installed and working before you tempt fate with adding a third party component.
Be careful when installing third party components. While a degree of integration between them and Delphi is necessary, I try to keep "what came from where" clear, as far as I can. I also try to keep things "separate" in hopes of minimizing unhealthy interactions.
These philosophical predilections are behind some of the choices you may note me taking in what follows. It is not "the only" way to install WinHTTP.
Before I started, I wanted to know my baseline. One folder in particular was of interest....
C:\Program Files (x86)\Borland\Delphi4\Lib\
That had a bunch of .dcu files in it, and one subdirectory (aka "sub-folder"), "Delphi2"
At the cost of many geek and guy points, I will say that "If all else fails, read the instructions" is a bad philosophy. Instead of accumulating failures you will then have to deal with, read the manual first. But remember that it may have to be taken with a pinch of salt. Aspects of the current product may not be exactly in step with what's in a manual which may be a little out of date. Sigh.
The pretty good, as these things go, manual is available to anyone via http://appcontrols.com/manuals.html. It has some install directions... but combine your reading of them with what I've written below. (Note to self: My copy on pcVash//Z://dls-manuals)
The files I had from my downloading were....
winhttp_help.zip winhttp_pack.zip winhttp_setup.exe
I also had a pre-existing directory (aka "folder") thus:
C:\Program Files (x86)\Borland\Delphi4\Lib\
(It had a bunch of .dcu files in it, and one sub-folder called "Delphi 2"
Now... despite what I said about reading manuals a moment ago, this time I tried simply double clicking on the winhttp_setup.exe... after prefixing both of the other filenames with "zz-", in hopes of learning if they were used by the setup routines or not. This is not generally a wise thing to do, but in this case, I thought I could justify it.
Note in particular that I haven't done the folder creation or file copying suggested, 1/14, in the Installation Instructions.
The setup routine suggested doing the install to...
C:\Program Files (x86)\Utilmind Solutions\WinHTTP
.. but I, recklessly, for reasons of my own revised that so that this new stuff was at least "inside" the Delphi hierarchy. I made it....
C:\Program Files (x86)\Borland\Delphi4\Utilmind Solutions\WinHTTP
Next I was asked which components I wanted to install.
I DE-selected almost everything in the list, keeping just...
I just went with the flow, in the rest of the setup process, and it preceded smoothly, finishing with a message saying that setup had been successful. Even with the two files I have from somewhere renamed... It seems the setup process didn't need them.
On my hard disc, in...
C:\Program Files (x86)\Borland\Delphi4\
... there was, as expected, a new folder, Utilmind, full of "stuff". It hadn't been there previously.
Note... of the steps given in the Installation Instructions...
1. Create "..\Lib\WinHTTP" directory. 2. Unzip files and copy them to "..\Lib\WinHTTP". 3. Start Delphi 4 IDE. 4. Open "WinHTTPD4.dpk" file. 5. Install package to the components palette ("Install" button).
... I have, so far, not done anything quite the way they suggest.
I'm going to do what they tell me to in step 1. I like that they've used a sub-folder within Lib, instead of presuming to "dump" their files in among other people's files.
I am not going to do step 2 quite as they've described it, "unzip...". Instead I am going to take some stuff created by the setup program we ran, and copy that to the folder I just created. The "some stuff" is everything in....
C:\Program Files (x86)\Borland\Delphi4\Utilmind Solutions\WinHTTP\Delphi4\
... "everything" being about 10 files of various types... 5 of them .dcu files.
So far, I hope, so good. We have the things we need, where we need them. Now Delphi needs "tweaking", so that it knows what we've made available, and offers certain things to you when you are using your Delphi. So...
Next I started up Delphi.
Clicked "File/ Open" from the menu, and drilled my way to...
C:\Program Files (x86)\Borland\Delphi4\Utilmind Solutions\WinHTTP\Delphi4\WinHTTPD4.dpk
... which, in my case, meant going "up" first, from...
C:\Program Files (x86)\Borland\Delphi4\Lib
... in order to go "down" through "...\Delphi4\Utilmind Solutions\WinHTTP..."
After I had selected the file, and clicked the open button, a small dialog came up explaining what the package was going to install. Looked okay, so I clicked the "Install" button in the toolbar.
I was rewarded with a reassuring "WinHTTPD4.bpl has been installed.... new components: TWinHTTP, TWinThread
Sure enough, the components palette had a new tab, UtilMind, with those components on it.
To test whether what I'd done WORKED, I shut Delphi down and restarted it, just to be thorough. (I fluffed (?) that, got a few odd messages, and said "Don't save" to get out.)
I then opened...
C:\Program Files (x86)\Borland\Delphi4\Utilmind Solutions\WinHTTP\Demo\HTTPDemo.dpr
... and a project with one unit, one form came up.
Tried to run it, and got...
[Fatal Error] Unit1.pas(7): File not found: 'WinHTTP.dcu'
A nuisance... but I wasn't too surprised. I THOUGH that all I needed to do was to go into Tools/ Environment Options, go to the "Libraries" tab, and add ";$(DELPHI)\Lib\WinHTTP" to the end of the list of paths. But my "Add" button was grayed out. Was "Delphi 4/ Standard" one of the ones you couldn't add third party components to? (No... windows 7 "being helpful" again. You can either use my work-around, below, or go into the Registry, if want to take the risk, and edit the library search path entry for Delphi under Current_User. Sigh.) We've already MOSTLY "added" it.
My work-around? I just put a copy of...
C:\Program Files (x86)\Borland\Delphi4\Lib\WinHTTP\WinHTTP.dcu
...in the folder of each program I want to use WinHTTP with. Once there was a copy of WinHTTP.dcu (and WinThread.dcu, from same source folder) in...
C:\Program Files (x86)\Borland\Delphi4\Utilmind Solutions\WinHTTP\Demo\
.... the demo almost compiled happily. But now I was getting...
[Error] Could not create output file, 'C:\Program Files (x86)\Borland\Delphi4\ Utilmind Solutions\WinHTTP\Demo\HTTPDemo.exe'
This was Windows 7 being "helpful". Because the output folder was within one of the "Program Files" folders, it had restrictions on it's permissions. I fiddled with the permissions, and was, finally, able to run the demo. It would have been wiser to make a copy of the folder with the demo app in it, and put that out in a less protected part of the hard drive. (I tried that too... worked fine.)
Oh! What does "worked" mean? What can you do with the demo? Enter a URL, e.g. wikipedia.com, into the URL box. Be sure the Output to memo" radio button is ticked. Click Go. You should see the "Output" memo fill with stuff. I got....
<!DOCTYPE html> <html lang="mul" dir="ltr"> <head> <!-- Sysops: Please do not edit the main template directly;.....
When I did it just now.
Forgive me abandoning this here? I hope you have what you need? If not, do please write and explain what's missing!!
Page tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org
....... P a g e . . . E n d s .....