Click to See Complete Forum and Search --> : Default Printer Driver Info.
jVC++
May 30th, 2002, 10:06 AM
I need to fetch default printer driver information like
device name and driver name and it has to work in
all the Windows Env. WIN 95/98/ME/NT/2K/XP....
I need to create a DLL for the above task....
Any comments or help with some sample code please..
Thanks for your time..
pm_sarjoon
May 31st, 2002, 01:34 AM
use
char *retStr=new char[255];
::GetProfileString("windows","device","",returnString,255);
Hope this will solve your problem
Regards,
PMS
jVC++
June 3rd, 2002, 03:05 AM
Hey PMS , thanks for that prompt post...
That really worked fine......
However , on WIN NT machine it is returning empty Value....
I read that it picks up from win.ini File and since the mentioned
section and key name were absent in my win.ini file on WIN NT
machine it is displaying Emty String....
Would you be able to give me any further inputs on this , Pls ...
Also , I would need to find , if the Printer status is ready ....
would appreciate your help on this issue too , if I am not demanding too much......
pm_sarjoon
June 3rd, 2002, 11:58 PM
Ok no probs.Try the below method.Hope this will solve.
char *GetPrinterName()
{
DWORD dwValues;
DWORD idw;
LONG lReturn;
HKEY hQKey = NULL;
TCHAR szStr[200];
DWORD dwValueNameLen,dwValueLength;
DWORD dwType;
BOOL Ok;
unsigned char *szValue=new unsigned char[255];
char *szErrorValue=new char[255];
strcpy(szErrorValue,"No printers");
lReturn = RegOpenKeyEx (HKEY_CURRENT_USER,"Printers",0L,KEY_ALL_ACCESS, &hQKey);
Ok = (lReturn == ERROR_SUCCESS);
if (Ok)
{
lReturn = RegQueryInfoKey( hQKey, NULL, NULL, NULL
, NULL, NULL, NULL, &dwValues, NULL, NULL, NULL, NULL );
Ok = (lReturn == ERROR_SUCCESS);
}
if(Ok)
{
for ( idw=0; ((idw<dwValues) && Ok); idw++) {
dwValueNameLen = 200;
dwValueLength=255;
lReturn = RegEnumValue(
hQKey
, idw
, szStr
, &dwValueNameLen
, NULL
, &dwType
, szValue
, &dwValueLength
);
if(strcmp(szStr,"DeviceOld")==0)
{
for(unsigned int index=0;index < strlen((char *)szValue);index++)
{
if(szValue[index]==',')
{
szValue[index]='\0';
break;
}
}
return (char *)szValue;
}
}
}
if (hQKey != NULL)
{
RegCloseKey (hQKey);
hQKey = NULL;
}
return szErrorValue;
}
You can get the status of the printer from PRINTER_INFO_2 and
JOB_INFO_2 structures.... Any further queries you can feel free to ask.
Regards,
PMS
jVC++
June 5th, 2002, 08:00 AM
Hi PMS ,
Full Marks... That's Perfect... It is really working fine now.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.