Delphi Xe2 Package x64 - delphi

Let's admit, I create new package in Delphi Xe2. I keep under a name "My". I add a simple component "MyComponent". I compile, I receive file Bpl in C:\Users\Public\Documents\RAD Studio\9.0\Bpl\My.bpl.
I add a platform "Win x64".
I compile, I receive C:\Users\Public\Documents\RAD Studio\9.0\Bpl\Win64\My.bpl.
...\Bpl\Win64\My.bpl to establish as new package does not give, writes "is not windows x32 applications".
The first is established normally and on a palette the component appears "MyComponent".
If to bring to are mute the index of a mouse will appear hint where it will be written, that it x32-compatible.
And at native component Delphi - at all x32-64 compatible.
Together with a disk to Xe2 there is a free disk with Free and Tral components if to put therefrom for example OverByteIcs or Ip*Works, that at them at all components will be 32-64х compatibility.
Questions:
1. How to establish the x64 the version package?
2. How to achieve, that the component had a compatibility 32-64, and not just 32?
P.S. Bad English language: ON

The Delphi IDE is 32 bit and so can only load 32 bit designtime packages. You can of course create 64 bit runtime packages.

Has earned, has understood!
We create empty package
We add the component, for example Button and it is specified what platforms for a component (the key moment are necessary!)
Example
unit GuButton;
interface
uses
System. SysUtils, System. Classes, Vcl. Controls, Vcl. StdCtrls;
type
[ComponentPlatformsAttribute (pidWin32 or pidWin64)] // !!!!!!!!!!!!!!!
TButtonGu = class (TButton)
private
{Private declarations}
protected
{Protected declarations}
public
{Public declarations}
published
{Published declarations}
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents (' Gu ', [TButtonGu]);
end;
We keep, we compile under x32. We add a platform x64 (in options should be registered, that directories under platforms different).
We compile under x64. We receive 2 BPL (as in the first question). We establish x32. We look - new component ButtonGu - 32-64 compatible was added.
Here I that wanted, all thanks.
In addition http://docwiki.embarcadero.com/RADStudio/en/64-bit_Cross-Platform_Application_Development_for_Windows

Related

How work with Word and Excel in Delphi?

I use Delphi X10 and Word 2016 64-bit on Windows 10 64-bit.
I always used ComObj.
for example:
uses ComObj;
procedure TForm1.RzBitBtn1Click(Sender: TObject);
var Excel: variant; i, j: word;
begin
Excel := CreateOleObject('Excel.Application');
Excel.Workbooks.Open('file.xls');
for i := 1 to 5 do
for j := 1 to 5 do
StringGrid1.Cells[j, i] := Excel.Sheets[1].Cells[i, j].Text;
end;
But, i want to use autocompleate for Excel methods. I read what i should import type library, but i cant find type library file in my system.
This is quite easy to do, as long as the type libraries for Excel anmd Word are correctly registered.
Go to the OCX\Servers folder under your Delphi install and find Word2010.Pas. Add it to a new VCL project, and USE it in the main form's unit. Declare a form variable A: WordApplication on your main form.
With that done, you should be able to go to Form1's Form.Create, type
A.
and autocomplete should offer you the possibilities for WordApplication's methods and properties.
Now, open Word2010.Pas and find the section
// File generated on 2/20/2013 5:56:45 PM from Type Library described below.
// ************************************************************************ //
// Type Lib: c:\Program Files\Microsoft Office\Office14\msword.olb (1)
// LIBID: {00020905-0000-0000-C000-000000000046}
That tells you the name and location of the type library which was used to generate Word2010.Pas.
Now, unless you need to use some method/property that has been added to Word/Excel since the 2010 version, Word2010.Pas and Excel2010.Pas may be all you need. However, you can import the type library of a more recent version using Delphi and have it generate an import unit for it. Exactly how to do that depends on your Delphi version, but for Delphi Seattle. you simply go to Component | Import Component from the IDE main menu, then select Import type library in the pop-up and follow the wizard's prompts.
Once you've generated the import unit, obviously you simply USE it in your project instead of MSWord2010.
Btw, strictly speaking, there is no "Delphi X10", recent versions (since XE8) have been Seattle, Berlin and Tokyo.

Can't load package %s error while installing a package

