简体   繁体   中英

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....

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM