#include "faxrtp.h" #pragma hdrstop BOOL IsExistingConnection( LPCTSTR RemoteName ) /*++ Routine Description: Checks to see if we are connected already. Arguments: RemoteName - UNC name of remote host Return Value: TRUE for success, FALSE on error --*/ { DWORD rc; HANDLE hEnum; DWORD Entries; NETRESOURCE *nrr = NULL; DWORD cb; DWORD i; DWORD ss; BOOL rval = FALSE; rc = WNetOpenEnum( RESOURCE_CONNECTED, RESOURCETYPE_ANY, 0, NULL, &hEnum ); if (rc != NO_ERROR) { return FALSE; } ss = 0; cb = 64 * 1024; nrr = (NETRESOURCE*) MemAlloc( cb ); if (!nrr) { WNetCloseEnum( hEnum ); SetLastError( ERROR_NOT_ENOUGH_MEMORY ); return FALSE; } ZeroMemory( nrr, cb ); while( TRUE ) { Entries = (DWORD)-1; rc = WNetEnumResource( hEnum, &Entries, nrr, &cb ); if (rc == ERROR_NO_MORE_ITEMS) { break; } else if (rc == ERROR_MORE_DATA) { cb += 16; MemFree( nrr ); nrr = (NETRESOURCE*) MemAlloc( cb ); if (!nrr) { SetLastError( ERROR_NOT_ENOUGH_MEMORY ); break; } ZeroMemory( nrr, cb ); continue; } else if (rc != NO_ERROR) { break; } for (i=0; i= MAX_PATH) { SetLastError( ERROR_BUFFER_OVERFLOW ); RVal = FALSE; } else { MakeDirectory(DestDir); RVal = CopyFile( TiffFileName, NameBuffer, TRUE ); } } exit: if (RVal) { FaxLog( FAXLOG_CATEGORY_INBOUND, FAXLOG_LEVEL_MAX, 2, MSG_FAX_SAVE_SUCCESS, TiffFileName, NameBuffer ); } else { FaxLog( FAXLOG_CATEGORY_INBOUND, FAXLOG_LEVEL_MIN, 3, MSG_FAX_SAVE_FAILED, TiffFileName, NameBuffer, GetLastErrorText(GetLastError()) ); } if (DstFName) { MemFree( DstFName ); } if (NameBuffer) { MemFree( NameBuffer ); } return RVal; }