mpr: Small fixes to WNetGetConnection.

Convert unc\server\share to \\server\share and be more tolerant to null
pointers if only length is requested.
This commit is contained in:
Maarten Lankhorst 2007-05-22 21:33:17 +02:00 committed by Alexandre Julliard
parent 41b099172f
commit c3bfe66ade

View File

@ -3,6 +3,7 @@
*
* Copyright 1999 Ulrich Weigand
* Copyright 2004 Juan Lang
* Copyright 2007 Maarten Lankhorst
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -1526,10 +1527,10 @@ DWORD WINAPI WNetGetConnectionA( LPCSTR lpLocalName,
if (!lpLocalName)
ret = WN_BAD_POINTER;
else if (!lpRemoteName)
ret = WN_BAD_POINTER;
else if (!lpBufferSize)
ret = WN_BAD_POINTER;
else if (!lpRemoteName && *lpBufferSize)
ret = WN_BAD_POINTER;
else
{
int len = MultiByteToWideChar(CP_ACP, 0, lpLocalName, -1, NULL, 0);
@ -1622,10 +1623,10 @@ DWORD WINAPI WNetGetConnectionW( LPCWSTR lpLocalName,
if (!lpLocalName)
ret = WN_BAD_POINTER;
else if (!lpRemoteName)
ret = WN_BAD_POINTER;
else if (!lpBufferSize)
ret = WN_BAD_POINTER;
else if (!lpRemoteName && *lpBufferSize)
ret = WN_BAD_POINTER;
else if (!lpLocalName[0])
ret = WN_BAD_LOCALNAME;
else
@ -1636,8 +1637,17 @@ DWORD WINAPI WNetGetConnectionW( LPCWSTR lpLocalName,
{
case DRIVE_REMOTE:
{
WCHAR remote[MAX_PATH];
static const WCHAR unc[] = { 'u','n','c','\\' };
WCHAR rremote[MAX_PATH], *remote = rremote;
if (!QueryDosDeviceW( lpLocalName, remote, MAX_PATH )) remote[0] = 0;
else if (!strncmpW(remote, unc, 4))
{
remote += 2;
remote[0] = '\\';
}
else if (remote[0] != '\\' || remote[1] != '\\')
FIXME("Don't know how to convert %s to an unc\n", debugstr_w(remote));
if (strlenW(remote) + 1 > *lpBufferSize)
{
*lpBufferSize = strlenW(remote) + 1;