Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CreateOleObject in a 64-bit Delphi program?

In a Delphi XE7 64-bit VCL program, the unit Vcl.OleAutocannot be found:

[dcc64 Fatal Error] Unit1.pas(33): F1026 File not found: 'Vcl.OleAuto.dcu'

While it works without problems in a 32-bit program:

uses
  Vcl.OleAuto;
...
FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');

So how can I use CreateOleObject in a 64-bit program?

like image 864
user1580348 Avatar asked Feb 20 '15 13:02

user1580348


1 Answers

Although the source code for Vcl.OleAuto is still supplied, the 64 bit lib directory does not include Vcl.OleAuto.dcu. Instead you are expected to use System.Win.ComObj and/or System.Win.ComServ. Note that the source for Vcl.OleAuto marks that unit as being deprecated, and tells you what to use instead.

If we look through the source for Vcl.OleAuto we can find some 32 bit asm code that has not been ported. Presumably Embarcadero decided not to port this to 64 bit because the unit is deprecated.

like image 176
David Heffernan Avatar answered Oct 22 '22 17:10

David Heffernan