PC Review


Reply
Thread Tools Rate Thread

CRASH (XP EMBEDDED WITH LATEST SERVICE PACK)

 
 
Giuseppe Recalcati
Guest
Posts: n/a
 
      25th Aug 2003
If I do an enumprinters while the system is adding a printer via the
"Add Printer Wizard" the system reboots: this happens ALWAYS if there
was no previous printer installed (and obviously no default printer
installed).
I think that this problem affects Windows XP (HOME/PRO) too.
you can check this problem with the following simple test program:

#include <windows.h>
#include <stdio.h>

BOOL CALLBACK WaitProc(HWND hwnd,LPARAM lParam)
{
bool& found = *((bool*)lParam);
char buffer[1024];
memset(buffer,0,1024);
GetWindowText(hwnd,buffer,1024);
if(strstr(buffer,"Add Printer Wizard"))
{
found = true;
return false;
}
return true;
}

BOOL CALLBACK CloseProc(HWND hwnd,LPARAM lParam)
{
bool& found = *((bool*)lParam);
char buffer[1024];
memset(buffer,0,1024);
GetWindowText(hwnd,buffer,1024);
if(strstr(buffer,"Add Printer Wizard"))
{
found = true;
return false;
}
return true;
}

BOOL CALLBACK CopyProc(HWND hwnd,LPARAM lParam)
{
bool& found = *((bool*)lParam);
char buffer[1024];
memset(buffer,0,1024);
GetWindowText(hwnd,buffer,1024);
if(strstr(buffer,"Copying Files"))
{
found = true;
return false;
}
return true;
}

//Check if the number of printers changes...
void main(void)
{
//First check for the actual number of printers...
unsigned int bytes = 0;
unsigned char* buffer = new unsigned char[bytes + 1];
BOOL status = false;
PRINTER_INFO_2* Penum = (PRINTER_INFO_2*)buffer;
DWORD Psize = bytes;
DWORD Pcopy = sizeof(PRINTER_INFO_1);
DWORD Preq = 1;
DWORD Status = 0L;
while(!status && buffer)
{
Penum = (PRINTER_INFO_2*)buffer;
Psize = bytes;

status = EnumPrinters( (DWORD) PRINTER_ENUM_LOCAL,
(LPSTR) NULL,
(DWORD) 2,
(LPBYTE) Penum,
(DWORD) Psize,
(LPDWORD) &Pcopy,
(LPDWORD) &Preq);
if(!status)
{
bytes += Pcopy;
delete[] buffer;
buffer = new unsigned char[bytes + 1];
}
}
unsigned int NumPrinters = Preq;
//Wait for the "Add Printer Wizard" startup...
int found = false;
for(;
{
EnumWindows(WaitProc,(long)&found);
if(found) break;
Sleep(1000);
}
Sleep(1000);
//If Ok continue...
if(found)
{
//Wait for the "Add Printer Wizard" closure...
for(;
{
int found = false;
EnumWindows(CloseProc,(long)&found);
if(!found) break;
Sleep(1000);
}
Sleep(1000);
//Wait for the "Copy Files" startup...
for(;
{
int found = false;
EnumWindows(CopyProc,(long)&found);
if(!found) break;
Sleep(1000);
}
Sleep(1000);
}
//Check if the number of printers is changed...
for(unsigned int i=0;i < 60;i++)
{
unsigned int bytes = 0;
unsigned char* buffer = new unsigned char[bytes + 1];
BOOL status = false;
PRINTER_INFO_2* Penum = (PRINTER_INFO_2*)buffer;
DWORD Psize = bytes;
DWORD Pcopy = sizeof(PRINTER_INFO_1);
DWORD Preq = 1;
DWORD Status = 0L;
while(!status && buffer)
{
Penum = (PRINTER_INFO_2*)buffer;
Psize = bytes;

status = EnumPrinters( (DWORD) PRINTER_ENUM_LOCAL,
(LPSTR) NULL,
(DWORD) 2,
(LPBYTE) Penum,
(DWORD) Psize,
(LPDWORD) &Pcopy,
(LPDWORD) &Preq);
if(!status)
{
bytes += Pcopy;
delete[] buffer;
buffer = new unsigned char[bytes + 1];
}
}
if(Preq != NumPrinters)
{
//SOMETHING IS CHANGED...
NumPrinters = Preq;
break;
}
if(buffer) delete[] buffer;
buffer = NULL;
Sleep(1000);
}
Sleep(60 * 1000);
}
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
latest Service Pack of Windows Embedded Standard AMangaser Windows XP Embedded 2 23rd Nov 2009 02:13 AM
I just downloaded the latest service pack for Office XP. Now my . =?Utf-8?B?RGFyeWw=?= Microsoft Outlook Discussion 0 25th Oct 2004 04:25 PM
Latest Service Pack / Palm synchronization Kenneth David Windows XP General 2 28th Feb 2004 08:07 PM
Latest Jet 4.0 Service Pack Lonnie Bridges Windows XP Basics 1 15th Feb 2004 04:33 AM
How to remove latest IE 6 service pack? Gulag Windows XP Internet Explorer 0 23rd Jul 2003 12:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:56 PM.