Great stuff, corrupt
Until Chris made the following comment in a different thread, ...
By the way, if you have the DLL copy its result into a string provided by the caller, you can avoid the need for LoadLibrary(), FreeLibrary() and lstrcpy().
... the fact that DllCall makes it possible for a DLL to modify the contents of an AHK variable had somehow eluded me (despite the fact that it's clearly stated in the docs! :oops:). Once it finally hit me yesterday, I realized I am now be in a position to actually contribute code to this community (remember I'm the C/Assembler guy who can't do C++), so until your latest release, I had starting planning something along the lines of
@ := "str" ; For readability
ExitCode := DllCall("AHKEx\RunWaitEx", @, "executable", @, "parameters", @, "workingdir", @, InVar, @, OutVar, @, ErrVar, "int")
for quietly launching console programs with fully redirected I/O (unlike AHK's RunWait, I was thinking of separating the executable from its parameters in order to avoid having to reproduce AHK's no-doubt complicated parsing rules for figuring out where one ends and the other begins). InVar above could be replaced by an explicit string, but OutVar and ErrVar would be appropriately sized variables. The programmer would initially assume the risk of insufficiently sized output variables, unless I can come up with a simple way to pass the current size of a variable to the call without burdening the syntax with additional parameters, like maybe making the initial contents of a variable reflect its size?
OutVar = 10240
(Hmm, I wonder whether I can talk Chris into a VarSetCapacity
option to place the variable's new size as a DWORD in its first 4 bytes? :wink: Would save the conversion work...)
In any case, now that you've made such progress with CmdRet, I'd like to put the question whether I should proceed (when time allows) or whether you might be planning a similar more complete implementation of your new RunReturn
call? [BTW, may I ask in what language you wrote CmdRet.dll? I was surprised by its tiny size, almost Assembler-like!)
Again, congratulations on a job well done!