I once thought this was a simple exercise in cutting strings, but only now I started to comprehend how sophisticated this combina is.
OK, I have a command line string of an application (many, actually - TStrings, but I process them uno by uno). I need to strip them off their parameters and unify them (i.e. UpperCase(ExtractShortPathName()) ).
I use this function, and it is rather good, but it only works for 70 percent of the cases, the others seem to slip away. I have broken my head trying to find a common pattern to all the command line, but could not distinguish more than I already did(without actually searching for the files).
For i:=1 to Length(PossibleParams) do
if posit>0 then
//Maybe in Windows or Windows system directory and path not given?
If ExtractFilePath(Temp)='' then
if FileExists(MainForm.WinDir+Temp) then
else if FileExists(MainForm.SysDir+Temp)then
Here are some strings that slipped away(taken from my registry autorun section for sake of testing):
"C:\Program Files\Common Files\Symantec Shared\Script Blocking\SBServ.exe" -reg
Alright, as you see this func is far from perfect (the number 70 is just an estimate) so all suggestions for improvement would be welcome.