Posted by: Remko in: JEDI Windows API Headers
If you look at the MSDN documentation of CreateProcess you might notice the following remark for the lpCommandLine parameter:
The Unicode version of this function, CreateProcessW, can modify the contents of this string. Therefore, this parameter cannot be a pointer to read-only memory (such as a const variable or a literal string). If this parameter is a constant string, the function may cause an access violation.
This means that when you move over to Unicode (Delphi 2009/2010) existing code might produce an Access Violation.
This code for example will produce an Access Violation:
To prevent these kinds of Access Violation we could change the declaration of the lpCommandLine parameter as var. This prevents passing nil though (which is allowed).
So if we want to allow passing nil but not a constant we should declare 2 overloaded functions:
I choose PByte in the second declaration because it allows for nil but disallows PChar(‘notepad.exe’) which will also AV.
So what do you think? Should we change this in Jwa?