Modify

Opened 13 months ago

Closed 3 months 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 Changed 13 months ago by Jpm

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

comment:2 Changed 13 months ago by BugFix

".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 Changed 13 months ago by Jpm

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 Changed 13 months ago by BugFix

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:5 follow-up: Changed 13 months ago by Jpm

So what do you suggest as the examples are correct?

comment:6 in reply to: ↑ 5 Changed 13 months ago by BugFix

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 Changed 3 months ago by Jon

  • Component changed from AutoIt to Standard UDFs

comment:8 Changed 3 months ago by Jpm

  • Resolution set to Works For Me
  • Status changed from new to closed

as the examples are working I close this ticket

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.