CreateOleObject in a 64-bit Delphi program?

In VCL program, Delphi XE7 64-bit cannot find Vcl.OleAuto device:

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

Although 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?

+5
source share
1 answer

Although source code for Vcl.OleAuto is still provided, the 64-bit lib directory does not include Vcl.OleAuto.dcu . Instead, you should use System.Win.ComObj and / or System.Win.ComServ . Note that the source for Vcl.OleAuto indicates that this item is deprecated and tells you what to use instead.

If we look at the source for Vcl.OleAuto , we can find the 32-bit asm code that has not been ported. Presumably, Embarcadero decided not to transfer this to 64 bits, because the device is outdated.

+10
source

Source: https://habr.com/ru/post/1213811/


All Articles