Click here to Skip to main content
15,920,596 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CListBox Pin
Martyn Pearson29-Apr-03 21:41
Martyn Pearson29-Apr-03 21:41 
GeneralInstall Driver Pin
peterchen29-Apr-03 20:49
peterchen29-Apr-03 20:49 
GeneralStepOver Crash in VisualC++ 6 Pin
Swinefeaster29-Apr-03 20:11
Swinefeaster29-Apr-03 20:11 
GeneralRe: StepOver Crash in VisualC++ 6 Pin
Neville Franks29-Apr-03 21:01
Neville Franks29-Apr-03 21:01 
GeneralRe: StepOver Crash in VisualC++ 6 Pin
Swinefeaster30-Apr-03 6:44
Swinefeaster30-Apr-03 6:44 
GeneralRe: StepOver Crash in VisualC++ 6 Pin
Hans Ruck29-Apr-03 22:15
Hans Ruck29-Apr-03 22:15 
GeneralError in ATL HTML Control Pin
Mahesh Perumal29-Apr-03 20:10
Mahesh Perumal29-Apr-03 20:10 
GeneralUrgent :Printer Status in PRINTER_INFO_2 Pin
Jaffer Mumtaz29-Apr-03 19:40
Jaffer Mumtaz29-Apr-03 19:40 
#include "Windows.h"
#include "WinSpool.h"
#include "Winbase.h"

char* cube() {
char buff[1024];
GetProfileString("PrinterPorts",NULL,NULL,buff,sizeof(buff));
int length,j;
length=strlen(buff);
char *token;
char sep[]="|";
for (j=0;j<1024;j++)
{
if(buff[j]==NULL)
buff[j]='|';
}

token = strtok( buff,sep);
j=0;
HANDLE hPrinter=NULL;
PRINTER_INFO_2 *ppi2 = NULL;
BOOL bFlag;
unsigned long dwNeeded;
DWORD dWord;
long Status;

char *portnumber,*strName;
//DWORD dError;

while( token != NULL )
{
bFlag=OpenPrinter(token,&hPrinter,NULL);
dWord=GetLastError();
if(bFlag==1)
{
bFlag= GetPrinter(hPrinter,2,0 ,0,&dwNeeded);
ppi2 = (PRINTER_INFO_2 *)GlobalAlloc(GPTR, dwNeeded);
bFlag= GetPrinter(hPrinter,2,(LPBYTE)ppi2 ,dwNeeded,&dwNeeded);
if (bFlag==1)
{
return token;
Status=1;
Status=ppi2->Status;
portnumber=ppi2->pPortName;
strName=ppi2->pShareName;
//dError=GetLastError();
ClosePrinter(hPrinter);
exit(0);
}
}
// SetDefaultPrinter(token);
token = strtok( NULL, sep);
ClosePrinter(hPrinter);
}
token=NULL;
return token;
}

Hi can any one tell me whts wrong with the code. the status returned by PRINTER_INFO_2 is 0 every time. while the OpenPrinter and GetPrinter are returning 1 meaning successfully returning values of the printer. i dont no why everytime status is 0.
can any body help me out.
waiting for swift reply
GeneralImmediate help required !!!!!! Pin
summo29-Apr-03 19:10
summo29-Apr-03 19:10 
GeneralRe: Immediate help required !!!!!! Pin
Rage29-Apr-03 20:46
professionalRage29-Apr-03 20:46 
GeneralMFC Testing Framework Pin
AAntix29-Apr-03 18:21
AAntix29-Apr-03 18:21 
Generalwebbrowser contextmenu Pin
imajit29-Apr-03 18:21
imajit29-Apr-03 18:21 
GeneralRe: webbrowser contextmenu Pin
Chris Richardson30-Apr-03 22:42
Chris Richardson30-Apr-03 22:42 
GeneralSimple cpp question Pin
ninjakiwi29-Apr-03 17:44
ninjakiwi29-Apr-03 17:44 
GeneralRe: Simple cpp question Pin
Toni7829-Apr-03 20:13
Toni7829-Apr-03 20:13 
GeneralRe: Simple cpp question Pin
David Crow30-Apr-03 3:15
David Crow30-Apr-03 3:15 
GeneralSerialization problem Pin
fermar8429-Apr-03 16:50
fermar8429-Apr-03 16:50 
GeneralRe: Serialization problem Pin
Neville Franks29-Apr-03 21:09
Neville Franks29-Apr-03 21:09 
QuestionHow to Broadcast? Pin
Aidman29-Apr-03 13:20
Aidman29-Apr-03 13:20 
AnswerRe: How to Broadcast? Pin
JohnnyG29-Apr-03 15:13
JohnnyG29-Apr-03 15:13 
GeneralRe: How to Broadcast? Pin
Aidman29-Apr-03 22:41
Aidman29-Apr-03 22:41 
GeneralRe: How to Broadcast? Pin
JohnnyG30-Apr-03 3:11
JohnnyG30-Apr-03 3:11 
GeneralRe: How to Broadcast? Pin
Aidman30-Apr-03 9:10
Aidman30-Apr-03 9:10 
GeneralRe: How to Broadcast? Pin
Aidman30-Apr-03 9:45
Aidman30-Apr-03 9:45 
GeneralRe: How to Broadcast? Pin
JohnnyG30-Apr-03 11:11
JohnnyG30-Apr-03 11:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.