2

I need to add version info and retrieve it from the CHM file to make it possible to make an alert message to a user about a new CHM-file version available and downloaded.

It means, that I should compare versions of CHM on different machines (Server and clients).

The other way is date and time checking, but I should remember about time zones, so this is complicated, because also one should remember about different file systems, according to Windows SDK help about SetFileTime function and FILETIME structure.

If someone knows the trick - please share.

notricky
  • 179
  • 1
  • 2
  • 18
  • 2
    chm files don't have version information. You'll have to invent your own mechanism to keep track of this. Perhaps in an HTML comment in a defined topic? Or include a private topic in the chm file that just contains the version. `GetFileTime` returns a time in UTC. No timezone adjustments needed. – David Heffernan Sep 08 '14 at 10:13
  • Wow, such a simple idea about including additional topic. But how to read it? Or should I ask another question? About `GetFileTime`: when I download CHM to a client - it gets its own creation time. And when a time zone differs it becomes complicated. – notricky Sep 08 '14 at 10:22
  • GetFileTime and SetFileTime operate on UTC values. If you want to use the file time, then you need to set it explicitly when you write the file. File time sucks for this problem though. Reading the content of ch, files is probably a little tricky. I'd look for a library. – David Heffernan Sep 08 '14 at 10:30
  • 1
    Why not externalise the version information and have a version file (text or XML) on both your FTP server and your client machines? On startup (or whenever the app needs to check), your app can check the version on your FTP and compare it with the version it has, then download if necessary. Providing you have control over what's published on your FTP server there shouldn't be an issue with stuff getting out of synch. – Andy_D Sep 08 '14 at 10:35
  • I know its a big hack but could you use the CHM file size for this? – Keith Miller Sep 08 '14 at 10:39
  • @DavidHeffernan do you know any such library? Set and Get - the thing is to have same dates and times on both Server and Client hdds.Which also depends on file system. – notricky Sep 08 '14 at 11:29
  • @Andy_D it means that same files are to be on both machines. And a client should have to update this file also after updating CHM or other files. – notricky Sep 08 '14 at 11:30
  • @KeithMiller - is it not thruth that file size depends on the file system (FAT, NTFS, Ex32..) and compression is on or off? – notricky Sep 08 '14 at 11:30
  • I don't know any such libraries. Websearch should. – David Heffernan Sep 08 '14 at 11:30
  • @notricky I think you can get the actual file size which would be independent of those two. – Keith Miller Sep 08 '14 at 12:00
  • @KeithMiller Unless the new version had the same size as the old version. – David Heffernan Sep 08 '14 at 12:30
  • You could try reading a URL like this: `mk:@MSITStore:C:\somedir\somefile.chm::/html/SomeTopic.html` – David Heffernan Sep 08 '14 at 14:18
  • We have decided to use filetime of last change in utc to compare files. Hope this would work. The next would be a try with the additional topic as @Andy_D had suggested. – notricky Sep 09 '14 at 12:24

1 Answers1

2

.chm files don't have version information. You will need to find some alternative way to mark the file version.

One way that occurs to me is to include a topic in the help file that contains the version. I imagine that this topic would be hidden, that is not linked by any other topic, not in the table of contents, etc.

All that remains is for your application to be able to read that topic from the help file. I'm sure that can be done with a .chm file parser, if you can obtain one. Perhaps more easily you can get the platform browser to read the topic for you. You can use IHTMLDocument2 to read a URI like this:

mk:@MSITStore:C:\somedir\somefile.chm::/html/SomeTopic.html
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Can you give please a shot of code? I'm not pretty good at interfaces. – notricky Sep 09 '14 at 13:58
  • No. Sorry. I did a quick trial with `TWebBrowser` to prove the concept. I actually did it in VS with C# because it was easier. But I don't think this is the time or the place to explain how to use `IHTMLDocument2`. That's a quite separate topic. – David Heffernan Sep 09 '14 at 14:00
  • Yes, I did the same test with `TWebBrowser` but it appears to be dependent from it and cannot be universal. Although, I have searched through `Vcl.HtmlHelpViewer` and it appears that each query to CHM should be displayed, as all funcs and procs of `THtmlHelpViewer` (hidden after *implementation* section) refer to `Winapi.Windows.HtmlHelp` proc. Still I didn't know how to implement an interface `IHtmlHelpTester` (defined in the module) for any workout. – notricky Sep 10 '14 at 11:11
  • This is not the time nor place to teach you how to use `IHTMLDocument2`. Which would allow you to read the file without invoking a visual browser control. No point using VCL html help viewer. They won't be of any use to you. You don't want to view the help file. You want to extract its contents. I answered the question that you asked to the best of my ability. I'm sorry that it wasn't helpful to you. However, I think that the answer would be valuable to other readers even if you can't make use of it. – David Heffernan Sep 10 '14 at 11:17