Fix port enumeration.

This commit is contained in:
Mike McCormack 2004-10-18 19:38:57 +00:00 committed by Alexandre Julliard
parent 6e8f4f3c69
commit d71bc33c11

View File

@ -3010,6 +3010,7 @@ static BOOL WINSPOOL_ComPortExists( LPCSTR name )
NULL, OPEN_EXISTING, 0, NULL ); NULL, OPEN_EXISTING, 0, NULL );
if (handle == INVALID_HANDLE_VALUE) if (handle == INVALID_HANDLE_VALUE)
return FALSE; return FALSE;
TRACE("Checking %s exists\n", name );
CloseHandle( handle ); CloseHandle( handle );
return TRUE; return TRUE;
} }
@ -3040,6 +3041,7 @@ BOOL WINAPI EnumPortsA(LPSTR name,DWORD level,LPBYTE buffer,DWORD bufsize,
DWORD info_size, ofs, i, printer_count, serial_count, count, n, r; DWORD info_size, ofs, i, printer_count, serial_count, count, n, r;
const LPCSTR szPrinterPortKey = "Software\\Wine\\Wine\\Config\\spooler"; const LPCSTR szPrinterPortKey = "Software\\Wine\\Wine\\Config\\spooler";
HKEY hkey_printer; HKEY hkey_printer;
BOOL retval = TRUE;
TRACE("(%s,%ld,%p,%ld,%p,%p)\n", TRACE("(%s,%ld,%p,%ld,%p,%p)\n",
name,level,buffer,bufsize,bufneeded,bufreturned); name,level,buffer,bufsize,bufneeded,bufreturned);
@ -3088,6 +3090,8 @@ BOOL WINAPI EnumPortsA(LPSTR name,DWORD level,LPBYTE buffer,DWORD bufsize,
portname[3] = '1' + i; portname[3] = '1' + i;
if (!WINSPOOL_ComPortExists( portname )) if (!WINSPOOL_ComPortExists( portname ))
continue; continue;
TRACE("Found %s\n", portname );
vallen = strlen( portname ); vallen = strlen( portname );
} }
else else
@ -3125,11 +3129,13 @@ BOOL WINAPI EnumPortsA(LPSTR name,DWORD level,LPBYTE buffer,DWORD bufsize,
/* add the name of the port if we can fit it */ /* add the name of the port if we can fit it */
if ( ofs < bufsize ) if ( ofs < bufsize )
lstrcpynA(&buffer[ofs],portname,bufsize - ofs); lstrcpynA(&buffer[ofs],portname,bufsize - ofs);
}
ofs += lstrlenA(portname)+1;
n++; n++;
} }
else
retval = FALSE;
ofs += lstrlenA(portname)+1;
}
RegCloseKey(hkey_printer); RegCloseKey(hkey_printer);
@ -3137,9 +3143,9 @@ BOOL WINAPI EnumPortsA(LPSTR name,DWORD level,LPBYTE buffer,DWORD bufsize,
*bufneeded = ofs; *bufneeded = ofs;
if(bufreturned) if(bufreturned)
*bufreturned = count; *bufreturned = n;
return TRUE; return retval;
} }