How do I make a Delphi control panel applet be non-'legacy'? - delphi

I have a Delphi .CPL currently written with Delphi 7 which needs to update settings in HKLM (to be used by a service application) and which must support Vista, Win7 and Server 2008. Currently this can be done by adding a RUNASADMIN value to AppCompatFlags/Layers, using the CPL file as the value name. This causes Windows to ask for elevation for a 'legacy control panel applet'.
I need to find a way to build the CPL in Delphi 2010 without it appearing to be 'legacy' and, if possible, not to require the registry setting or elevation. Adding the usual manifest resource to the DLL/CPL referencing Common-Controls v6 and "requireAdministrator" does not fix the problem: no elevation is requested and HKLM access fails. Both the original and the Delphi 2010 .CPL can be made to run correctly (after elevation) by navigating to the file in SYSWOW64, right-clicking, and running 'as Administrator'.
Later: I have found a succint explanation of why you cannot elevate a DLL in this way in a forum posting here.

I believe you need to use COM elevation. There was a wonderful blog posting on this which appears to have been taken down, but the source code behind the posting is still available on the VCL components website (way back machine link).
Some additional information can be found in the question/answers for: Delphi: Prompt for UAC elevation when needed

I think I have found a better answer to my question. There is such an animal as a 'non-legacy' control panel applet, which is described in MSDN here. "Now, in Windows Vista, you can add your own applet to Control Panel by creating an executable for your applet and registering it, instead of going through the trouble of creating a .cpl file."

Related

procedure _ftol2_sse being called after update to Delphi XE?

In our program we are using a web service to pull back data from a third party into our program.
Ever since we updated to Delphi XE from Delphi 2009, Windows server 2003 users are receiving the following error message when making a SOAP call to the web service.
msvcrt.dll on Server 2003 does not have the procedure _ftol2_sse which is now being called for some reason..
I know this procedure was not being called when we had our source code on Delphi 2009 because I don't get this error on Windows server 2003 when running those builds.
Is this feasible? Could a change in the IDE affect which dll procedures are being called? Does anyone have any insight or ideas on how I might track down or fix this error?
Thanks
This is the third similar question you have asked on this topic. I'll attempt to give you some background information and help you work out what is going on.
First of all it's important to know that msvcrt.dll is a system component. It is not the MSVC runtime. It is supplied as part of Windows. Back in the bad old days, in the mid-90s, a lot of devlopers assumed that the MSVC6 runtime was always available. And they neglected to install that runtime as part of their program's installation. This occasionally caused trouble when the install program happened to find a machine without MSVC6.
The MSVC team moved to differently named runtime DLLs, msvcrt70.dll, msvcrt80.dll and so on. And they educated the developers that installing the MSVC runtime should be part of all MSVC application's installation programs.
But the Windows team wanted to help out legacy apps that had installers that assumed MSVC6 runtime was available. So they took the MSVC6 runtime under their control and started shipping it with Windows. I think this started around the time of Windows 2000 or XP.
The point I am trying to make is that msvcrt.dll is a system DLL over which you have no control. In your previous questions you have described your attempts to modify that DLL. Don't do that.
Now, from what I can glean, the version of msvcrt.dll that shipped with 2003 server does not export a function named _ftol2_sse. Hardly surprising since SSE floating point was not widely available back in the days of 2003 server. Clearly something in your system is resulting in an attempt to import _ftol2_sse.
You should be able to work out what is provoking this by using Dependency Walker. Use the functions on the Profile menu to start your application and study closely the logs. You should be able to see the chain of events that lead to an attempt to link to _ftol2_sse.
I'd be surprised if any of the Windows code linked to msvcrt.dll. That library is provided purely as a prop for legacy apps that link against MSVC6. But you never know.
Also try loading your executable in Dependency Walker. Look at the list of imported DLLs. Check to see if msvcrt.dll is in the list. If so, see what functions your executable imports, and if _ftol2_sse is in that list. If so then you'll be able to find it somewhere in the Delphi source code.
From the various similar sounding reports on the web I suspect that the problem you face is benign. Many of the people reporting the same issue can OK the dialogs and have their program continue without problem. This suggests that you can simply suppress the error reporting and so solve your problem. Use the SetErrorMode function to do so. You want to include the SEM_FAILCRITICALERRORS flag.
Be aware that SetErrorMode has a rather perverse interface. Almost all code that I have ever seen uses it incorrectly. Including the code in the Delphi RTL, and so many of the commonly used Delphi third party libraries. Raymond Chen, as usual, explains how to use it correctly.
Could switching compilers provoke the behaviour change? Certainly they could. Either the library code that you are using is implemented differently. Or perhaps the error mode is somehow different at the crucial moment.

New TFrame and TDataModule crashing Delphi IDE

