Page 1 of 1

Parse String to test the length of a string

Posted: Fri Nov 18, 2011 9:10 am
by MattWilkinson
I am using Parse String to try and work out the length of a string.

I am splitting a string at position 21
Parse String $VMS_SERIALNUM$ into Variables VMS_SERIAL_A and VMS_SERIAL_B (Split at position from start)
However if VMS_SERIALNUM is say 12 chars, VMS_SERIAL_A is 12 chars long, so I can't tell how long this string is if it is less than the requried length.

How can I detect the length of a string using this or another method?

Re: Parse String to test the length of a string

Posted: Fri Nov 18, 2011 1:07 pm
by giaviv
You can use the Call DLL Function to invoke lstrlenA in kernel32.dll.

Here is a code that does this (paste this in IA):

Code: Select all

~InstallAware Clipboard Data~
~MessageBox~
~{4C809D69-42FB-4B93-AF20-590FA8966D29}~
~$SIZE$~
~$SIZE$~
~0~
~1~
~~
~Call DLL Function~
~{FF933DFF-A468-4212-92A5-508B11D56E43}~
~kernel32.dll,lstrlenA,byte,SIZE,"allocated string buffer (MAX_PATH length)",$STRING$,$~
~mIDEFunc.dll\mEXEFunc.dll~
~Set Variable~
~{7BFF1598-E6BC-448A-B195-621CEF4BD170}~
~SIZE$MYAH$MYAH$FALSE~
~~
~Set Variable~
~{6849524D-4D5A-48F3-AAC6-C0D0A50EF6B6}~
~STRING$MYAH$MYAH$FALSE~
~InstallAware~


Re: Parse String to test the length of a string

Posted: Mon Nov 21, 2011 3:49 am
by MattWilkinson
Thanks Aviv - which operating system can this be used on? XP, Vista, 7, 2003, 2008 will work I am assuming?

Re: Parse String to test the length of a string

Posted: Mon Nov 21, 2011 8:29 am
by giaviv
This works on a minimum OS of Windows 2000.