Wikia

Delphi Programming

Alternatives to Deprecated Methods

2,918pages on
this wiki
Talk2

In recent versions of Delphi, you can use the deprecated directive to flag obsolete methods which should not be used anymore. This allows code which calls them to compile, but the compiler will emit a warning. For example, look at the following declaration from SysUtils:

procedure RaiseLastWin32Error; deprecated; // use RaiseLastOSError
If you call this method in your code, the compiler will emit a warning like this:
[Warning] Unit1.pas[28]: Symbol 'RaiseLastWin32Error' is deprecated
We can see from the comment in SysUtils that RaiseLastOSError is the intended replacement. But not all deprecated methods have such comments, so the list below is intended to help find good replacements.

Methods Deprecated in Delphi for .NETEdit

AnsiStartsText
For the WideString overload, use System.String.StartsWith()

Methods Deprecated due to Platform CompatibilityEdit

RaiseLastWin32Error
Use RaiseLastOSError
IncludeTrailingBackslash/ExcludeTrailingBackslash
Use IncludeTrailingPathDelimiter/ExcludeTrailingPathDelimiter

List of Deprecated elements in Delphi 2005Edit

ActnMenus UnitEdit

TCustomActionMenuBar.GetDefaultSounds;

var
   MenuItemControlClass: TMenuItemControlClass deprecated;
   MenuAddRemoveItemClass: TAddRemoveItemClass deprecated;
   MenuButtonControlClass: TMenuButtonControlClass deprecated;
   MenuPopupClass: TCustomPopupClass deprecated;
   MenuCustomizePopupClass: TCustomizeActionToolBarClass deprecated;

ComCtrls UnitEdit

CheckToolMenuDropdown
Use TToolButton.CheckMenuDropDown

Forms UnitEdit

MakeObjectInstance
Use Classes.pas version instead.
FreeObjectInstance
Use Classes.pas version instead.
AllocateHWnd
Use Classes.pas version instead.
DeallocateHWnd

Obsolete (in Forms.pas)Edit

  • Subclass3DWnd
  • Subclass3DDlg
  • SetAutoSubClass
  • DoneCtl3D
  • InitCtl3D

StdActnMenus UnitEdit

  • RegisterStandardMenus

Deprecated UnitsEdit

  • OleAuto.pas // replacing with ComObj.pas works in at least part of the cases
  • Outline.pas

List of Deprecated elements in Delphi 7Edit

Classes UnitEdit

  • TCollection.Added
  • TCollection.Deleting
Overwrite TCollection.Notify instead

RTLConsts UnitEdit

Resource StringsEdit

SConvUnknownDescription
No longer used
SInvalidDate
Moved to SysConst unit
SInvalidDateTime
Moved to SysConst unit
SInvalidInteger
Moved to SysConst unit
SInvalidTime
Moved to SysConst unit
STimeEncodeError
Moved to SysConst unit

SysConst UnitEdit

Resource StringsEdit

SVarNotArray
Use SVarInvalid instead
SWin32Error
Use SOSError
SUnkWin32Error
Use SUnkOSError
SVarTypeUnknown
Not used anymore
SVarTypeOutOfRange
Not used anymore
SVarTypeAlreadyUsed
Not used anymore
SVarTypeNotUsable
Not used anymore
SInvalidVarOpWithHResult
Not used anymore

System Unit (Default)Edit

ConstEdit

vmtAfterConstruction
Use VMTOFFSET in asm code instead
RaiseList
Use AcquireExceptionObject instead
SetRaiseList
Use AcquireExceptionObject instead
HPrevInst
Cannot be tested for multiple instances in Win32
UnicodeToUtf8
Use overloaded alternative
Utf8ToUnicode
Use overloaded alternative
TVariantManager
See Variants unit
GetVariantManager
See Variants unit
SetVariantManager
See Variants unit
IsVariantManagerSet
See Variants unit

Don't use:

  • vmtSafeCallException
  • vmtBeforeDestruction
  • vmtDispatch
  • vmtDefaultHandler
  • vmtNewInstance
  • vmtFreeInstance
  • vmtDestroy
  • vmtQueryInterface
  • vmtAddRef
  • vmtRelease
  • vmtCreateObject

Unknown:

  • Mark
  • Release
  • TextStart

SysUtils UnitEdit

  • EStackOverflow
  • EWin32Error -> use EOSError (ancestor class of EWin32Error)
  • NewStr
  • DisposeStr
  • AssignStr
  • AppendStr
RaiseLastWin32Error
Use RaiseLastOSError

Around Wikia's network

Random Wiki