I'm testing on Delphi 2007 and my groupproject is composed by 2 packages.
PackageRun.bpl
It's marked as "runtime only" and contains a unit named "uMyTestRun.pas" in which is defined an empty TFrame descendant:
unit uMyTestRun;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TMyTest = class(TFrame)
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
{$R *.dfm}
end.
PackageDes.bpl
It requires PackageRun.bpl, it's marked as "designtime only" and contains a unit named "uMyTestDes.pas" in which I wrote the following code:
unit uMyTestDes;
interface
uses
Classes,
uMyTestRun;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('MyComponents', [TMyTest]);
end;
end.
Output directories of both packages are in Library paths (Inside there are bpl, dcp and dcu).
Trying to install PackageDes.bpl (Component, Install Packages..., Add...), I'm getting the following error:
Can't load package C:\<...>\PackageDes.bpl. Impossibile trovare il
modulo specificato.
The last part of the message is in my OS's language, in english it should be something like "Can't find specified module". (My OS is Windows 10 Pro 64bit).
PackageDes.bpl is exactly in the same path shown in the error message (C:\<...>\PackageDes.bpl).
After some tests, I found that the error disappear by removing the following line from uMyTestDes.pas unit:
RegisterComponents('MyComponents', [TMyTest]);
Is there something wrong in my code/projects/environment?
Run Process Monitor from http://SysInternals.com and set the filters to intercept only file operations ( toolbar rightmost buttons ) of your Delphi IDE process (check the process name in TaskManager or shortcut properties (it is bds.exe for Delphi XE2), then add the filter similar to Include / Process Name / Ends With / bds.exe ).
Then clear the log in PM, switch to Delphi and try to load the package, then as soon as error pops up switch back to PM and stop capturing events. Try to do it fast as you can, for example do not waste your time closing error box.
Now you would get a trace of file I/O activity of Delphi loading the package of yours (and some other background activity noise - the faster you do the less noise there'd be). In that trace look for all the errors and see where and which package Delphi tries to find.
You can also try Microsoft Dependency Walker or similar tools to se if your Design-Time BPL has all the DLL-dependency tree resolvable. Personally I usually use Unreal/Total commander with FileInfo plugin or ntCore CFF Explorer.
Easy way to solve this issue is to add a post build action to your run time project:
copy "$(OUTPUTDIR)\$(OUTPUTFILENAME)" "$(BDSCOMMONDIR)\Bpl"
The command above copies your run time file to the default IDE Bpl location.
I had a similar issue. In my case I had the same library name in a different Delphi version BPL path. I found out the solution for my issue looking at the comments above, so this is only a reminder for basic things to check:
BPL path have to be included in your OS path variable;
Search for a BPL module with the same name in other OS path before the right one (mutiple Delphi version installations).
Try to change the register procedure to uMyTestRun unit.
unit UMyTestRun;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;
type
TMyTest = class(TFrame)
private
{ Private declarations }
public
{ Public declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('MyComponents', [TMyTest]);
end;
end.
Now, the package will install correctly.
Regards.

Lockbox 3 for Android with XE7 not working

I just found that lockbox 3.6.0 should support Android. However when i look in my palette i see that the codec only supports win32 and win64.
How can i make it work for my android apps also?
Im using Delphi XE7 and have already followed the installation instructions supplied in the package. For a windows app it works just fine.
You have two options:
(1) Run-time
You can always create the components at run-time. There is an example on the website on how to do it, and I copy a fragment of this example below. Just replace the ShowMessage() functions with whatever is appropriate ...
procedure EncryptAStream( Plaintext, Ciphertext: TStream);
var
Codec1: TCodec;
CryptographicLibrary1: TCryptographicLibrary;
begin
ShowMessage( 'Demonstration of How to Encrypt a Stream with TurboPower LockBox 3.');
Codec1 := TCodec.Create( nil);
CryptographicLibrary1 := TCryptographicLibrary.Create( nil);
Codec1.CryptoLibrary := CryptographicLibrary1;
Codec1.StreamCipherId := uTPLb_Constants.BlockCipher_ProgId;
Codec1.BlockCipherId := 'native.AES-256';
Codec1.ChainModeId := uTPLb_Constants.CBC_ProgId;
Codec1.Password := 'my utf-16le password';
// Codec1.Reset; Reset if you are continuing from a previous encryption operation.
Codec1.EncryptStream( Plaintext, Ciphertext);
// Codec1.Burn; Burn if you need to purge memory of sensitive data.
Ciphertext.Position := 0;
ShowMessageFmt(
'The ciphertext for AES-256 with CBC chaining'#13#10 +
' of plaintext ''banana'' (UTF-8 encoding),'#13#10 +
' and password ''my utf-16le password'' (UTF-16LE encoding),'#13#10 +
' prepended by 64 bit nonce, (being the IV),'#13#10 +
' and rendered for display in base64 is ...'#13#10 +
'%s', [Stream_to_Base64( Ciphertext)]);
Codec1.Free;
CryptographicLibrary1.Free;
end;
(2) Design-time
A little bit of tweaking is required to get the components onto the palette for Android. This will be done for you in the next version of TPLockbox 3 to be released, but for now, here is the procedure ...
Remove vcl, vclimg and dbrtl from the TPLB3 run-time requirements.
For the run-time package, add the Android target platform, and make it the active one. But of course, don't add this platform to the design-time package.
The binary product for the run-time should be named libTP_LockBox3_XE7.so, where XE7 is a place-marker for your compiler version.
Preface the declarations for the two components (TCodec and TCryptographicLibrary) with
[ComponentPlatformsAttribute( pidWin32 or pidWin64 or pidOSX32 or pidiOSSimulator or pidiOSDevice or pidAndroid)]
TCodec = class( TTPLb_BaseNonVisualComponent, ICryptographicLibraryWatcher,
{ etc. }
This is the key to the whole thing. The ComponentPlatformsAttribute attribute declares what platforms should the component be displayed for, on the palette. If not declared, I believe that the default is pidWin32 or pidWin64, but I cannot point to any official documentation to support this.
Recompile the run-time package. Remember that if your are compiling with MS-BUILD, on certain compiler versions, you need to save-all before you can successfully compile.
Go to the IDE Tools | Options and open the Library Path for the Android platform. Make sure that this path include the location of where you put the dcu files for the Android case. For example, on my installation it is ...
C:\Dev\TPLB\work-products\ephemeral\dcu\XE6\Android
You should physically check this directory. It should have a file named TPLB3.AES.dcu and another named TPLB3.AES.so for example.
Recompile and re-install the design-time package
Open your mobile project. Slap design-time components for TCodec and TCryptographicLibrary on your Android forms. Proceed as you would for a windows application.

Control panel Win7 applets

In DelphiXe I create through the master of projects the new applet of the Control panel, I change an icon, the name, etc.
To activation reactions I write Showmessage (' Test '); Compile, receive dll, rename in *.cpl. In a win.explorer at start of this file the message appears.
In WinXp I insert this file in c:\windows\system32, open Control panel Windows, I see the applet and at its start the test message stands out.
I make too most on Win7x64 (or on 2008r2), but in the control panel of the applet I do not observe, reboot of a problem does not solve.
Tried to duplicate a file in c:\windows\syswow64, too there is no result.
How to force the applet will appear in the panel under Win7?
Code:
library Project1;
uses
CtlPanel,
AppletModule1 in 'AppletModule1.pas' {AppletModule1AppletModule: TAppletModule};
exports CPlApplet;
{$R *.RES}
{$E cpl}
begin
Application.Initialize;
Application.CreateForm(TAppletModule1AppletModule, AppletModule1AppletModule);
Application.Run;
end.
////////////// and Unit module
unit AppletModule1;
interface
uses
Windows, Messages, SysUtils, Classes, CtlPanel, Dialogs;
type
TAppletModule1AppletModule = class(TAppletModule)
procedure AppletModuleActivate(Sender: TObject; Data: Integer);
private
{ private declarations }
protected
{ protected declarations }
public
{ public declarations }
end;
var
AppletModule1AppletModule: TAppletModule1AppletModule;
implementation
{$R *.DFM}
procedure TAppletModule1AppletModule.AppletModuleActivate(Sender: TObject;
Data: Integer);
begin
Showmessage('Test');
end;
end.
On XP, you can drop the .cpl file into the system folder and be done with it:
How to Register DLL Control Panel Items
As of Windows XP, new Control Panel item DLLs should be installed in the associated application's folder under the Program Files folder. Items that are stored in the System32 directory with a .cpl extension do not need to be registered; they are automatically shown in the Control Panel. All other Control Panel items that use CPlApplet must be registered in one of two ways:
If the Control Panel item is to be available to all users, register the path on a per-computer basis by adding a REG_EXPAND_SZ value to the HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Control Panel\Cpls subkey, set to the DLL path.
If the Control Panel item is to be available on a per-user basis, use HKEY_CURRENT_USER as the root key instead of HKEY_LOCAL_MACHINE.
However, on Vista and later, your .cpl applet needs to be registered in the Registry. Dropping it in the system folder may not be enough.
Developing for the Control Panel
Types of Control Panel Applets
There are three types of Control Panel applets:
Command objects—applets that run commands specified in the registry
Shell folders—applets open up in the Control Panel. Examples of shell folder applets are the Fonts Folder, Administrative Tools, Personalization, System, User Accounts, and Programs
CPLs—applets that implement the CplApplet function
Command objects are the easiest to implement.
Adding and Registering Your Own Applets and Tasks
Adding your own applet to Control Panel is easier in Windows Vista. Software developers can now easily add their own applets and tasks to Control Panel.
In previous versions of Windows, you add applets to the Control Panel by using the Windows Registry and the CplApplet function. The operating system uses the Registry to enumerate the modules containing the applets. Each module's CplApplet function is called to display the applet, its icon and description, and then invoke the applet. This process is more complicated than using command objects because the applet must implement the CplApplet Interface. Although this process is still supported in Windows Vista, using command objects is encouraged since it is easier to implement.
Now, in Windows Vista, you can just write an executable (.exe), register it as a command object and the applet appears in Control Panel. For example, you can write an executable, MySystemApplet.exe, for your applet and add the applet to Control Panel by simply registering MySystemApplet.exe as a shell command object instead of tediously modifying the binary with an implementation of the CplApplet interface.

ActiveX controls with old Delphi versions

I'm testing a non visual ActiveX control based on a registered .ocx
which I import into Delphi using the provided wizard.
Then, I simply put the generated component on the main form of a new VCL application.
Under old Delphi versions (D5 and D2007), when i launch the application, this raise an AV
during the component initialization.
with Delphi 2009 : no problem, the application starts smoothly.
My questions are :
Are there known enhancements of ActiveX management in recent Delphi versions which
can explain this difference ?
Can I suspect a bug in the ActiveX control, or can I consider the origin of the
problem is from old Delphi versions ?
I need to use this component (if tests OK) in D2007.
Do you think that it is possible to correct the AV problem under D2007 by modifying the D2007 generated .tlb file (for example by trying to use the D2009 generated one)
PS: the ActiveX control is not named, because my question is a general question about Delphi and ActiveX, not about a specific ActiveX control.
Edit :
With D2007, the error (an Access Violation) appears during Application.CreateForm(TForm1, Form1);
and more specifically when the Olecontrol is created :
procedure TOleControl.CreateInstance;
var
ClassFactory2: IClassFactory2;
LicKeyStr: WideString;
procedure LicenseCheck(Status: HResult; const Ident: string);
begin
if Status = CLASS_E_NOTLICENSED then
raise EOleError.CreateFmt(Ident, [ClassName]);
OleCheck(Status);
end;
begin
if not (csDesigning in ComponentState) and
(FControlData^.LicenseKey <> nil) then
begin
// ON THE LINE BELOW : the call of CoGetClassObject raise an AV
OleCheck(CoGetClassObject(FControlData^.ClassID, CLSCTX_INPROC_SERVER or
CLSCTX_LOCAL_SERVER, nil, IClassFactory2, ClassFactory2));
LicKeyStr := PWideChar(FControlData^.LicenseKey);
LicenseCheck(ClassFactory2.CreateInstanceLic(nil, nil, IOleObject,
LicKeyStr, FOleObject), SInvalidLicense);
end else
LicenseCheck(CoCreateInstance(FControlData^.ClassID, nil,
CLSCTX_INPROC_SERVER or CLSCTX_LOCAL_SERVER, IOleObject,
FOleObject), SNotLicensed);
end;
As far as I remember there were major enhancements to the ActiveX/TLB import in Delphi 2009 (related to Unicode support) - that might explain it.
In my personal experience Delphi 7 and Delphi 2007 repeatedly failed to import some Windows 7 type libraries (various new interfaces to work with new taskbar), but Delphi 2009 managed that without any problems at all.
As for using Delphi 2009 generated file in earlier versions - beware of Unicode issues. Plus it won't help if the defect is in RTL... Try to make a wrapper ActiveX in Delphi 2009 and use it in Delphi 2007 - that should work.
Sorry to barge in so late after the battle (5 years later as a matter of fact), but I wasted so much time on this precise issue that I thought I should share what I've seen and what I've done to solve it :
2 machines (win7 64 / win 8.1) same delphi 7 (same version same build), same activeX (MapX to name it) with identical .lic files containing the key made of 59 characters :
uQnZi2sFw22L0-MRa8pYX-1E2P8065-5N5M3459-3C934220-04969-6562
same import producing 2 slightly different TLB.
The one working : (on win 8.1) contains this in procedure TMap.InitControlData :
const
CLicenseKey: array[0..61] of Word = ( $0075, $0051, $006E, $005A, $0069, $0032, $0073, $0046, $0077, $0032, $0032
, $004C, $0030, $002D, $004D, $0052, $0061, $0038, $0070, $0059, $0058
, $002D, $0031, $0045, $0032, $0050, $0038, $0030, $0036, $0035, $002D
, $0035, $004E, $0035, $004D, $0033, $0034, $0035, $0039, $002D, $0033
, $0043, $0039, $0033, $0034, $0032, $0032, $0050, $0030, $002D, $004D
, $0030, $0034, $0039, $0036, $0039, $002D, $0036, $0035, $0036, $0032
, $0000);
which translates to a 61 char key
uQnZi2sFw22L0-MRa8pYX-1E2P8065-5N5M3459-3C93422P0-M04969-6562
The TLB that does not work (win 7 64) contains this instead:
const
CLicenseKey: array[0..2] of Word = ( $0050, $004D, $0000);
which translates to a 2 char key
PM
Replacing one const with the other and recompiling the component solved my issue. I don't really know what happened. I just know the Import/TLB produced a bad .pas file that can be corrected manually.

Resources