Search code examples
delphitype-conversionlazarus

delphi string to handle type casting


Is there anyway to safely convert/typecast a string inside TEdit (an actual window handle for eg. 00010C10) into a handle LONGWORD data type I presume in Delphi/Lazarus.

Recommended method here Pascal - String to LongWord is IntToStr but compiler throws following error:

Exception class EConvertError with message '00010C10' is not a valid integer value

Also tried IntToStr64 but no luck....


Solution

  • It's because by default the StrToInt expects the string to be in decimal notation. To convert an hex notation string to integer prefix it with $, ie

    intVal := StrToInt('$'+Edit1.Text);