Joe Yoder wrote on 2011-02-18: 
> Tracy and all,
> 
> I am trying to develop some competence with API calls so I setup a
> simple bench mark and had the Performance tab on Task Manager up while
> I ran several tests.  Here is the test routine:
> 
> * Test DoAndWait performance
> * Save the start time
>   m.StTm = VAL(SYS(2))
> * Do the call - Uncomment the one being tested
>   ?DoAndWait("c:\windows\system32\notepad.exe Contents.txt", "NOR")
>   *?DoAndWait("c:\windows\system32\cmd.exe /c dir c:\ /s", "HID")
>   *?DoAndWait("c:\windows\system32\cmd.exe /c dir c:\ /s>Contents.txt",
"HID")
> 
> * report the elapsed time
>   ?ALLTRIM(STR(VAL(SYS(2)) - m.StTm)) + ' Seconds this run'
> I tried the inkey(.1) both before and after the DO EVENTS line.  I could
> not tell any difference in the CPU utilization with or without the
> inkey(.1) enabled in the code.  The directory scan run durations were
> also the same with or without the inkey(.1).
> 
> I was surprised to see that the directory redirected to a file ran in
> 5 or 6 seconds while the one going nowhere took 11 or 12 seconds.
> 
> I would be glad for an explanation of what is causing these results
> but a grateful that I can at least achieve them now.
> 
> I stumbled across the "cmd.exe /c dir"  syntax as a way to execute an
> internal command but have never found any documentation about when
> this is necessary.  Where can I find this information?
> 
> It appears that one needs to convert long filenames to the 8.3 format
> before passing them as parameters on a command line to the CreateProcess
> routine.  Is this something that applies to all API calls?
> 
> Thanks to all who helped me with this,
> 
> Joe

Joe,

>   *?DoAndWait("c:\windows\system32\cmd.exe /c dir c:\ /s", "HID")

> I was surprised to see that the directory redirected to a file ran in
> 5 or 6 seconds while the one going nowhere took 11 or 12 seconds.

Actually, the command you have printed all the results to screen, resulting
in 11ish seconds. Direct the output to NUL when you do not really need the
data. Yes, NUL not NULL because that's the old DOS carry over.

You're saying the VFP instance you ran that notepad in did not seem to take
a lot of processor time without the inkey(.1)? I just went back and grabbed
that code Grig posted. My earlier statement was based on similar code I had
written. It appears the DoEvents and the InKey(.1) result in the same
reduction in processor intense usage. My original code I had worked out did
not have either.

> I stumbled across the "cmd.exe /c dir"  syntax as a way to execute an
> internal command but have never found any documentation about when
> this is necessary.  Where can I find this information?

The functionality of the /c ends the parameters for CMD. So the command 
DoAndWait([C:\windows\System32\Cmd.exe dir /d c:\temp\temp >
C:\Temp\temp\dir.txt])
actually fails to run correctly. Place the /c before the dir and it will.

> It appears that one needs to convert long filenames to the 8.3 format
> before passing them as parameters on a command line to the CreateProcess
> routine.  Is this something that applies to all API calls?

This is how I pass long file names:
DoAndWait([C:\windows\System32\Cmd.exe /c dir c:\temp\temp > "C:\Temp\Space
in Folder\dir.txt"])

The Command Prompt uses the double quote (") as parameter delimiters. 


Tracy Pearson
PowerChurch Software




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/001101cbd2ab$a8353150$f89f93f0$@com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to