Opened 7 years ago
Closed 6 years ago
#3726 closed Bug (Works For Me)
_WinAPI_PathGetArgs / _WinAPI_PathRemoveArgs -- using like the help example can lead to errors
| Reported by: | BugFix | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | Standard UDFs | |
| Version: | 3.3.14.0 | Severity: | None |
| Keywords: | _WinAPI_PathGetArgs, _WinAPI_PathRemoveArgs | Cc: |
Description
The help example for the _WinAPI_PathGetArgs and _WinAPI_PathRemoveArgs functions uses the _WinAPI_AssocQueryString function as the source for the command line.
However, this can lead to errors if the path of the executable is not enclosed in string delimiters. The Remarks specifically mention not to use such features ("This function should not be used on generic command path templates (from users or the registry)").
But in the example the function _WinAPI_AssocQueryString is used, which accesses the registry.
The following can happen:
#include <WinAPIShPath.au3>
#include <APIRegConstants.au3>
#include <WinAPIReg.au3>
Local $sCmd = _WinAPI_AssocQueryString('.profile', $ASSOCSTR_COMMAND)
ConsoleWrite('$sCmd: ' & $sCmd & @CRLF) ; TRUE --> C:\Program Files\Intel\bin\iWrap.exe /CMD:7 %1
Local $sPath = _WinAPI_PathRemoveArgs($sCmd)
ConsoleWrite("$sPath: " & $sPath & @LF) ; FALSE --> C:\Program
Local $sArgs = _WinAPI_PathGetArgs($sCmd)
ConsoleWrite("$sArgs: " & $sArgs & @LF) ; FALSE --> Files\Intel\bin\iWrap.exe /CMD:7 %1
I would recommend using a defined path for the help example, instead of _WinAPI_AssocQueryString.
Local $sCmd = '"C:\Program Files\Intel\bin\iWrap.exe" /CMD:7 %1'
Attachments (0)
Change History (8)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
".profile" was just one example. This is common to all programs that create dirty registry entries. For example, the entry for ".gadget" is also incorrect.
I just wanted to point out that a function that reads from the registry, can also bring erroneous values and therefore should not be used for a help example.
comment:3 by , 7 years ago
Are you sayning that ".au3" is not a well formatted.
the examples for all Udf referenced in the examples are correct so what do you want to be improved?
comment:4 by , 7 years ago
the examples for all Udf referenced in the examples are correct so what do you want to be improved?
That's what they are in the particular case used. But help examples should be universal, or am I wrong?
I've made a script in the same manner like the help example. And this gots wrong results.
Therefore, I wanted to point out that help examples should be designed so that they can not provide any mistakes.
comment:6 by , 7 years ago
Replying to Jpm:
So what do you suggest as the examples are correct?
As i wrote in my start post:
I would recommend using a defined path for the help example, instead of _WinAPI_AssocQueryString.
We could e.g. use these:
AutoIt3.exe myScript.au3 param1 param2 param3
And, of course, the indication that paths that contain spaces must be encapsulated in quotes.
comment:7 by , 6 years ago
| Component: | AutoIt → Standard UDFs |
|---|
comment:8 by , 6 years ago
| Resolution: | → Works For Me |
|---|---|
| Status: | new → closed |
as the examples are working I close this ticket

I Don't know how your .profile have been created but for me is a program installer update the registry correctly it must include the path to .exe in quote
so for me there is no error
In my system the .profile is not created. You can try .xls to verify