可以通过GetProfileString函数来获得默认的打印机的信息,如果获取默认打印机失败,则可认为当前计算机不存在打印机。

C++代码如下:

BOOL IsExsitPrinter()
{
TCHAR tszPrinter[
128] = {};
DWORD dByteCnt
= 0;
dByteCnt
= GetProfileString(_T("windows"), _T("device"),
NULL, tszPrinter, 128);
if (dByteCnt <= 0)
{
/*当前计算机不存在打印机*/
return FALSE;
}

/*当前计算机存在打印机*/
return TRUE;
}

其中,_T、TCHAR都是可同时适应ASNI和UNICODE编码方式。

posted on 2011-06-12 12:15  闲云鹤  阅读(360)  评论(0编辑  收藏  举报