W
weiyuan99
Unregistered / Unconfirmed
GUEST, unregistred user!
我的代码如下,好像没有执行?
//---------------------------------------------------------------------------
bool __fastcall TWPrint:etectPrinter(String sPrinterStr,String sPrintState)
{
int handle, length, res;
char string[10];
try
{
strcpy(string, "/x18");//clear cache
length = strlen(string);
if((handle = open(sPrinterStr.c_str(), O_WRONLY, S_IREAD | S_IWRITE)) == -1)
{
//ShowMessage("error!");
return false;
}
if((sPrintState=="1")||(sPrintState=="3"))
{
write(handle, string,length);
}
close(handle);
return true;
}
catch(...)
{
if(handle != -1) close(handle);
return false;
}
}
//---------------------------------------------------------------------------
bool __fastcall TWPrint:etectPrinter(String sPrinterStr,String sPrintState)
{
int handle, length, res;
char string[10];
try
{
strcpy(string, "/x18");//clear cache
length = strlen(string);
if((handle = open(sPrinterStr.c_str(), O_WRONLY, S_IREAD | S_IWRITE)) == -1)
{
//ShowMessage("error!");
return false;
}
if((sPrintState=="1")||(sPrintState=="3"))
{
write(handle, string,length);
}
close(handle);
return true;
}
catch(...)
{
if(handle != -1) close(handle);
return false;
}
}