EnumPrinters problem

I use EnumPrinters to check whether a printer is installed on local machine,
but it always return me 0 even if I specified an exisiting local installed
printer(it suppose should return me a non-zero value). Could anyone help me?
I use a string like \\servername\\printer name in specifying the
pPrinterName.

the code as follows

int CheckPrinter::IsInstalled(LPTSTR pPrinterName)
{
int ret = 0;
DWORD bytesNeeded, numEntries;
BOOL bFlag;
PRINTER_INFO_2 *pi;

bFlag = ::EnumPrinters( PRINTER_ENUM_NAME, NULL, 2, NULL, 0,
&bytesNeeded, &numEntries );

pi = ( PRINTER_INFO_2 * )::HeapAlloc( ::GetProcessHeap(), 0,
bytesNeeded );
if( pi == 0 ) return 0;

bFlag = ::EnumPrinters( PRINTER_ENUM_NAME, pPrinterName, 2, (LPBYTE)pi,
bytesNeeded, &bytesNeeded, &numEntries );

if ( bFlag ) ret = 1;

::HeapFree( ::GetProcessHeap(), 0, pi );

return ret;
}
[1017 byte] By [skifan] at [2007-11-17 11:49:14]