I've been getting unexpected errors when running the app I'm developing in Windows XP (under Virtual PC from Windows 7). I'm compiling it using Visual Studio 2010 in Windows 7 64-bit Professional.
I've tracked the problem down to URLs not being created properly under XP. The following is a small test bed I put together to show this -
URL_COMPONENTS components;
memset( &components, 0, sizeof( URL_COMPONENTS ));
components.dwStructSize = sizeof( URL_COMPONENTS );
components.lpszScheme = L"http";
components.dwSchemeLength = 4;
components.lpszHostName = L"google.com";
components.dwHostNameLength = 10;
components.nScheme = INTERNET_SCHEME_HTTP;
components.nPort = 80;
DWORD len = 0;
DWORD flags = ICU_REJECT_USERPWD;
if( !WinHttpCreateUrl( &components, flags, NULL, &len )) {
WChar buf[256];
wsprintf( buf, L"Error code %08X", GetLastError( ));
MessageBox( NULL, buf, L"FAILURE", NULL );
}
I would expect it to set len to the correct size and give an error code of 0x7A to indicate ERROR_INSUFFICIENT_BUFFER. This is what happens under Windows 7. What I'm actually getting under Windows XP is an error code of 0x57 to indicate ERROR_INVALID_PARAMETER.
If I set the value of flags to be zero then it works fine on both Operating Systems. What I'm trying to work out is why ICU_REJECT_USERPWD is causing it to fail under XP.
I realise I don't need that flag to be set for this example, but this is just some test code I put together to display the issue.
Many thanks for any help with this problem (or to anyone who points out what I'm doing wrong...)