Solve ActiveForm automatically update

zhaozj2021-02-16  47

ActiveForm UpdatesActiveForms are a quick way to create a browser-based application and still be able to use all of Delphi's visual components and design-time support. If you have an existing Win32 GUI application and want to move to the web with it, then ActiveForms are certainly an option to consider (although you must be aware of the downsides: it only runs natively inside Internet Explorer, and really requires Win32 as client operating system) and apart from the code signing (security!) issue, which can take some. time to setup, ActiveForms are really a quick solution to put a first version of your app in the browser. Until you want to deploy an updated version, that is, at which time you may find that the client (running Internet Explorer) not always automatically uses the new version of the ActiveForm. In fact, the current way Delphi generated ActiveForm deployment files and Internet Explorer "interact", it would be a miracle if your real-world ActiveForm would be automatically u Pdated Even ONCE AT The Client Side. Fortunately, I've Found An Easy Workaround, But Let's Take A Closer Look At The Cause of this Problem First ...

Before we start looking at the problem, I assume you've all started an ActiveForm with the "include version information" enabled, as well as all other "auto-increment build number" and "auto-increment release number" options inside the Project Options and Deployment options dialogs. If you do not include version information with your ActiveForm, then you do not even need to read the remainder of this little article, as there will be no way where-ever that Internet Explorer on the client will be able to determine that a new version of the ActiveForm exists Which means clients need to stick with the original version (unless you can instruct them to either manually delete either the old one, or download and install the new one -. yeah, right, and maybe Borland will buy Microsoft to fix these miscommunication problems next time) .Anyway, when deploying an ActiveForm, Delphi (and C Builder) generates a number of files. If you do not use .CAB file compression and also do not deploy Any Package s or additional files, then Delphi generates a single .HTM file and a single .OCX files (both with filenames equal to your projectname). The .HTM file will contain a section that identifies the ActiveForm to be loaded, which also includes the version Number, As Follows:

"CLASSID =" CLSID: 42424242-4242-4242-4242-424242424242 "

Codebase = "./ DRBOB42X.OCX # Version = 1, 0, 0, 0"

Width = 640

HEIGHT = 480

Align = center

HSPACE = 0

vSpace = 0

>

Now, if you either specify that you want to use .CAB file compression (always a good idea) or you need to deploy packages or additional files, then Delphi will generate an .HTM file that will not directly specify the ActiveForm with a version number ., but rather an .INF file (without a version number - that's the problem) This .INF file will in its turn contain the specifications of the ActiveForm and all other deployed files, including detailed version information, for example as follows: [Add .Code]

DRBOB42X.OCX = DRBOB42X.OCX

VCL50.bpl = vcl50.bpl

[DRBOB42X.OCX]

File =. / DRBOB42X.CAB

CLSID = {42424242-4242-4242-4242-424242424242}

RegisterServer = YES

Fileversion = 1, 0, 4, 2

[Vcl50.bpl]

File =. / vcl50.cab

Fileversion = 5, 0, 6, 18

Destdir = 11

The problem when using an .INF file (which you get - again - even if only using .CAB file compression), is that Internet Explorer only looks at the version information inside the HTM file in order to determine whether or not to download a new set of files from the server. Even if we supply a new INF file with higher version numbers, Internet Explorer will not check these version numbers and download a new ActiveForm. This has been a problem for a long while now, and a potential showstopper for Real-World Applications Using ActiveForms.

Fortunately, There's An Easy Workaround I Discovered: Just Specify The Version Number Inside The HTM File, The HTM File Will Originally Contain The FOLLOWING SNIPPET:

"CLASSID =" CLSID: 42424242-4242-4242-4242-424242424242 "

Codebase = "./ DRBOB42X.INF"

Width = 640

HEIGHT = 480

Align = center

HSPACE = 0

vSpace = 0

>

As soon as you enter a version number to this ./DrBob42.inf file, then Internet Explorer will be triggered to compare it to the local version, and download a new ActiveForm (and if needed packages and additionally deployed files as well). In Short, The "Working" Object Code Snippet 10.4.2. Version Number Inside The DRBOB42.INF File:

"CLASSID =" CLSID: 42424242-4242-4242-4242-424242424242 "

Codebase = "./ DRBOB42X.INF # Version = 1, 0, 4, 2"

Width = 640

HEIGHT = 480

Align = center

HSPACE = 0

vSpace = 0

>

The only downside is that you need to manually adjust the HTM file everytime you deploy your ActiveForm. But that's not really a problem, since I doubt you'd want to use the HTM file generated by Delphi (or C Builder) in a real-world situation anyway. It only means you need to look into the .INF file to find out the actual version number (which in my case increases after every build and every deployment) and modify the HTM file to reflect that new version. and That Will Make Sure All My Clients Will Get The Right New Version of The ActiveForm Next Time The Load Internet Explorer, as The Yy Should.

One final word of caution: if you've selected the "auto-increment build number" and "auto-increment release number" options, then you should know that the release number will be auto-incremented right after you've deployed the ActiveForm . in other words:. right after you've deployed it for the first time, the ActiveForm version on disk (and on the server) will be 1,0,0,0 However, the file version information in your current project will then show 1,0,1,0 - ie the release number (third number of the series) in the IDE will always be one higher than the release number of the actually deployed ActiveForm This is not so with build numbers (fourth number of the. series) - these will always be in sync Remember this when you client calls and specifies the version number (and it might also be a good idea to have the ActiveForm display the version number somewhere in a lower-left corner, for example).. .. The prawn is empty translation ^ _ ^.

In fact, it is said that it is a sentence, modify Delphi automatically generates (of course, you can also manually do one) test ActiveForm's HTML file, add a "# version = 1, 0, 4, 2" in the original CodeBase, this version number OCX File version number

转载请注明原文地址:https://www.9cbs.com/read-28332.html

New Post(0)