void __fastcall TSaveObj::SaveDeltas(TClientDataSet* PCds,OleVariant vDeltas) { TCustomClientDataSet *ADS = new TCustomClientDataSet(NULL); try { ADS->Data = vDeltas; ADS->First(); while (!ADS->Eof) { //更新的内容 if ((ADS->UpdateStatus() == usModified) || (ADS->UpdateStatus() == usInserted) || (ADS->UpdateStatus() == usDeleted) ) { AssignPropVal(PCds,ADS,ADS->UpdateStatus()); //得到更新的主键值 if (ADS->UpdateStatus() == usModified) { } //建立sql AnsiString tmp =BuildSql(ADS); if (tmp !="") { int ret =ExecSQL(tmp); FSaveSql = FSaveSql+ tmp; if (ret==-1) { AnsiString strInfo = "保存数据失败 "; strInfo += StrPas(GetLastSQLError()); RaiseErr(strInfo); } else if (ret<0) { try { RaiseErr("保存数据失败,请检查网络是否正常或其他"); } __finally { } } } } ADS->Next(); }
__fastcall TAboutBox::TAboutBox(TComponent* Owner) : TForm(Owner) { char szVer[80] = {0}; GetFileInfo(szVer, Application->ExeName.c_str(), 0); lbVersion->Caption = lbVersion->Caption + StrPas(szVer); AnsiString sPlatform = ""; int iBuildNumber = 0; switch (Win32Platform) { case VER_PLATFORM_WIN32_WINDOWS: sPlatform = "Windows 95"; iBuildNumber = Win32BuildNumber & 0x0000FFFF; break; case VER_PLATFORM_WIN32_NT: sPlatform = "Windows NT"; iBuildNumber = Win32BuildNumber; break; default: AnsiString sPlatform = "Windows"; break; } if ((Win32Platform == VER_PLATFORM_WIN32_WINDOWS) || (Win32Platform == VER_PLATFORM_WIN32_NT)) { if (Win32CSDVersion == "") lbOS->Caption = Format("%s %d.%d (Build %d)", ARRAYOFCONST((sPlatform, Win32MajorVersion, Win32MinorVersion, iBuildNumber))); else lbOS->Caption = Format("%s %d.%d (Build %d: %s)", ARRAYOFCONST((sPlatform, Win32MajorVersion, Win32MinorVersion, iBuildNumber, Win32CSDVersion))); } else { lbOS->Caption = Format("%s %d.%d", ARRAYOFCONST((sPlatform, Win32MajorVersion, Win32MinorVersion))); } TMemoryStatus MS; GlobalMemoryStatus(&MS); AnsiString sMem = FormatFloat("#,### KB", MS.dwTotalPhys / 1024); while (sMem.Length() < 28) { sMem = " " + sMem; } lbMemory->Caption = "系统可用物理内存: " + sMem; }
//--------------------------------------------------------------------------- USEFORM("forms\unit_Main.cpp", form_Main); //--------------------------------------------------------------------------- void FindAndSendMesageToParent() { // ------ ’раню данные о процессах которые совпадают с именем софта ------ PROCESSENTRY32 *pr_entr_array = NULL; int pr_entr_ItemsCount = 0; // ----- PROCESSENTRY32 pr_entr; pr_entr.dwSize = sizeof( PROCESSENTRY32 ); THREADENTRY32 thr_entr; thr_entr.dwSize = sizeof( THREADENTRY32 ); HANDLE handle; // ---- ѕооиск процессов сопадающих с именем моего софта ----- handle = CreateToolhelp32Snapshot( TH32CS_SNAPALL, 0 ); if ( Process32First( handle, &pr_entr ) ) while ( Process32Next( handle, &pr_entr ) ) { if ( LowerCase( StrPas( pr_entr.szExeFile ) ) == LowerCase( ExtractFileName(Application->ExeName) )) { pr_entr_ItemsCount++; pr_entr_array = (PROCESSENTRY32 *) realloc (pr_entr_array, pr_entr_ItemsCount*sizeof(PROCESSENTRY32) ); memcpy(&pr_entr_array[pr_entr_ItemsCount-1], &pr_entr, sizeof(PROCESSENTRY32)); } } CloseHandle( handle ); // ---- »щу “рэды дл¤ которых совпадают ѕарент“ридјйди ----- handle = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); if ( Thread32First(handle, &thr_entr) ) while ( Thread32Next(handle, &thr_entr) ) for ( int i = 0; i < pr_entr_ItemsCount; i++) if ( pr_entr_array[i].th32ProcessID == thr_entr.th32OwnerProcessID ) { PostThreadMessage(thr_entr.th32ThreadID, WM_WAKEUP, 0, 0); //bs = GetLastError(); //if ( bs == ERROR_INVALID_THREAD_ID ) {} } CloseHandle( handle ); if ( pr_entr_array != NULL ) free(pr_entr_array); pr_entr_array = NULL; }
//²Ù×÷Ô±µÇ¼ bool __fastcall TfrmLogin::LoginSys(AnsiString sLginNo, AnsiString sLginPwd) { AnsiString strSQL,strInfo; int iRet; Screen->Cursor = crHourGlass; #if 0 Lguser.IsAdmin = true; Lguser.bLoginOk = true; Screen->Cursor = crDefault; return true; #endif if (sLginPwd.IsEmpty()) { strSQL = "select * from T_en_user where UR_USERID ='"+sLginNo +"' and user_pwd is null"; } else { strSQL = "select * from T_en_user where UR_USERID ='"+sLginNo +"' and UR_PASSWORD=\'"+ sLginPwd +"\'"; } char tmp; //tmp = PAY_USER_ACTIVE ; //strSQL = strSQL+ " and UR_STATUS="+QuotedStr(atoi(&tmp)); try { iRet = ExecSQL(strSQL,true,dmMain->cDataSetQry); } catch(...) { strInfo = "µÇ¼ʧ°Ü¡£"; ShowDlg(strInfo, DLG_ICONWARNING); return false; } if (iRet == -1) { strInfo = "µÇ¼ʧ°Ü "; strInfo += StrPas(GetLastSQLError()); ShowDlg(strInfo, DLG_ICONWARNING); return false; } else if (iRet == -2) { strInfo = "²ÎÊý´íÎó¡£"; ShowDlg(strInfo, DLG_ICONWARNING); return false; } if (dmMain->cDataSetQry->RecordCount < 1) { strInfo = "Î޴˲Ù×÷Ô±»òÃÜÂë´íÎó¡£"; ShowDlg(strInfo, DLG_ICONWARNING); dmMain->cDataSetQry->Close(); return false;; } else { Lguser.sLoginNo = dmMain->cDataSetQry->FieldByName("UR_USERID")->AsString; Lguser.sLoginName = dmMain->cDataSetQry->FieldByName("UR_USERNAME")->AsString; Lguser.sPwd = dmMain->cDataSetQry->FieldByName("UR_PASSWORD")->AsString; Lguser.MenuRigth = dmMain->cDataSetQry->FieldByName("ur_MenuRight")->AsString; AnsiString tmpstr = dmMain->cDataSetQry->FieldByName("ur_isAdmin")->AsString; Lguser.IsAdmin = (tmpstr =="1"); //Lguser.uProp = dmMain->cDataSetQry->FieldByName("user_prop")->AsInteger; Lguser.sMemo = dmMain->cDataSetQry->FieldByName("user_memo")->AsString; Lguser.IsAdmin = true; Lguser.bLoginOk = true; } Screen->Cursor = crDefault; return true; }