RegSetValueEx problem?

davep davep at cyw.uklinux.net
Sat Mar 31 06:59:14 CST 2001


I've been trying to track down why WineMine does not save my best scores ;-(

On exit, WineMine saves the current user settings to the registry with code
like this:

    char data[16];

    wsprintf( data, "%d", p_board->pos.x );
    RegSetValueEx( hkey, "Xpos", 0, REG_SZ, (LPBYTE) data,  sizeof( data ));

The problem here is that the 'count' parameter passed to RegSetValueEx is not
the string length but the size of the entire buffer. Wine dutifully writes into
the registry the entire buffer including the trailing garbage, and also adds a
null to the end if there isn't one there. When WineMine tries to read the value
back it is now 17 characters long and too big to fit in the 16-byte buffer.

Compiling and running Winemine under Windows 95 this problem doesn't occur.
Win95 truncates the value at the first null.

So RegSetValueEx needs fixing. However there are already comments in there
about the differences between 95 and NT in the handling of REG_SZ values, and I
don't have an NT system to carry out checks. Can someone with experience
propose a solution?
-- 
Dave Pickles





More information about the wine-devel mailing list