On Fri, 11 Dec 2009, [email protected] wrote:

Hi,

>     ; TOFIX: CreateProcessW() second parameter has to be a read/write 
>              buffer. Przemek, do you have an idea how to solve that 
>              the cleanest way?
>              (for now I kept a cast, assuming that a buffer is 
>              created by Harbour conversion API, but that's not 
>              something it guarantees in the future.)

As general solution I'll add:
   HB_WCHAR * hb_wstrdup( const HB_WCHAR * );
and make hb_wstrlen() public.

But for more tuned usage I'll also add:
   HB_WCHAR * hb_wstrUnShare( void ** hStr,
                              const HB_WCHAR * pStr, ULONG ulLen );
and:
   char * hb_strUnShare( void ** hStr, const char * pStr, ULONG ulLen );
which can be used to convert (only if necessary) the buffer to writable
state so you can use it in WIN_RUNDETACHED() in this way:
   ULONG ulLen;
   LPCTSTR lpCommandRO = HB_PARSTR( 2, &hCommandLine, &ulLen );
   LPTSTR lpCommand = HB_STRUNSHARE( &hCommandLine, lpCommandRO, ulLen );

It's the cleanest version but if you trust MS that in non unicode version
CreateProcessA() never change the buffer then you can make:
   ULONG ulLen;
   LPCTSTR lpCommandRO = HB_PARSTR( 2, &hCommandLine, &ulLen );
#if defined( UNICODE )
   LPWSTR lpCommand = hb_wstrUnShare( &hCommandLine, lpCommandRO, ulLen );
#else
   LPSTR lpCommand = ( LPSTR ) lpCommandRO;
#endif

best regards,
Przemek
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to