bool BrainUtil::RunSystemCommand(const CString& cmd) { CString tempCmd = cmd; //int ret = _wsystem(tempCmd.GetBuffer()); //DATA_ASSERT(0 == ret); // Don't aseert the failure is accepted. // Get the output from the pipe FILE* pipe = _wpopen(tempCmd.GetBuffer(), _T("r")); if (!pipe) { return false; LogOut(_T("Error: failed to create the piple.")); } TCHAR buffer[256]; while(!feof(pipe)) { if(fgetws(buffer, 256, pipe) != NULL) { LogOut(buffer); } } int ret = _pclose(pipe); return 0 == ret; }
/** * @brief 处理结算中断 * @param 无 * @return * @li APP_SUCC * @li APP_FAIL * @li APP_QUIT */ int DealSettleTask(void) { if (YES == GetVarBatchHaltFlag() || YES == GetVarPrintSettleHalt() || YES == GetVarPrintDetialHalt() || YES == GetVarClrSettleDataFlag() ) { if(PubConfirmDlg("上次结算未完成", "是否继续执行结算", 0, 30)!=APP_SUCC) return APP_FAIL; if (APP_SUCC == Settle(1)) { if (YES == GetVarIsAutoLogOut()) { LogOut(); } #if defined(USE_TMS) DoTmsTask(TMS_POS_CHKUPDATA); #endif return APP_QUIT; } else { if (PubGetKeyCode(1) == KEY_ESC) { return APP_QUIT; } return APP_FAIL; } } return APP_SUCC; }
int far pascal zEnumObjects( HDC pp1, int pp2, FARPROC pp3, LPSTR pp4 ) { int r; FARPROC fp ; SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:EnumObjects HDC+int+FARPROC+LPSTR+", pp1, pp2, pp3, pp4 ); if( pp2 == OBJ_PEN ) fp = (FARPROC)HookAdd( (void far *)EnumPens, (void far *)pp3 ) ; else fp = (FARPROC)HookAdd( (void far *)EnumBrushes, (void far *)pp3 ) ; /* ** Call the API! */ RestoreRegs(); GrovelDS(); r = EnumObjects(pp1,pp2,fp,pp4); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:EnumObjects int+++++", r, (short)0, (short)0, (short)0, (short)0 ); RestoreRegs(); return( r ); }
BOOL far pascal zUnhookWindowsHook( int pp1, FARPROC pp2 ) { BOOL r; FARPROC fp ; SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:UnhookWindowsHook int+FARPROC+", pp1, pp2 ); fp = (FARPROC)HookFind( (void far *)pp2 ) ; if ( fp == NULL ) { /* Unhooking an unknown hook type */ fp = pp2; } /* ** Call the API! */ RestoreRegs(); GrovelDS(); r = UnhookWindowsHook(pp1,fp); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:UnhookWindowsHook BOOL+++", r, (short)0, (short)0 ); RestoreRegs(); return( r ); }
int FAR PASCAL DlgMesgProc( HWND hWnd, WORD wMsg, WORD wParam, LONG lParam, FARPROC fp, WORD AX ) { int i; SaveRegs() ; LogIn( (LPSTR)"MSGCALL:FARPROC+HWND+MSGNUM+WORD+LONG+", fp, hWnd, wMsg, wParam, lParam ); RestoreRegs() ; GrovelDS(); i = HookCall( hWnd, wMsg, wParam, lParam, fp, AX ); UnGrovelDS(); SaveRegs() ; LogOut( (LPSTR)"MSGRET:LONG+FARPROC+MSGNUM+WORD+LONG+", (LONG)i, fp, hWnd, wMsg, wParam, lParam ); RestoreRegs() ; return( i ); }
BOOL far pascal zExtTextOut( HDC pp1, int pp2, int pp3, WORD pp4, LPRECT pp5, LPSTR pp6, WORD pp7, LPINT pp8 ) { BOOL r; SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:ExtTextOut HDC+int+int+WORD+LPRECT+LPSTR+WORD+ARRAYINT+", pp1, pp2, pp3, pp4, pp5, pp6, pp7, pp8, pp7 ); /* ** Call the API! */ RestoreRegs(); GrovelDS(); r = ExtTextOut(pp1,pp2,pp3,pp4,pp5,pp6,pp7,pp8); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:ExtTextOut BOOL+++++++++", r, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0 ); RestoreRegs(); return( r ); }
void far pascal zSetKeyboardState( BYTE far* pp1 ) { SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:SetKeyboardState FixedString+", pp1, (DWORD) 256 ); /* ** Call the API! */ RestoreRegs(); GrovelDS(); SetKeyboardState(pp1); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:SetKeyboardState +", (short)0 ); RestoreRegs(); return; }
WORD far pascal zSetTimer( HWND pp1, int pp2, WORD pp3, FARPROC pp4 ) { WORD r; SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:SetTimer HWND+int+WORD+FARPROC+", pp1, pp2, pp3, pp4 ); if ( pp4 != NULL ) { pp4 = (FARPROC) HookAdd( (void far *)TimerRtn, (void far *)pp4 ); } /* ** Call the API! */ RestoreRegs(); GrovelDS(); r = SetTimer(pp1,pp2,pp3,pp4); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:SetTimer WORD+++++", r, (short)0, (short)0, (short)0, (short)0 ); RestoreRegs(); return( r ); }
int far pascal zSetCommState( DCB far* pp1 ) { int r; SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:SetCommState DCB far*+", pp1 ); /* ** Call the API! */ RestoreRegs(); GrovelDS(); r = SetCommState(pp1); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:SetCommState int++", r, (short)0 ); RestoreRegs(); return( r ); }
UINT far* far pascal zSetCommEventMask( int pp1, UINT pp2 ) { UINT far* r; SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:SetCommEventMask int+UINT+", pp1, pp2 ); /* ** Call the API! */ RestoreRegs(); GrovelDS(); r = SetCommEventMask(pp1,pp2); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:SetCommEventMask UINT far*+++", r, (short)0, (short)0 ); RestoreRegs(); return( r ); }
int far pascal zOpenComm( LPCSTR pp1, UINT pp2, UINT pp3 ) { int r; SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:OpenComm LPCSTR+UINT+UINT+", pp1, pp2, pp3 ); /* ** Call the API! */ RestoreRegs(); GrovelDS(); r = OpenComm(pp1,pp2,pp3); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:OpenComm int++++", r, (short)0, (short)0, (short)0 ); RestoreRegs(); return( r ); }
/** * @brief 进行签退处理(有判断操作员的权限) * @param 无 * @return * @li APP_SUCC * @li APP_FAIL */ static int DoLogOut(void) { int nWaterSum = 0; int nRet = 0; if (APP_SUCC != ChkOperRole()) { return APP_FAIL; } GetWaterNum(&nWaterSum); if (nWaterSum > 0) { PubMsgDlg("签退", "有交易流水先结算", 3, 10); return APP_FAIL; } if (YES == GetVarIsLogin()) { nRet = LogOut(); } else { PubMsgDlg("签退", "POS已经签退", 0, 3); nRet = APP_FAIL; } #if defined(USE_TMS) DoTmsTask(TMS_POS_CHKUPDATA); #endif return nRet; }
/** * @brief 进行结帐处理(有判断操作员的权限) * @param 无 * @return * @li APP_SUCC * @li APP_FAIL */ int DoSettle(void) { int nWaterSum = 0; int nRet = 0; if (APP_SUCC != ChkOperRole()) { return APP_FAIL; } GetWaterNum(&nWaterSum); if (nWaterSum == 0) { PubMsgDlg("批结算", "无流水不允许结算\n\n按任意键退出!", 1, 30); return APP_FAIL; } //ASSERT_QUIT(DispTotal()); if (Settle(0) != APP_SUCC) { PubMsgDlg("结算失败", "请重新结算", 3, 10); return APP_FAIL; } if (YES == GetVarIsAutoLogOut()) { nRet = LogOut(); } #if defined(USE_TMS) DoTmsTask(TMS_POS_CHKUPDATA); #endif return nRet; }
void BrainUtil::LogOutLastError(const CString& lpszFunction) { // Retrieve the system error message for the last-error code LPVOID lpMsgBuf; LPVOID lpDisplayBuf; DWORD dw = GetLastError(); if(0 == dw) return; // Don't need to log out the success information. FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL ); // Display the error message and exit the process lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT, (lstrlen((LPCTSTR)lpMsgBuf) + lstrlen((LPCTSTR)lpszFunction) + 40) * sizeof(TCHAR)); StringCchPrintf((LPTSTR)lpDisplayBuf, LocalSize(lpDisplayBuf) / sizeof(TCHAR), TEXT("%s failed with error %d: %s"), (LPCTSTR)lpszFunction, dw, lpMsgBuf); LogOut((LPTSTR)lpDisplayBuf, COLOR_RED); LocalFree(lpMsgBuf); LocalFree(lpDisplayBuf); //ExitProcess(dw); }
long far pascal zSetWindowLong( HWND pp1, int pp2, long pp3 ) { long r; long l; FARPROC fp ; SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:SetWindowLong HWND+int+long+", pp1, pp2, pp3 ); if( pp2 == GWL_WNDPROC ) { pp3 = (long)((FARPROC)HookAdd( (void far *)MesgProc, (void far *)pp3 )); } /* ** Call the API! */ RestoreRegs(); GrovelDS(); r = SetWindowLong(pp1,pp2,pp3); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:SetWindowLong long++++", r, (short)0, (short)0, (short)0 ); RestoreRegs(); return( r ); }
int far pascal zUngetCommChar( int pp1, char pp2 ) { int r; SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:UngetCommChar int+char+", pp1, pp2 ); /* ** Call the API! */ RestoreRegs(); GrovelDS(); r = UngetCommChar(pp1,pp2); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:UngetCommChar int+++", r, (short)0, (short)0 ); RestoreRegs(); return( r ); }
/* ** TIMER STUFF ** */ WORD FAR PASCAL TimerRtn( HWND hwnd, WORD uMsg, int nId, DWORD dwTime, FARPROC fp, WORD AX ) { WORD rc; SaveRegs() ; LogIn( (LPSTR)"TIMECALL:SetTimer FARPROC+HWND+WORD+int+DWORD+", fp, hwnd, uMsg, nId, dwTime ) ; RestoreRegs() ; GrovelDS(); rc = HookCall( hwnd, uMsg, nId, dwTime, fp, AX ); UnGrovelDS(); SaveRegs() ; LogOut( (LPSTR)"TIMERET:SetTimer WORD+FARPROC+HWND+WORD+int+DWORD+", rc, fp, hwnd, uMsg, nId, dwTime ) ; RestoreRegs() ; return( rc ); }
int far pascal zWriteComm( int pp1, void far* pp2, int pp3 ) { int r; SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:WriteComm int+FineString+", pp1, (LPSTR) pp2, (int) pp3 ); /* ** Call the API! */ RestoreRegs(); GrovelDS(); r = WriteComm(pp1,pp2,pp3); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:WriteComm int++++", r, (short)0, (short)0, (short)0 ); RestoreRegs(); return( r ); }
long far pascal zSetBitmapBits( HBITMAP pp1, DWORD pp2, LPSTR pp3 ) { long r; SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:SetBitmapBits HBITMAP+DWORD+FixedString+", pp1, pp2, pp3, pp2 ); /* ** Call the API! */ RestoreRegs(); GrovelDS(); r = SetBitmapBits(pp1,pp2,pp3); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:SetBitmapBits long++++", r, (short)0, (short)0, (short)0 ); RestoreRegs(); return( r ); }
int far pascal zClearCommBreak( int pp1 ) { int r; SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:ClearCommBreak int+", pp1 ); /* ** Call the API! */ RestoreRegs(); GrovelDS(); r = ClearCommBreak(pp1); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:ClearCommBreak int++", r, (short)0 ); RestoreRegs(); return( r ); }
BOOL far pascal zGetCharWidth( HDC pp1, UINT pp2, UINT pp3, LPINT pp4 ) { BOOL r; SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:GetCharWidth HDC+UINT+UINT++", pp1, pp2, pp3, (short)0 ); /* ** Call the API! */ RestoreRegs(); GrovelDS(); r = GetCharWidth(pp1,pp2,pp3,pp4); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:GetCharWidth BOOL++++ARRAYINT+", r, (short)0, (short)0, (short)0, pp4, 1 + pp3 - pp2 ); RestoreRegs(); return( r ); }
int far pascal zBuildCommDCB( LPCSTR pp1, DCB far* pp2 ) { int r; SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:BuildCommDCB ++", (short)0, (short)0 ); /* ** Call the API! */ RestoreRegs(); GrovelDS(); r = BuildCommDCB(pp1,pp2); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:BuildCommDCB int+LPCSTR+DCB far*+", r, pp1, pp2 ); RestoreRegs(); return( r ); }
HDC far pascal zResetDC(HDC pp1, LPSTR pp2) { HDC r; SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:ResetDC HDC+LPDEVMODE+", pp1, pp2 ); /* ** Call the API! */ RestoreRegs(); GrovelDS(); r = ResetDC(pp1,pp2); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:ResetDC HDC+++", r, (short)0, (short)0 ); RestoreRegs(); return( r ); }
int far pascal zFlushComm( int pp1, int pp2 ) { int r; SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:FlushComm int+int+", pp1, pp2 ); /* ** Call the API! */ RestoreRegs(); GrovelDS(); r = FlushComm(pp1,pp2); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:FlushComm int+++", r, (short)0, (short)0 ); RestoreRegs(); return( r ); }
LONG FAR PASCAL WH_DEBUGHook( int nCode, WORD wParam, LONG lParam, FARPROC fp, WORD AX ) { LONG l; SaveRegs() ; LogIn( (LPSTR)"HOOKCALL:WH_DEBUG FARPROC+int+WORD+LONG+", fp, nCode, wParam, lParam ); RestoreRegs() ; GrovelDS(); l = HookCall( nCode, wParam, lParam, fp, AX ); UnGrovelDS(); SaveRegs() ; LogOut( (LPSTR)"HOOKRET:WH_DEBUG LONG+FARPROC+int+WORD+LONG+", l, fp, nCode, wParam, lParam ); RestoreRegs() ; return( l ); }
BOOL FAR PASCAL EnumTaskWin( HWND hwnd, DWORD lParam, FARPROC fp, WORD AX ) { BOOL l; SaveRegs() ; LogIn( (LPSTR)"ENUMCALL:EnumTaskWindows FARPROC+HWND+DWORD+", fp, hwnd, lParam ) ; RestoreRegs() ; GrovelDS(); l = HookCall( hwnd, lParam, fp, AX ); UnGrovelDS(); SaveRegs() ; LogOut( (LPSTR)"ENUMRET:EnumTaskWindows BOOL+FARPROC+HWND+DWORD+", l, fp, hwnd, lParam ) ; RestoreRegs() ; return( l ); }
int FAR PASCAL EnumBrushes( char FAR *lpLogObject, char FAR *lpData, FARPROC fp, WORD AX ) { int l; SaveRegs() ; LogIn( (LPSTR)"ENUMCALL:EnumObjects(BRUSH) FARPROC+LPLOGPEN+LPSTR+", fp, lpLogObject, lpData ) ; RestoreRegs() ; GrovelDS(); l = HookCall( lpLogObject, lpData, fp, AX ); UnGrovelDS(); SaveRegs() ; LogOut( (LPSTR)"ENUMRET:EnumObjects(BRUSH) int+FARPROC+LPLOGPEN+LPSTR+", l, fp, lpLogObject, lpData ) ; RestoreRegs() ; return( l ); }
BOOL far pascal zEnumTaskWindows( HANDLE pp1, FARPROC pp2, long pp3 ) { BOOL r; SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:EnumTaskWindows HANDLE+FARPROC+long+", pp1, pp2, pp3 ); pp2 = (FARPROC) HookAdd( (void far *)EnumTaskWin, (void far *)pp2 ) ; /* ** Call the API! */ RestoreRegs(); GrovelDS(); r = EnumTaskWindows(pp1,pp2,pp3); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:EnumTaskWindows BOOL++++", r, (short)0, (short)0, (short)0 ); RestoreRegs(); return( r ); }
int FAR PASCAL FamilyCounter( char FAR *lpLogFont, char FAR *lpTextMetrics, short nFontType, char FAR *lpData, FARPROC fp, WORD AX ) { int l; SaveRegs() ; LogIn( (LPSTR)"ENUMCALL:EnumFontFamilies FARPROC+LPLOGFONT+LPTEXTMETRIC+int+DWORD+", fp, lpLogFont, lpTextMetrics, nFontType, lpData ) ; RestoreRegs() ; GrovelDS(); l = HookCall( lpLogFont, lpTextMetrics, nFontType, lpData, fp, AX ); UnGrovelDS(); SaveRegs() ; LogOut( (LPSTR)"ENUMRET:EnumFontFamilies int+FARPROC+LPLOGFONT+LPTEXTMETRIC+int+DWORD+", l, fp, lpLogFont, lpTextMetrics, nFontType, lpData ) ; RestoreRegs() ; return( l ); }
DWORD far pascal zGetTextExtent( HDC pp1, LPCSTR pp2, int pp3 ) { DWORD r; SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:GetTextExtent HDC+LPCSTR+int+", pp1, pp2, pp3 ); /* ** Call the API! */ RestoreRegs(); GrovelDS(); r = GetTextExtent(pp1,pp2,pp3); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:GetTextExtent DWORD++++", r, (short)0, (short)0, (short)0 ); RestoreRegs(); return( r ); }