StungStang Posted May 7, 2012 Share Posted May 7, 2012 Hi to all i'm trying to made this function: PathRemoveArgs in autoit, but this not work (it surely my fault). Here is my code:#include <Array.au3> $Path = '"C:\program files\TEST.exe" -nogui' $d_call = DllCall("shlwapi.dll", "int", "PathRemoveArgs", "wstr", $Path) If Not @error Then _ArrayDisplay($d_call) EndIfThat will always return the same path, but i want to know only the real path whitout it's arguments. How i can fix that?Hi! Link to comment Share on other sites More sharing options...
Yashied Posted May 7, 2012 Share Posted May 7, 2012 (edited) Look at EDIT:Use PathRemoveArgsW for Unicode string - "wstr", and PathRemoveArgs or PathRemoveArgsA for ANSI string - "str". Edited May 7, 2012 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
StungStang Posted May 7, 2012 Author Share Posted May 7, 2012 (edited) Thanks Yashied thanks a lot, but i've seen this: "This function should not be used on generic command path templates (from users or the registry)". I'm currently reading from the values from startup key: (HKEY_CURRENT_USERSOFTWAREMicrosoftWindowsCurrentVersionRun"), then i read the file path and check if the .exe exists. Do you suggest me to use this function or what? Hi and thank you so much. Edited May 8, 2012 by StungStang Link to comment Share on other sites More sharing options...
JohnOne Posted May 7, 2012 Share Posted May 7, 2012 Well it works just fine. #include <WinAPIEx.au3> $Path = '"C:\program files\TEST.exe" -nogui' $rtn = _WinAPI_PathRemoveArgs($Path) If Not @error Then ConsoleWrite($rtn & @LF) EndIf Exit AutoIt Absolute Beginners  Require a serial  Pause Script  Video Tutorials by Morthawt  ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
StungStang Posted May 8, 2012 Author Share Posted May 8, 2012 Yes this surely work fine but the dubt is about that:"This function should not be used on generic command path templates (from users or the registry)"As i said before I'm currently reading the values from startup key: (HKEY_CURRENT_USERSOFTWAREMicrosoftWindowsCurrentVersionRun"), then i read the file path and check if the .exe exists.If this function should not should not be used on the registry, there is a good alternative?Hi! Link to comment Share on other sites More sharing options...
Andreik Posted May 8, 2012 Share Posted May 8, 2012 $sPath = '"C:program filesTEST.exe" -nogui' MsgBox(0,"",PathRemoveArgs($sPath)) Func PathRemoveArgs($sPath) Local $aRet = DllCall("shlwapi.dll","none","PathRemoveArgs","str",$sPath) If @error Then SetError(1,0,False) Else Return $aRet[1] EndIf EndFunc When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Yashied Posted May 8, 2012 Share Posted May 8, 2012 (edited) Yes this surely work fine but the dubt is about that...Do not care. Just a function does not return an error. Edited May 8, 2012 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
StungStang Posted May 8, 2012 Author Share Posted May 8, 2012 Ok thanks to all, problem solved Hi! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now