Here is the problem I've met:
Working in BDS 2006 IDE, my older computer gone, new ( i7 mount ) has been built and it has Windows 7 Ult OS 64bit, where 2006 was installed and QuickReports Pro as well as eDocEngine, FIB+, TMS, LMD, ZEOS & DB Comparer Component Packs - I use them in my products.
On computer I have Office 2010 installed as well, by default in 32bit version and Adobe CS6. That's it.
After installation I tried few times reinstall RAD 2009 and anyway, always the same problem, to simplify it is 100% reproducable like that:
Create new Delphi VCL Forms application ;
Click File / New / Other and goto, say, "Delphi files" and select Frame or DataModule. When new file is created, all the time we have message:
"Stack overflow - save your work and restart Delphi for Microsoft Windows"
After that IDE set in bad state and next F12 ( show VCL designer) closes Delphi with General Error.
Any idea what happens?
As I said, I tried few time uninstall - install 2006, start in any personality, use / do not use any of the updates or IDE fixes from Andy's site, nothing helps.
Any help would be greatly appreciated.
You can try running a second instance of the IDE in the debugger.
Create an empty dll or package project.
Open Run > Parameters
Set the host application to $(BDS)\bin\BDS.exe
Then just hit F9 to run the second instance of the IDE in the debugger. After that just follow the steps to reproduce the problem and wait for the exception. If all goes well you'll get a complete call stack to step through.
Note: You may see various other exceptions occurring as the IDE loads. These are normal and can usually be ignored.
Also you didn't mention what version of Windows was on your old machine. If it was Windows XP Uwe could be right. XP was a little more lax on security by default than Vista or 7. The new default is to restrict write access to any folder under Program Files. If that turns out to be the problem you can adjust the write permissions for $(BDS) for whatever user account you use for development.
Delete de PackageCache in Embarcadero registry entries. Its not a complete solution but worked for me.
Got that from here: http://qc.embarcadero.com/wc/qcmain.aspx?d=118669 (last answer).
I have no BDS 2006 at hand, but is it possible that the default folder for new projects is located below the Program Files folder? In that case there might be no write access to that folder.

Using TChromium, Delphi Chromium Embedded

This is a continuation of my last question. In that question I showed a problem involving TWebBrowser generating threads that persisted after the Browsers destruction. While noone could provide a solution to the problem, it was suggested that the problem could be a non-fixable one (a flaw with the TWebBrowser component itself).
Because of this I have attempted to download and use the Delphi Chromium Embedded Framework. I downloaded the components and added them to Delphi, added one to a new form and attempted to run the program, at which point it throws up a CPU break point at
5264DF81 6A01 push $01
Module Load: icudt46.dll. No Debug Info. Base Address: $562C0000. Process DCEFTestRun.exe (3080)
There is no error message, but when the program is continued manually it closes. I have had no experience with DCEF before, nor any experience using 3rd party components and the DCEF site is sorely lacking in documentation.
I suppose the easiest thing i'm asking for is a simple walkthrough (very basic) of what to download/install and where to get the Chromium Components to work.
Thankyou in advance.
You are missing the Chromium Embedded Framework (CEF) core libraries. It is enough to copy the content of the ..\dcef\bin\Win32 folder (from your downloaded package) into your project's output directory (or into some of the known folders location reachable from your project's executable).

are delphi 2010 programs capable of tackling vista/win7 UAC by default

if you compile a program in D2010 a manifest .res file is automatically generated. is it included in your program by default? or you have to include it yourself?if yes what level of privilage is given to you? my program modifies a registery key would it be able to do so with out any modifications to .res file?if no what modifications i need to do?
a side question: is there a component/expert(prefably free) that can generate/include .res file in my delphi 7 and delphi 2007 projects automatically just like delphi 2010?
edit: forgot to mention i do not have win7 or vista nor have i ever used them
edit2:i have included a manifest file just in case following this tutorial but the tutorial only talks about windows vista and not 7 would the .xml(manifest) file in this tutorial make my app capable of dealing with win7 UAC too
edit3 if i include my own manifest file and delphi is including it by default as well that will make 2 manifest files(1 with admin previlages and 2nd without) would this cause any problems/unpredictable behaviour
The manifest generated by delphi gives your process the lowest privileges (that is the default by the way).
You have to modify the manifest file in order for it to ASK for permission to be run under administrative rights (Called elevation).
Your application with the standard privileges should read/write to HKEY_CURRENT_USER without elevation.
Accessing %programfiles% and HKEY_LOCAL_MACHINE requires elevation. (Not so sure about the other registry hives)
This is a PDF that will help you A LOT with what you're up to.
http://pascalfonteneau.developpez.com/articles/delphi/vista/uac/VistaUACandDelphi.pdf

Pegasus Imaging PrintPro ActiveX control gives error when dropped on Delphi form

I'm trying to use the Pegasus Imaging PrintPro v4 ActiveX control with Delphi 7 on a Win2K box. When I drop the ActiveX control on the form I get the extremely helpful error message
"Access violation at address 00000000. Read of address 00000000."
and the component doesn't appear on the form.
There are a bunch of other Pegasus Imaging ActiveX controls installed and they work fine.
Any suggestions on where to start troubleshooting, I'm not very experienced with ActiveX control (I usually go for native VCL only).
Lachlan
If you download the latest changes file it says that "Fixed an issue where the ActiveX DLL would not register on Windows 2000.".
You should try upgrading to the latest version.
Something in the control is not configured properly. You might not be able to "drop" it on the form, but might have to instantiate it manually. The access violation you are experiencing is the attempt to get the value out of a pointer which is null. Most likely the control has a required construction parameter which is not being set by the Delphi ActiveX component wrapper.

Resources