123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501 |
- #include "StdAfx.h"
- #include "Global.h"
- #include <io.h> // _access_s头文件;
- #include "afxcoll.h"
- #include "afxtempl.h"
- #include "atlconv.h"
- #include <tlhelp32.h>
- #include <WinSock.h>
- #include "..\\lzari.h"
- #include "..\helper\ffsco.h"
- static const int BEGIN_YEAR = 1901;
- static const int NUMBER_YEAR = 199;
- static const unsigned int LUNAR_YEARS[199] =
- {
- 0x04AE53, 0x0A5748, 0x5526BD, 0x0D2650, 0x0D9544, 0x46AAB9, 0x056A4D, 0x09AD42, 0x24AEB6, 0x04AE4A,
- 0x6A4DBE, 0x0A4D52, 0x0D2546, 0x5D52BA, 0x0B544E, 0x0D6A43, 0x296D37, 0x095B4B, 0x749BC1, 0x049754,
- 0x0A4B48, 0x5B25BC, 0x06A550, 0x06D445, 0x4ADAB8, 0x02B64D, 0x095742, 0x2497B7, 0x04974A, 0x664B3E,
- 0x0D4A51, 0x0EA546, 0x56D4BA, 0x05AD4E, 0x02B644, 0x393738, 0x092E4B, 0x7C96BF, 0x0C9553, 0x0D4A48,
- 0x6DA53B, 0x0B554F, 0x056A45, 0x4AADB9, 0x025D4D, 0x092D42, 0x2C95B6, 0x0A954A, 0x7B4ABD, 0x06CA51,
- 0x0B5546, 0x555ABB, 0x04DA4E, 0x0A5B43, 0x352BB8, 0x052B4C, 0x8A953F, 0x0E9552, 0x06AA48, 0x7AD53C,
- 0x0AB54F, 0x04B645, 0x4A5739, 0x0A574D, 0x052642, 0x3E9335, 0x0D9549, 0x75AABE, 0x056A51, 0x096D46,
- 0x54AEBB, 0x04AD4F, 0x0A4D43, 0x4D26B7, 0x0D254B, 0x8D52BF, 0x0B5452, 0x0B6A47, 0x696D3C, 0x095B50,
- 0x049B45, 0x4A4BB9, 0x0A4B4D, 0xAB25C2, 0x06A554, 0x06D449, 0x6ADA3D, 0x0AB651, 0x093746, 0x5497BB,
- 0x04974F, 0x064B44, 0x36A537, 0x0EA54A, 0x86B2BF, 0x05AC53, 0x0AB647, 0x5936BC, 0x092E50, 0x0C9645,
- 0x4D4AB8, 0x0D4A4C, 0x0DA541, 0x25AAB6, 0x056A49, 0x7AADBD, 0x025D52, 0x092D47, 0x5C95BA, 0x0A954E,
- 0x0B4A43, 0x4B5537, 0x0AD54A, 0x955ABF, 0x04BA53, 0x0A5B48, 0x652BBC, 0x052B50, 0x0A9345, 0x474AB9,
- 0x06AA4C, 0x0AD541, 0x24DAB6, 0x04B64A, 0x69573D, 0x0A4E51, 0x0D2646, 0x5E933A, 0x0D534D, 0x05AA43,
- 0x36B537, 0x096D4B, 0xB4AEBF, 0x04AD53, 0x0A4D48, 0x6D25BC, 0x0D254F, 0x0D5244, 0x5DAA38, 0x0B5A4C,
- 0x056D41, 0x24ADB6, 0x049B4A, 0x7A4BBE, 0x0A4B51, 0x0AA546, 0x5B52BA, 0x06D24E, 0x0ADA42, 0x355B37,
- 0x09374B, 0x8497C1, 0x049753, 0x064B48, 0x66A53C, 0x0EA54F, 0x06B244, 0x4AB638, 0x0AAE4C, 0x092E42,
- 0x3C9735, 0x0C9649, 0x7D4ABD, 0x0D4A51, 0x0DA545, 0x55AABA, 0x056A4E, 0x0A6D43, 0x452EB7, 0x052D4B,
- 0x8A95BF, 0x0A9553, 0x0B4A47, 0x6B553B, 0x0AD54F, 0x055A45, 0x4A5D38, 0x0A5B4C, 0x052B42, 0x3A93B6,
- 0x069349, 0x7729BD, 0x06AA51, 0x0AD546, 0x54DABA, 0x04B64E, 0x0A5743, 0x452738, 0x0D264A, 0x8E933E,
- 0x0D5252, 0x0DAA47, 0x66B53B, 0x056D4F, 0x04AE45, 0x4A4EB9, 0x0A4D4C, 0x0D1541, 0x2D92B5
- };
- BOOL g_bRemote = FALSE;
- HMODULE g_hlyfzMicroShareDLL = NULL;
- lyfzCreateShare g_lyfzCreateShare = NULL;
- WORD g_arrFileVersion[4] = { 0 };
- TCHAR g_szLoginUser[MAX_PATH] = _T("");
- TCHAR g_szLoginPsw[MAX_PATH] = _T("");
- TCHAR g_szModulePath[MAX_PATH] = _T("");
- TCHAR g_szModuleFileName[MAX_PATH] = _T("");
- TCHAR g_szConnectString[MAX_PATH] = _T("");
- TCHAR g_szHostComputerIP[MAX_PATH] = _T("");
- DWORD g_dwTCPChatPort;
- TCHAR g_szDBSource[MAX_PATH] = _T("");
- TCHAR g_szDBSourcePort[MAX_PATH] = _T("");
- DWORD g_dwDBServerPort = 0;
- TCHAR g_szDBAccount[MAX_PATH] = _T("");
- TCHAR g_szDBPassWord[MAX_PATH] = _T("");
- TCHAR g_szDBName[MAX_PATH] = _T("");
- TCHAR g_szShareHost[MAX_PATH] = _T("");
- TCHAR g_szOriginalFolder[MAX_PATH] = _T("");
- TCHAR g_szOriginalBkFolder[MAX_PATH] = _T("");
- TCHAR g_szEarlyRepairFolder[MAX_PATH] = _T("");
- TCHAR g_szEarlyRepairBkFolder[MAX_PATH] = _T("");
- TCHAR g_szFurtherRepairFolder[MAX_PATH] = _T("");
- TCHAR g_szFurtherRepairBkFolder[MAX_PATH] = _T("");
- TCHAR g_szDesignFolder[MAX_PATH] = _T("");
- TCHAR g_szDesignBkFolder[MAX_PATH] = _T("");
- TCHAR g_szTelRecordingFolder[MAX_PATH] = _T("");
- TCHAR g_szFullDressImageFolder[MAX_PATH] = _T("");
- BOOL g_bSoftWareReg = FALSE;
- CString g_strDogMainInfo = "";
- CString g_strMain = "";
- CStringArray g_strArrayOfBranchName;
- CStringArray g_strArrayOfBranchName2;
- CStringArray g_strArrayOfBranchIPAdress;
- CStringArray g_strArrayOfBranchDogMainInfo;
- unsigned int g_nCountOfAllowToConn = 0;
- DWORD g_nLeng = 0;
- BYTE *g_pData = NULL;
- DWORD g_nLeng2 = 0;
- BYTE *g_pData2 = NULL;
- SENDHEAD g_sendhead;
- BOOL g_bRedSkin = 0;
- COLORREF g_gridcol1 = RGB(204, 204, 204);
- COLORREF g_gridcol2 = RGB(190, 190, 190);
- COLORREF g_bkcol = RGB(184, 184, 184);
- CString g_date;
- CString g_title;
- CArray<CStringArray, CStringArray>g_userarray;
- CArray<CStringArray, CStringArray>g_cominfoarray;
- CArray<CStringArray, CStringArray>g_cominfoarraylocal;
- CArray<DWORD, DWORD>g_lengarray;
- CArray<DWORD, DWORD>g_btnlengarray;
- CArray<BYTE*, BYTE*>g_pointerarray;
- CBrush g_editbkbrush;
- DWORD g_btnleng[8];
- int g_btnlengpos = -1;
- int g_nYearpos = -1;
- CString g_branchname = "";
- CString g_branchip = "";
- CString g_branchip2 = "";
- BOOL g_bBranchModify = 0;
- BOOL g_bShowOK = 0;
- BOOL g_bStaffAchievementShow = 0;
- BOOL g_bSaveUploadTask1 = 0;
- BOOL g_bSaveUploadTask2 = 0;
- BOOL g_bSaveUploadTask3 = 0;
- BOOL g_bSaveUploadTask4 = 0;
- BOOL g_bSearchFilter = 0;
- CString g_waiter1;
- CString g_waiter2;
- CString g_waiter3;
- CString g_waiter4;
- CString g_waiter5;
- CString g_filterdate1;
- CString g_filterdate2;
- CString g_filterdate3;
- CString g_filterdate4;
- CString g_filterdate5;
- CString g_filterdate6;
- CString g_filterbranch;
- USER g_user;
- CString g_mainpath;
- CString g_id;
- CString g_server;
- CStringArray g_serverarray;
- CString g_serverbak;
- CString g_path1;
- CString g_path2;
- CString g_path3;
- CString g_path4;
- CString g_path5;
- CString g_path6;
- CString g_path7;
- CString g_path1bak;
- CString g_path2bak;
- CString g_path3bak;
- CString g_path4bak;
- CString g_path5bak;
- CString g_path6bak;
- CString g_path7bak;
- CDatabase g_db;
- DWORD g_ncount;
- CFont g_titlefont;
- DWORD g_nSendCode = 0;
- BOOL g_bSendOK = 0;
- CString g_temp;
- CArray<CStringArray, CStringArray>g_hisyeararray;
- CArray<CStringArray, CStringArray>g_brancharray;
- CArray<CStringArray, CStringArray>g_oldclientarray;
- BOOL g_bNoConnDlg = 0;
- BOOL g_bInSkin = 0;
- BOOL g_bGenBranchData = 0;
- BOOL g_bSortAscending = FALSE;
- CFont g_listctrlfont;
- float g_fscalex;
- float g_fscaley;
- int g_screenwid;
- int g_screenhei;
- float g_WidthScale2 = 1;
- float g_HeightScale2 = 1;
- RESDATA2 g_resdata2;
- BOOL g_bAlphaWnd = 0;
- BYTE g_bNeedDrawParent = 0;
- BOOL g_bAllBranch = 0;
- CString g_domain;
- CString g_sInfo;
- int g_ncot = 0;
- int g_conpos = 0;
- int g_nAutoShowStaffAchievement = -1;
- BOOL g_bShowBar = 1;
- int g_bookingtype = 0;
- BOOL g_bNoLoginLia = 0;
- BOOL g_bConnLYFZ = 0;
- BOOL g_bSendLYFZ = 0;
- int g_ntimeout = 29000;
- float g_WidthScale;
- float g_HeightScale;
- int g_dx = 0;
- int g_dy = 0;
- BOOL g_bNeedCoon = 1;
- CStringArray g_menubranchname;
- CArray<CStringArray, CStringArray>g_List1array;
- int g_conntype = 0;
- int GetSysIniInfo(const char *szPath, const char *szIniName)
- {
- TCHAR szDrive[_MAX_DRIVE] = { 0 };
- TCHAR szDir[_MAX_DIR] = { 0 };
- TCHAR szFna[_MAX_DIR] = { 0 };
- TCHAR szExt[_MAX_DIR] = { 0 };
- ::GetModuleFileName(NULL, g_szModuleFileName, sizeof(g_szModuleFileName) / sizeof(TCHAR));
- sprintf(g_szModulePath, _T("%s"), g_szModuleFileName);
- _tsplitpath(g_szModulePath, szDrive, szDir, szFna, szExt);
- _tcscpy(g_szModulePath, szDrive);
- _tcscat(g_szModulePath, szDir);
-
- TCHAR szFile[MAX_PATH + 1] = "";
- if (szPath != NULL && szIniName != NULL)
- wsprintf(szFile, _T("%s\\%s"), szPath, szIniName);
- else
- wsprintf(szFile, _T("%s\\HostInfo.ini"), g_szModulePath);
- TRACE("szFile =%s\n", szFile);
- OFSTRUCT ofStruct;
- OpenFile(szFile, &ofStruct, OF_EXIST);
- if (ERROR_FILE_NOT_FOUND == GetLastError())
- {
-
- strcpy(g_szHostComputerIP, _T("."));
- g_dwTCPChatPort = 5678;
- return -1;
- }
-
- GetPrivateProfileString(_T("HostComputerInfo"), _T("HostIP"), _T(""), g_szHostComputerIP, MAX_PATH, szFile);
- g_dwTCPChatPort = GetPrivateProfileInt(_T("HostComputerInfo"), _T("HostChatPort"), 0, szFile);
- return 0;
- }
- BOOL IsFileExist(const TCHAR *pFileFullName)
- {
- int err = 0;
-
- if ((err = _access(pFileFullName, 0)) == 0)
- {
-
-
- if ((err = _access(pFileFullName, 2)) == 0)
- {
-
- }
- else
- {
-
- }
- }
- else
- {
-
- return FALSE;
- }
- return TRUE;
- }
- BOOL WaitWithMessageLoop(HANDLE hEvent, int nTimeout)
- {
- DWORD dwRet = 0;
- while (1)
- {
-
- dwRet = MsgWaitForMultipleObjects(1, &hEvent, FALSE, nTimeout, QS_ALLINPUT);
- if (dwRet == WAIT_OBJECT_0)
- {
- TRACE0("WaitWithMessageLoop() event triggered.\n");
- return TRUE;
- }
- else
- if (dwRet == WAIT_OBJECT_0 + 1)
- {
-
- AfxGetApp()->PumpMessage();
- }
- else
- if (dwRet == WAIT_TIMEOUT)
- {
-
- return FALSE;
- }
- else
- {
-
- return TRUE;
- }
- }
- }
- void DeleteDirectory(CString strDir)
- {
- try
- {
-
- CFileFind ff;
- BOOL bFound = ff.FindFile(strDir + "\\*", 0);
- while (bFound)
- {
- bFound = ff.FindNextFile();
- if (ff.GetFileName() == "." || ff.GetFileName() == "..")
- continue;
-
- SetFileAttributes(ff.GetFilePath(), FILE_ATTRIBUTE_NORMAL);
- if (ff.IsDirectory())
- {
- DeleteDirectory(ff.GetFilePath());
- RemoveDirectory(ff.GetFilePath());
- }
- else
- {
- DeleteFile(ff.GetFilePath());
- }
- }
- ff.Close();
-
- RemoveDirectory(strDir);
- }
- catch (...)
- {
-
- }
-
- }
- BOOL RegisterOcx(LPCTSTR ocxfile)
- {
- HKEY hKey;
- bool bRet;
- USES_CONVERSION;
- ITypeLib* pTypeLib;
- CString CLSIDStr;
- CLSID clsid;
- LPOLESTR wRes = NULL;
- if (LoadTypeLib(T2OLE(ocxfile), &pTypeLib) == S_OK)
- {
- TLIBATTR tlibAttr, *ptlibAttr;
- ptlibAttr = &tlibAttr;
- pTypeLib->GetLibAttr(&ptlibAttr);
- clsid = ptlibAttr->guid;
- pTypeLib->Release();
- }
- ::StringFromCLSID(clsid, &wRes);
- CLSIDStr = OLE2CT(wRes);
- if ((RegOpenKeyEx(HKEY_CLASSES_ROOT, "CLSID\\" + CLSIDStr, 0, KEY_READ, &hKey) == ERROR_SUCCESS) || (RegOpenKeyEx(HKEY_CLASSES_ROOT, "Wow6432Node\\TypeLib\\" + CLSIDStr, 0, KEY_READ, &hKey) == ERROR_SUCCESS))
- {
- return true;
- }
- else
- {
- HINSTANCE hLib = LoadLibrary(ocxfile);
- if (hLib < (HINSTANCE)HINSTANCE_ERROR)
- {
- MessageBox(0, "权限不足,不能载入OCX文件!无法注册控件!", "结果", MB_OK);
- bRet = false;
- }
- else
- {
- FARPROC lpDllEntryPoint;
- lpDllEntryPoint = GetProcAddress(hLib, _T("DllRegisterServer"));
- if (lpDllEntryPoint != NULL)
- {
- if (FAILED((*lpDllEntryPoint)()))
- {
- MessageBox(0, "调用注册函数(DllRegisterServer)失败!无法注册控件!", "结果", MB_OK);
- bRet = false;
- }
- else
- bRet = true;
- }
- else
- {
- MessageBox(0, "调用注册函数(DllRegisterServer)失败!无法注册控件!", "结果", MB_OK);
- bRet = false;
- }
- }
- FreeLibrary(hLib);
- return bRet;
- }
- }
- BOOL GetDebugPriv()
- {
-
- HANDLE hToken;
-
- LUID sedebugnameValue;
-
- TOKEN_PRIVILEGES tkp;
- DWORD dwCurProcId = GetCurrentProcessId();
-
- HANDLE hCurProc;
- hCurProc = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwCurProcId);
- if (!::OpenProcessToken(hCurProc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
- {
- ShowSystemErrorInfo(CString("提权OpenProcessToken失败。"), GetLastError());
- return FALSE;
- }
- if (!::LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &sedebugnameValue))
- {
- ShowSystemErrorInfo(CString("提权LookupPrivilegeValue失败。"), GetLastError());
- CloseHandle(hToken);
- return FALSE;
- }
- tkp.PrivilegeCount = 1;
- tkp.Privileges[0].Luid = sedebugnameValue;
- tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
- if (!::AdjustTokenPrivileges(hToken, FALSE, &tkp, sizeof tkp, NULL, NULL))
- {
- ShowSystemErrorInfo(CString("提权AdjustTokenPrivileges失败。"), GetLastError());
- CloseHandle(hToken);
- return FALSE;
- }
- CloseHandle(hCurProc);
- CloseHandle(hToken);
- return TRUE;
- }
- bool GetFileVersion(HMODULE hModule, WORD *pBuffer)
- {
- TCHAR fname[MAX_PATH];
- VS_FIXEDFILEINFO *pVi;
- DWORD dwHandle;
- std::string str;
- if (::GetModuleFileName(hModule, fname, MAX_PATH))
- {
- int size = GetFileVersionInfoSize(fname, &dwHandle);
- if (size > 0)
- {
- BYTE *buffer = new BYTE[size];
- memset(buffer, 0, size);
- if (GetFileVersionInfo(fname, dwHandle, size, buffer))
- {
- if (VerQueryValue(buffer, _T("\\"), (LPVOID *)&pVi, (PUINT)&size))
- {
- pBuffer[0] = HIWORD(pVi->dwFileVersionMS);
- pBuffer[1] = LOWORD(pVi->dwFileVersionMS);
- pBuffer[2] = HIWORD(pVi->dwFileVersionLS);
- pBuffer[3] = LOWORD(pVi->dwFileVersionLS);
- delete buffer;
- return true;
- }
- }
- delete buffer;
- }
- }
- return false;
- }
- BOOL CheckInternalIPV4(const unsigned int &ip_addr)
- {
-
-
-
-
-
- #if 0
-
- if ((ip_addr >= 0x0A000000 && ip_addr <= 0x0AFFFFFF) ||
- (ip_addr >= 0xAC100000 && ip_addr <= 0xAC1FFFFF) ||
- (ip_addr >= 0xC0A80000 && ip_addr <= 0xC0A8FFFF)
- )
- {
- return FALSE;
- }
- return TRUE;
- #endif
- #if 0
-
-
-
-
- if ((ip_addr >> 24 == 0xa) || (ip_addr >> 16 == 0xc0a8) || (ip_addr >> 22 == 0x2b0))
- return FALSE;
- else
- return TRUE;
- #endif
- #if 1
-
- if ((ip_addr >> 24 == 0x0A) || (ip_addr >> 20 == 0xAC1) || (ip_addr >> 16 == 0xC0A8) || (ip_addr >> 26 == 0x7))
- return FALSE;
- else
- return TRUE;
- #endif
- }
- BOOL IsValidIPV4(const TCHAR *szIP)
- {
- int nIndex = 0;
- int nPointCount = 0;
- int nLen = strlen(szIP);
- for (int i = 0; i < nLen; i++)
- {
- if (szIP[i] == '.')
- {
- if (i == 0 || i == nLen - 1)
- {
- return FALSE;
- }
- else
- {
- if (++nIndex != i)
- {
- nIndex = i;
- nPointCount++;
- }
- else
- return FALSE;
- }
- continue;
- }
- if (isdigit(szIP[i]) == 0)
- return FALSE;
- }
- if (nPointCount != 3)
- return FALSE;
- return TRUE;
- }
- int GetHostAllOfIP(const TCHAR *pHostName, std::vector<std::string> &vtHostIPV4)
- {
- #if 0
- WSADATA wsa = { 0 };
- WSAStartup(MAKEWORD(2, 2), &wsa);
- #endif
- #if 0
- addrinfo hint, *answer, *curr;
- memset(&hint, 0, sizeof(addrinfo));
- hint.ai_family = AF_INET;
- hint.ai_socktype = SOCK_STREAM;
- int nRet = GetAddrInfo(pHostName, NULL, &hint, &answer);
-
- if (nRet != 0)
- {
- DWORD dwError = GetLastError();
- return;
- }
- TCHAR szIP[MAX_PATH];
- for (curr = answer; curr != NULL; curr = curr->ai_next)
- {
-
- memset(szIP, 0, MAX_PATH);
- inet_ntop(AF_INET, &(((sockaddr_in*)(curr->ai_addr))->sin_addr), szIP, MAX_PATH);
- vtHostIPV4.push_back(szIP);
- }
- freeaddrinfo(answer);
- #endif
- return 0;
- }
- void DataToArray(CArray<CStringArray, CStringArray>*pArrayOfString, int datapos)
- {
- try
- {
- pArrayOfString->RemoveAll();
- if (g_nLeng == 0)
- {
- return;
- }
-
- if (g_sendhead.code[0])
- {
-
- BYTE *lpszOut = NULL;
- int nOutSize = 0;
- LZARI Lzari;
- Lzari.UnCompress(g_pData, g_nLeng, lpszOut, nOutSize);
-
- CMemFile memfile;
- memfile.Attach(lpszOut, nOutSize);
- Lzari.Release();
-
- CArchive ar(&memfile, CArchive::load);
- pArrayOfString->SetSize(g_sendhead.count[0]);
-
- for (int ii = 0; ii < pArrayOfString->GetSize(); ii++)
- {
- pArrayOfString->ElementAt(ii).Serialize(ar);
- }
-
- ar.Close();
- memfile.Detach();
- }
- else
- {
- CMemFile memfile;
- memfile.Attach(g_pData, g_nLeng);
- CArchive ar(&memfile, CArchive::load);
- pArrayOfString->SetSize(g_sendhead.count[0]);
- for (int ii = 0; ii < pArrayOfString->GetSize(); ii++)
- {
- pArrayOfString->ElementAt(ii).Serialize(ar);
- }
- ar.Close();
- memfile.Detach();
- }
- }
- catch (...)
- {
- }
- }
- void DataToArray(
- CArray<CStringArray, CStringArray>*pArrayOfString1,
- CArray<CStringArray, CStringArray>*pArrayOfString2,
- int datapos)
- {
- try
- {
- CArray<CStringArray, CStringArray>*parray[2] = { pArrayOfString1, pArrayOfString2 };
- DWORD bytereads = 0;
- for (int i = 0; i < 2; i++)
- {
- parray[i]->RemoveAll();
- if (g_sendhead.length[i] == 0)
- continue;
- if (g_sendhead.code[i])
- {
-
- BYTE *lpszOut = NULL;
- int nOutSize = 0;
- LZARI Lzari;
- Lzari.UnCompress(g_pData + bytereads, g_sendhead.length[i], lpszOut, nOutSize);
-
- CMemFile memfile;
- memfile.Attach(lpszOut, nOutSize);
- Lzari.Release();
-
- bytereads += g_sendhead.length[i];
- CArchive ar(&memfile, CArchive::load);
- parray[i]->SetSize(g_sendhead.count[i]);
-
- for (int ii = 0; ii < parray[i]->GetSize(); ii++)
- {
- parray[i]->ElementAt(ii).Serialize(ar);
- }
-
- ar.Close();
- memfile.Detach();
- }
- else
- {
- CMemFile memfile;
- memfile.Attach(g_pData + bytereads, g_sendhead.length[i]);
- bytereads += g_sendhead.length[i];
- CArchive ar(&memfile, CArchive::load);
- parray[i]->SetSize(g_sendhead.count[i]);
- for (int ii = 0; ii < parray[i]->GetSize(); ii++)
- {
- parray[i]->ElementAt(ii).Serialize(ar);
- }
- ar.Close();
- memfile.Detach();
- }
- }
- }
- catch (...)
- {
- }
- }
- void DataToArray(
- CArray<CStringArray, CStringArray>*pArrayOfString1,
- CArray<CStringArray, CStringArray>*pArrayOfString2,
- CArray<CStringArray, CStringArray>*pArrayOfString3,
- int datapos)
- {
- try
- {
- CArray<CStringArray, CStringArray>*parray[3] = { pArrayOfString1, pArrayOfString2, pArrayOfString3 };
- DWORD bytereads = 0;
- for (int i = 0; i < 3; i++)
- {
- parray[i]->RemoveAll(); if (g_sendhead.length[i] == 0)continue;
- if (g_sendhead.code[i])
- {
- BYTE *lpszOut = NULL;
- int nOutSize = 0;
- LZARI Lzari;
- Lzari.UnCompress(g_pData + bytereads, g_sendhead.length[i], lpszOut, nOutSize);
- CMemFile memfile;
- memfile.Attach(lpszOut, nOutSize);
- Lzari.Release();
- bytereads += g_sendhead.length[i];
- CArchive ar(&memfile, CArchive::load);
- parray[i]->SetSize(g_sendhead.count[i]);
- for (int ii = 0; ii < parray[i]->GetSize(); ii++)
- {
- parray[i]->ElementAt(ii).Serialize(ar);
- }
- ar.Close();
- memfile.Detach();
- }
- else
- {
- CMemFile memfile;
- memfile.Attach(g_pData + bytereads, g_sendhead.length[i]);
- bytereads += g_sendhead.length[i];
- CArchive ar(&memfile, CArchive::load);
- parray[i]->SetSize(g_sendhead.count[i]);
- for (int ii = 0; ii < parray[i]->GetSize(); ii++)
- {
- parray[i]->ElementAt(ii).Serialize(ar);
- }
- ar.Close();
- memfile.Detach();
- }
- }
- }
- catch (...)
- {
- }
- }
- void DataToArray(
- CArray<CStringArray, CStringArray>*pArrayOfString1,
- CArray<CStringArray, CStringArray>*pArrayOfString2,
- CArray<CStringArray, CStringArray>*pArrayOfString3,
- CArray<CStringArray, CStringArray>*pArrayOfString4,
- int datapos)
- {
- try
- {
- CArray<CStringArray, CStringArray>*parray[4] =
- {
- pArrayOfString1,
- pArrayOfString2,
- pArrayOfString3,
- pArrayOfString4
- };
- DWORD bytereads = 0;
- for (int i = 0; i < 4; i++)
- {
- parray[i]->RemoveAll(); if (g_sendhead.length[i] == 0)continue;
- if (g_sendhead.code[i])
- {
- BYTE *lpszOut = NULL;
- int nOutSize = 0;
- LZARI Lzari;
- Lzari.UnCompress(g_pData + bytereads, g_sendhead.length[i], lpszOut, nOutSize);
- CMemFile memfile;
- memfile.Attach(lpszOut, nOutSize);
- Lzari.Release();
- bytereads += g_sendhead.length[i];
- CArchive ar(&memfile, CArchive::load);
- parray[i]->SetSize(g_sendhead.count[i]);
- for (int ii = 0; ii < parray[i]->GetSize(); ii++)
- {
- parray[i]->ElementAt(ii).Serialize(ar);
- }
- ar.Close();
- memfile.Detach();
- }
- else
- {
- CMemFile memfile;
- memfile.Attach(g_pData + bytereads, g_sendhead.length[i]);
- bytereads += g_sendhead.length[i];
- CArchive ar(&memfile, CArchive::load);
- parray[i]->SetSize(g_sendhead.count[i]);
- for (int ii = 0; ii < parray[i]->GetSize(); ii++)
- {
- parray[i]->ElementAt(ii).Serialize(ar);
- }
- ar.Close();
- memfile.Detach();
- }
- }
- }
- catch (...)
- {
- }
- }
- void DataToArray(
- CArray<CStringArray, CStringArray>*pArrayOfString1,
- CArray<CStringArray, CStringArray>*pArrayOfString2,
- CArray<CStringArray, CStringArray>*pArrayOfString3,
- CArray<CStringArray, CStringArray>*pArrayOfString4,
- CArray<CStringArray, CStringArray>*pArrayOfString5,
- int datapos)
- {
- try
- {
- CArray<CStringArray, CStringArray>*parray[5] =
- {
- pArrayOfString1,
- pArrayOfString2,
- pArrayOfString3,
- pArrayOfString4,
- pArrayOfString5
- };
- DWORD bytereads = 0;
- for (int i = 0; i < 5; i++)
- {
- parray[i]->RemoveAll();
- if (g_sendhead.length[i] == 0)
- continue;
- if (g_sendhead.code[i])
- {
- BYTE *lpszOut = NULL;
- int nOutSize = 0;
- LZARI Lzari;
- Lzari.UnCompress(g_pData + bytereads, g_sendhead.length[i], lpszOut, nOutSize);
- CMemFile memfile;
- memfile.Attach(lpszOut, nOutSize);
- Lzari.Release();
- bytereads += g_sendhead.length[i];
- CArchive ar(&memfile, CArchive::load);
- parray[i]->SetSize(g_sendhead.count[i]);
- for (int ii = 0; ii < parray[i]->GetSize(); ii++)
- {
- parray[i]->ElementAt(ii).Serialize(ar);
- }
- ar.Close();
- memfile.Detach();
- }
- else
- {
- CMemFile memfile;
- memfile.Attach(g_pData + bytereads, g_sendhead.length[i]);
- bytereads += g_sendhead.length[i];
- CArchive ar(&memfile, CArchive::load);
- parray[i]->SetSize(g_sendhead.count[i]);
- for (int ii = 0; ii < parray[i]->GetSize(); ii++)
- {
- parray[i]->ElementAt(ii).Serialize(ar);
- }
- ar.Close();
- memfile.Detach();
- }
- }
- }
- catch (...)
- {
- }
- }
- void DataToArray(
- CArray<CStringArray, CStringArray>*pArrayOfString1,
- CArray<CStringArray, CStringArray>*pArrayOfString2,
- CArray<CStringArray, CStringArray>*pArrayOfString3,
- CArray<CStringArray, CStringArray>*pArrayOfString4,
- CArray<CStringArray, CStringArray>*pArrayOfString5,
- CArray<CStringArray, CStringArray>*pArrayOfString6,
- int datapos)
- {
- try
- {
- CArray<CStringArray, CStringArray>*parray[6] =
- {
- pArrayOfString1,
- pArrayOfString2,
- pArrayOfString3,
- pArrayOfString4,
- pArrayOfString5,
- pArrayOfString6
- };
- DWORD bytereads = 0;
- for (int i = 0; i < 6; i++)
- {
- parray[i]->RemoveAll();
- if (g_sendhead.length[i] == 0)continue;
- if (g_sendhead.code[i])
- {
- BYTE *lpszOut = NULL;
- int nOutSize = 0;
- LZARI Lzari;
- Lzari.UnCompress(g_pData + bytereads, g_sendhead.length[i], lpszOut, nOutSize);
- CMemFile memfile;
- memfile.Attach(lpszOut, nOutSize);
- Lzari.Release();
- bytereads += g_sendhead.length[i];
- CArchive ar(&memfile, CArchive::load);
- parray[i]->SetSize(g_sendhead.count[i]);
- for (int ii = 0; ii < parray[i]->GetSize(); ii++)
- {
- parray[i]->ElementAt(ii).Serialize(ar);
- }
- ar.Close();
- memfile.Detach();
- }
- else
- {
- CMemFile memfile;
- memfile.Attach(g_pData + bytereads, g_sendhead.length[i]);
- bytereads += g_sendhead.length[i];
- CArchive ar(&memfile, CArchive::load);
- parray[i]->SetSize(g_sendhead.count[i]);
- for (int ii = 0; ii < parray[i]->GetSize(); ii++)
- {
- parray[i]->ElementAt(ii).Serialize(ar);
- }
- ar.Close();
- memfile.Detach();
- }
- }
- }
- catch (...)
- {
- }
- }
- void DataToArray(
- CArray<CStringArray, CStringArray>*pArrayOfString1,
- CArray<CStringArray, CStringArray>*pArrayOfString2,
- CArray<CStringArray, CStringArray>*pArrayOfString3,
- CArray<CStringArray, CStringArray>*pArrayOfString4,
- CArray<CStringArray, CStringArray>*pArrayOfString5,
- CArray<CStringArray, CStringArray>*pArrayOfString6,
- CArray<CStringArray, CStringArray>*pArrayOfString7,
- int datapos)
- {
- try
- {
- CArray<CStringArray, CStringArray>*parray[7] =
- {
- pArrayOfString1,
- pArrayOfString2,
- pArrayOfString3,
- pArrayOfString4,
- pArrayOfString5,
- pArrayOfString6,
- pArrayOfString7
- };
- DWORD bytereads = 0;
- for (int i = 0; i < 7; i++)
- {
- parray[i]->RemoveAll();
- if (g_sendhead.length[i] == 0)continue;
- if (g_sendhead.code[i])
- {
- BYTE *lpszOut = NULL;
- int nOutSize = 0;
- LZARI Lzari;
- Lzari.UnCompress(g_pData + bytereads, g_sendhead.length[i], lpszOut, nOutSize);
- CMemFile memfile;
- memfile.Attach(lpszOut, nOutSize);
- Lzari.Release();
- bytereads += g_sendhead.length[i];
- CArchive ar(&memfile, CArchive::load);
- parray[i]->SetSize(g_sendhead.count[i]);
- for (int ii = 0; ii < parray[i]->GetSize(); ii++)
- {
- parray[i]->ElementAt(ii).Serialize(ar);
- }
- ar.Close();
- memfile.Detach();
- }
- else
- {
- CMemFile memfile;
- memfile.Attach(g_pData + bytereads, g_sendhead.length[i]);
- bytereads += g_sendhead.length[i];
- CArchive ar(&memfile, CArchive::load);
- parray[i]->SetSize(g_sendhead.count[i]);
- for (int ii = 0; ii < parray[i]->GetSize(); ii++)
- {
- parray[i]->ElementAt(ii).Serialize(ar);
- }
- ar.Close();
- memfile.Detach();
- }
- }
- }
- catch (...)
- {
- }
- }
- void DataToArray(
- CArray<CStringArray, CStringArray>*pArrayOfString1,
- CArray<CStringArray, CStringArray>*pArrayOfString2,
- CArray<CStringArray, CStringArray>*pArrayOfString3,
- CArray<CStringArray, CStringArray>*pArrayOfString4,
- CArray<CStringArray, CStringArray>*pArrayOfString5,
- CArray<CStringArray, CStringArray>*pArrayOfString6,
- CArray<CStringArray, CStringArray>*pArrayOfString7,
- CArray<CStringArray, CStringArray>*pArrayOfString8,
- int datapos)
- {
- try
- {
- CArray<CStringArray, CStringArray>*parray[8] =
- {
- pArrayOfString1,
- pArrayOfString2,
- pArrayOfString3,
- pArrayOfString4,
- pArrayOfString5,
- pArrayOfString6,
- pArrayOfString7,
- pArrayOfString8
- };
- DWORD bytereads = 0;
- for (int i = 0; i < 8; i++)
- {
- parray[i]->RemoveAll();
- if (g_sendhead.length[i] == 0)continue;
- if (g_sendhead.code[i])
- {
- BYTE *lpszOut = NULL;
- int nOutSize = 0;
- LZARI Lzari;
- Lzari.UnCompress(g_pData + bytereads, g_sendhead.length[i], lpszOut, nOutSize);
- CMemFile memfile;
- memfile.Attach(lpszOut, nOutSize);
- Lzari.Release();
- bytereads += g_sendhead.length[i];
- CArchive ar(&memfile, CArchive::load);
- parray[i]->SetSize(g_sendhead.count[i]);
- for (int ii = 0; ii < parray[i]->GetSize(); ii++)
- {
- parray[i]->ElementAt(ii).Serialize(ar);
- }
- ar.Close();
- memfile.Detach();
- }
- else
- {
- CMemFile memfile;
- memfile.Attach(g_pData + bytereads, g_sendhead.length[i]);
- bytereads += g_sendhead.length[i];
- CArchive ar(&memfile, CArchive::load);
- parray[i]->SetSize(g_sendhead.count[i]);
- for (int ii = 0; ii < parray[i]->GetSize(); ii++)
- {
- parray[i]->ElementAt(ii).Serialize(ar);
- }
- ar.Close();
- memfile.Detach();
- }
- }
- }
- catch (...)
- {
- }
- }
- void DataToArray(
- CArray<CStringArray, CStringArray>*pArrayOfString1,
- CArray<CStringArray, CStringArray>*pArrayOfString2,
- CArray<CStringArray, CStringArray>*pArrayOfString3,
- CArray<CStringArray, CStringArray>*pArrayOfString4,
- CArray<CStringArray, CStringArray>*pArrayOfString5,
- CArray<CStringArray, CStringArray>*pArrayOfString6,
- CArray<CStringArray, CStringArray>*pArrayOfString7,
- CArray<CStringArray, CStringArray>*pArrayOfString8,
- CArray<CStringArray, CStringArray>*pArrayOfString9,
- CArray<CStringArray, CStringArray>*pArrayOfString10,
- int datapos)
- {
- try
- {
- CArray<CStringArray, CStringArray>*parray[10] =
- {
- pArrayOfString1,
- pArrayOfString2,
- pArrayOfString3,
- pArrayOfString4,
- pArrayOfString5,
- pArrayOfString6,
- pArrayOfString7,
- pArrayOfString8,
- pArrayOfString9,
- pArrayOfString10
- };
- DWORD bytereads = 0;
- for (int i = 0; i < 10; i++)
- {
- parray[i]->RemoveAll();
- if (g_sendhead.length[i] == 0)continue;
- if (g_sendhead.code[i])
- {
- BYTE *lpszOut = NULL;
- int nOutSize = 0;
- LZARI Lzari;
- Lzari.UnCompress(g_pData + bytereads, g_sendhead.length[i], lpszOut, nOutSize);
- CMemFile memfile;
- memfile.Attach(lpszOut, nOutSize);
- Lzari.Release();
- bytereads += g_sendhead.length[i];
- CArchive ar(&memfile, CArchive::load);
- parray[i]->SetSize(g_sendhead.count[i]);
- for (int ii = 0; ii < parray[i]->GetSize(); ii++)
- {
- parray[i]->ElementAt(ii).Serialize(ar);
- }
- ar.Close();
- memfile.Detach();
- }
- else
- {
- CMemFile memfile;
- memfile.Attach(g_pData + bytereads, g_sendhead.length[i]);
- bytereads += g_sendhead.length[i];
- CArchive ar(&memfile, CArchive::load);
- parray[i]->SetSize(g_sendhead.count[i]);
- for (int ii = 0; ii < parray[i]->GetSize(); ii++)
- {
- parray[i]->ElementAt(ii).Serialize(ar);
- }
- ar.Close();
- memfile.Detach();
- }
- }
- }
- catch (...)
- {
- }
- }
- void LoadImageFromBuf(Bitmap **img, BYTE *pData, DWORD leng)
- {
- try
- {
- if (pData == NULL)return;
- if (*img)delete *img;
- *img = NULL;
-
- HGLOBAL m_hMem = GlobalAlloc(GMEM_MOVEABLE, leng);
- if (m_hMem == NULL)return;
- BYTE* pmem = (BYTE*)GlobalLock(m_hMem);
- memcpy(pmem, pData, leng);
- IStream* pstm;
- CreateStreamOnHGlobal(m_hMem, TRUE, &pstm);
-
- *img = Gdiplus::Bitmap::FromStream(pstm);
-
- GlobalUnlock(m_hMem);
- pstm->Release();
- }
- catch (...)
- {
- }
- }
- void LoadImageFromFile(Image **img, CString path)
- {
- try
- {
- if (!PathFileExists(path))return;
- if (*img)delete *img;
- *img = NULL;
- BSTR bstr = path.AllocSysString();
- *img = Image::FromFile(bstr);
- SysFreeString(bstr);
- }
- catch (...)
- {
- }
- }
- void LoadImageFromFile(Bitmap **img, CString path)
- {
- try
- {
- if (!PathFileExists(path))return;
- if (*img)delete *img;
- *img = NULL;
- BSTR bstr = path.AllocSysString();
- *img = Bitmap::FromFile(bstr);
- SysFreeString(bstr);
- }
- catch (...)
- {
- }
- }
- void LoadImageFromBuf(Image **img, BYTE *pData, DWORD leng)
- {
- try
- {
- if (pData == NULL)return;
- if (*img)delete *img;
- *img = NULL;
-
- HGLOBAL m_hMem = GlobalAlloc(GMEM_MOVEABLE, leng);
- if (m_hMem == NULL)return;
- BYTE* pmem = (BYTE*)GlobalLock(m_hMem);
- memcpy(pmem, pData, leng);
- IStream* pstm;
- CreateStreamOnHGlobal(m_hMem, TRUE, &pstm);
-
- *img = Gdiplus::Image::FromStream(pstm);
-
- GlobalUnlock(m_hMem);
- pstm->Release();
- }
- catch (...)
- {
- }
- }
- void LoadImageFromBuf(Image **img, CString path)
- {
- try
- {
- CFile fp;
- if (fp.Open(path, CFile::modeRead))
- {
- DWORD leng = fp.GetLength();
- BYTE *pData = new BYTE[leng];
- fp.Read(pData, leng);
- fp.Close();
- LoadImageFromBuf(img, pData, leng);
- delete[]pData;
- }
- }
- catch (...)
- {
- }
- }
- void LoadImageFromBuf(Bitmap **img, CString path)
- {
- try
- {
- CFile fp;
- if (fp.Open(path, CFile::modeRead))
- {
- DWORD leng = fp.GetLength();
- BYTE *pData = new BYTE[leng];
- fp.Read(pData, leng);
- fp.Close();
- LoadImageFromBuf(img, pData, leng);
- delete[]pData;
- }
- }
- catch (...)
- {
- }
- }
- void LoadImageFromRes(Image **img, LPCTSTR lpszResourceName, LPCTSTR ResourceType)
- {
- try
- {
- HGLOBAL hGlobal = NULL;
- HRSRC hSource = NULL;
- LPVOID lpVoid = NULL;
- int nSize = 0;
- BOOL bResult = FALSE;
- hSource = FindResource(NULL, lpszResourceName, ResourceType);
- if (hSource == NULL)return;
- hGlobal = LoadResource(NULL, hSource);
- if (hGlobal == NULL)return;
- lpVoid = LockResource(hGlobal);
- if (lpVoid == NULL)return;
- nSize = (UINT)SizeofResource(NULL, hSource);
- LoadImageFromBuf(img, (BYTE*)hGlobal, nSize);
- UnlockResource(hGlobal);
- FreeResource(hGlobal);
- }
- catch (...)
- {
- }
- }
- int GetOrientation(Image *image)
- {
- try
- {
- if (image)
- {
- UINT totalBufferSize;
- UINT numProperties;
- image->GetPropertySize(&totalBufferSize, &numProperties);
-
- PropertyItem* pAllItems = (PropertyItem*)malloc(totalBufferSize);
-
- image->GetAllPropertyItems(totalBufferSize, numProperties, pAllItems);
-
- for (UINT j = 0; j < numProperties; ++j)
- {
- if (PropertyTagOrientation == pAllItems[j].id)
- {
- short* ptrLong = (short*)(pAllItems[j].value);
- int ret = (int)*ptrLong;
- free(pAllItems);
- return ret;
- }
- }
- free(pAllItems);
- }
- }
- catch (...)
- {
- }
- return 1;
- }
- int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
- {
- UINT num = 0;
- UINT size = 0;
- ImageCodecInfo* pImageCodecInfo = NULL;
- GetImageEncodersSize(&num, &size);
- if (size == 0)
- return -1;
- pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
- if (pImageCodecInfo == NULL)
- return -1;
- GetImageEncoders(num, size, pImageCodecInfo);
- for (UINT j = 0; j < num; ++j)
- {
- if (wcscmp(pImageCodecInfo[j].MimeType, format) == 0)
- {
- *pClsid = pImageCodecInfo[j].Clsid;
- free(pImageCodecInfo);
- return j;
- }
- }
- free(pImageCodecInfo);
- return -1;
- }
- void SaveImageToFile(Image *img, CString path)
- {
- try
- {
- if (img == NULL)return;
- CLSID encoderClsid;
- BSTR bstr = path.AllocSysString();
- path.MakeLower();
- if (path.Right(3) == "bmp")
- {
- GetEncoderClsid(L"image/bmp", &encoderClsid);
- img->Save(bstr, &encoderClsid, NULL);
- }
- else if (path.Right(3) == "png")
- {
- GetEncoderClsid(L"image/png", &encoderClsid);
- img->Save(bstr, &encoderClsid, NULL);
- }
- else
- {
- GetEncoderClsid(L"image/jpeg", &encoderClsid);
- EncoderParameters encoderParameters;
- ULONG quality;
- encoderParameters.Count = 1;
- encoderParameters.Parameter[0].Guid = EncoderQuality;
- encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
- encoderParameters.Parameter[0].NumberOfValues = 1;
-
- quality = 100;
- encoderParameters.Parameter[0].Value = &quality;
- img->Save(bstr, &encoderClsid, &encoderParameters);
- }
- SysFreeString(bstr);
- }
- catch (...)
- {
- }
- }
- void SaveImageToFile2(Image *img, CString path, ULONG quality)
- {
- try
- {
- if (img == NULL)return;
- CLSID encoderClsid;
- BSTR bstr = path.AllocSysString();
- path.MakeLower();
- if (path.Right(3) == "bmp")
- {
- GetEncoderClsid(L"image/bmp", &encoderClsid);
- img->Save(bstr, &encoderClsid, NULL);
- }
- else if (path.Right(3) == "png")
- {
- GetEncoderClsid(L"image/png", &encoderClsid);
- img->Save(bstr, &encoderClsid, NULL);
- }
- else
- {
- GetEncoderClsid(L"image/jpeg", &encoderClsid);
- EncoderParameters encoderParameters;
- encoderParameters.Count = 1;
- encoderParameters.Parameter[0].Guid = EncoderQuality;
- encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
- encoderParameters.Parameter[0].NumberOfValues = 1;
-
- encoderParameters.Parameter[0].Value = &quality;
- img->Save(bstr, &encoderClsid, &encoderParameters);
- }
- SysFreeString(bstr);
- }
- catch (...)
- {
- }
- }
- void IsWaiter2(CString id, CString name, CArray<CStringArray, CStringArray>*waiterarray, BOOL &bWait1, BOOL &bWait2, float &fscale1, float &fscale2, BOOL bCheckDate, CString date1, CString date2)
- {
- for (int i = 0; i < waiterarray->GetSize(); i++)
- {
- if (id == waiterarray->ElementAt(i).ElementAt(0))
- {
- if (bCheckDate)
- {
- if (waiterarray->ElementAt(i).ElementAt(21) < date1 || waiterarray->ElementAt(i).ElementAt(21) > date2 || waiterarray->ElementAt(i).ElementAt(22) != "OK")
- {
- bWait1 = bWait2 = 0;
- return;
- }
- }
- if (name == waiterarray->ElementAt(i).ElementAt(1))
- {
- bWait1 = 1;
- fscale1 = atof(waiterarray->ElementAt(i).ElementAt(5)) / 100.0;
- if (fscale1 == 0)fscale1 = 1;
- }
- else if (name == waiterarray->ElementAt(i).ElementAt(2))
- {
- bWait1 = 1;
- fscale1 = atof(waiterarray->ElementAt(i).ElementAt(6)) / 100.0;
- }
- else if (name == waiterarray->ElementAt(i).ElementAt(3))
- {
- bWait1 = 1;
- fscale1 = atof(waiterarray->ElementAt(i).ElementAt(7)) / 100.0;
- }
- else if (name == waiterarray->ElementAt(i).ElementAt(4))
- {
- bWait1 = 1;
- fscale1 = atof(waiterarray->ElementAt(i).ElementAt(8)) / 100.0;
- }
-
- if (name == waiterarray->ElementAt(i).ElementAt(9))
- {
- bWait2 = 1;
- fscale2 = atof(waiterarray->ElementAt(i).ElementAt(13)) / 100.0;
- if (fscale2 == 0)fscale2 = 1;
- }
- else if (name == waiterarray->ElementAt(i).ElementAt(10))
- {
- bWait2 = 1;
- fscale2 = atof(waiterarray->ElementAt(i).ElementAt(14)) / 100.0;
- }
- else if (name == waiterarray->ElementAt(i).ElementAt(11))
- {
- bWait2 = 1;
- fscale2 = atof(waiterarray->ElementAt(i).ElementAt(15)) / 100.0;
- }
- else if (name == waiterarray->ElementAt(i).ElementAt(12))
- {
- bWait2 = 1;
- fscale2 = atof(waiterarray->ElementAt(i).ElementAt(16)) / 100.0;
- }
- return;
- }
- }
- return;
- }
- void IsWaiter3(CString id, CString name, CArray<CStringArray, CStringArray>*waiterarray, BOOL &bWait1, BOOL &bWait2, float &fscale1, float &fscale2)
- {
- bWait1 = bWait2 = 0;
- for (int i = 0; i < waiterarray->GetSize(); i++)
- {
- if (id == waiterarray->ElementAt(i).ElementAt(0))
- {
- if (name == waiterarray->ElementAt(i).ElementAt(17))
- {
- bWait1 = 1;
- fscale1 = atof(waiterarray->ElementAt(i).ElementAt(19)) / 100.0;
- if (fscale1 == 0)fscale1 = 1;
- }
-
- if (name == waiterarray->ElementAt(i).ElementAt(18))
- {
- bWait2 = 1;
- fscale2 = atof(waiterarray->ElementAt(i).ElementAt(20)) / 100.0;
- }
- return;
- }
- }
- return;
- }
- int CheckPhoneType(CString &phoneno)
- {
- if (phoneno.IsEmpty())
- return -1;
- for (int i = 0; i < phoneno.GetLength(); i++)
- {
- if (phoneno.GetAt(i) < '0' || phoneno.GetAt(i) > '9')return -1;
- }
- if (phoneno.GetAt(0) == '1')
- {
- if (phoneno.GetLength() != 11)
- return -1;
- int mobile[] = { 139, 138, 137, 136, 135, 134, 159, 158, 152, 151, 150, 157, 188, 187, 144, 182, 147, 183, 184, 178 };
- int unicom[] = { 130, 131, 132, 155, 156, 186, 185, 176 };
- int telecom[] = { 133, 153, 189, 180, 181, 177 };
- int others[] = { 170 };
- for (i = 0; i < sizeof(mobile) / sizeof(int); i++)
- {
- if (mobile[i] == atoi(phoneno.Left(3)))
- {
- return 0;
- }
- }
- for (i = 0; i < sizeof(unicom) / sizeof(int); i++)
- {
- if (unicom[i] == atoi(phoneno.Left(3)))
- {
- return 1;
- }
- }
- for (i = 0; i < sizeof(telecom) / sizeof(int); i++)
- {
- if (telecom[i] == atoi(phoneno.Left(3)))
- {
- return 2;
- }
- }
- for (i = 0; i < sizeof(others)/sizeof(int);i++)
- {
- if ( others[i] == atoi((phoneno.Left(3))))
- {
- return 3;
- }
- }
- return -1;
- }
- return -1;
- }
- BOOL CheckDateOK(IN CString &str, IN CONST BOOL &bLunanr)
- {
- if (str.IsEmpty())return 1;
- CString tip;
- int i;
- CString demo = CTime::GetCurrentTime().Format("%Y-%m-%d");
- if (str.GetLength() != demo.GetLength())
- goto ll;
-
- if (str.GetAt(4) != '-')
- goto ll;
- if (str.GetAt(7) != '-')
- goto ll;
- for (i = 0; i < str.GetLength(); i++)
- {
- if (i == 4 || i == 7)continue;
- if (str.GetAt(i) < '0' || str.GetAt(i) > '9')
- goto ll;
- }
- #if 1
- if (!bLunanr)
- return IsValidDate(str);
- else
- return IsValidLunanrDate(str);
- #else
- return 1;
- #endif
- ll:
- tip.Format("日期:%s格式错误!\r\n样板:%s", str, demo);
- AfxMessageBox(tip, MB_ICONSTOP);
- return 0;
- }
- BOOL CheckBadWords(CString str, BOOL bMsg)
- {
- CString badwords[165] = { \
- "【call5.me】", \
- "您可拨020", \
- "88btt.com热线400611", \
- "400678165", \
- "海王星", \
- "博天堂", \
- "十八大", \
- "钓鱼岛", \
- "无限次数提款", \
- "广东地和", \
- "利来", \
- "抢劫", \
- "fa lun", \
- "强奸", \
- "dafa", \
- "falun", \
- "SIM卡抽奖", \
- "罢工", \
- "罢课", \
- "暴乱", \
- "婊子", \
- "操你", \
- "操你娘", \
- "蠢猪", \
- "达赖", \
- "打倒", \
- "大法", \
- "大纪元", \
- "弹药", \
- "钓鱼岛", \
- "东突", \
- "东突厥斯坦伊斯兰运动", \
- "发抡", \
- "发仑", \
- "发伦", \
- "发囵", \
- "发沦", \
- "发纶", \
- "发轮", \
- "发论", \
- "法 轮 功", \
- "法.轮.功", \
- "法抡", \
- "法仑", \
- "法伦", \
- "法囵", \
- "法沦", \
- "法纶", \
- "法轮", \
- "法论", \
- "反革命", \
- "反日", \
- "分裂", \
- "干你娘", \
- "功友", \
- "古怪歌", \
- "国研新闻邮件", \
- "黑庄", \
- "宏志", \
- "洪志", \
- "胡锦涛", \
- "鸡巴", \
- "鸡毛信文汇", \
- "妓女", \
- "简鸿章", \
- "江八点", \
- "江独裁", \
- "江泽民", \
- "疆独", \
- "教徒", \
- "锦涛", \
- "靖国神社", \
- "九、评", \
- "九.评", \
- "九码", \
- "九-评", \
- "拉丹", \
- "拉登", \
- "李鹏", \
- "联总之声传单", \
- "灵动卡", \
- "六合彩", \
- "六码", \
- "吕秀莲", \
- "绿色环保手机", \
- "美国之音", \
- "猛料", \
- "迷药", \
- "民运", \
- "民猪", \
- "嫖娼", \
- "迫害", \
- "枪支", \
- "强奸", \
- "窃听器", \
- "人民报", \
- "人民报讯", \
- "人民大众时事参考", \
- "人民内情真相", \
- "人民真实报道", \
- "人权", \
- "日你妈", \
- "日他", \
- "三码", \
- "三陪", \
- "色情", \
- "傻B", \
- "涉日", \
- "十六大", \
- "示威", \
- "他妈的", \
- "台*湾", \
- "特等奖", \
- "天葬", \
- "突厥斯坦", \
- "推翻", \
- "王八蛋", \
- "温家宝", \
- "无能", \
- "香港总部", \
- "小鸡鸡", \
- "新华举报", \
- "新华内情", \
- "新闻封锁", \
- "畜生", \
- "玄`机", \
- "压迫", \
- "淫秽", \
- "银行联合管理局", \
- "印尼伊斯兰祈祷团", \
- "游行", \
- "舆论", \
- "造反", \
- "真善忍", \
- "镇压", \
- "正法", \
- "政变", \
- "政治风波", \
- "中俄边界新约", \
- "中国银联", \
- "中华民国", \
- "中奖", \
- "朱容基", \
- "自焚", \
- "自由运动", \
- "达赖", \
- "套牌", \
- "情妇", \
- "监听", \
- "巴南电信", \
- "合川分公司", \
- "合川电信", \
- "死光", \
- "116114", \
- "北京宝诚", \
- "华盛投资", \
- "名门国际", \
- "利博", \
- "赤橙黄绿", \
- "免佣BJL首发", \
- "洗*码优惠", \
- "【俱乐部】", \
- "18266381922", \
- "回拨卡", \
- "号码百事通推出短信订机票!实时" };
- for (int i = 0; i < 165; i++)
- {
- g_temp = badwords[i];
- if (str.Find(g_temp) != -1)
- {
-
- return 0;
- }
- }
- return 1;
- }
- bool CheckFolderFileExist(CString &strPath)
- {
- CString path = strPath;
- CFile fp;
- if (fp.Open(path, CFile::modeRead))
- {
- fp.Close();
- return 1;
- }
- if (strPath.Right(1) != "\\")
- path += "\\";
- path += "zaqw1234.dat";
-
- #if JEFF_TEST_ON
- if (PathFileExists(path))
- {
- ::DeleteFile(path);
- }
- #else
- ::DeleteFile(path);
- #endif
- if (fp.Open(path, CFile::modeCreate) == 0)
- return 0;
- fp.Close();
- if (PathFileExists(path))
- ::DeleteFile(path);
- return 1;
- }
- int FindArray(CStringArray *pArray, const CString &Str)
- {
- for (int i = 0; i < pArray->GetSize(); i++)
- {
- if (pArray->ElementAt(i) == Str)
- return i;
- }
- return -1;
- }
- void FillLength(CString &str, int length)
- {
- while (str.GetLength() < length)
- str += " ";
- }
- int GetYearPos(int year)
- {
- for (int i = 0; i < g_hisyeararray.GetSize(); i++)
- {
- if (year == atoi(g_hisyeararray.ElementAt(i).ElementAt(0)))
- return i;
- }
- return -1;
- }
- BOOL GIsHalfHZ(const CString &str)
- {
- int len = str.GetLength();
- BOOL IsHalf = FALSE;
- for (int i = 0; i < len; i++)
- {
- if (str.GetAt(i) < 0) IsHalf = !IsHalf;
- }
- return IsHalf;
- }
- void WriteTitle(CString str)
- {
- g_title = str;
- CStdioFile fp;
- fp.Open(g_mainpath + "\\title.txt", CFile::modeWrite | CFile::modeCreate);
- fp.WriteString(str);
- fp.Close();
- }
- CString GetIP(CString branch)
- {
- for (int i = 0; i < g_brancharray.GetSize(); i++)
- {
- if (g_domain == g_brancharray.ElementAt(i).ElementAt(2))
- {
-
- return g_server;
- CString ip = g_serverbak;
- MyGetIPByName(ip);
- return ip;
- }
- if (branch == g_brancharray.ElementAt(i).ElementAt(0))
- {
- return g_brancharray.ElementAt(i).ElementAt(1);
- }
- }
- return "";
- }
- BOOL IsHanZi(CString str)
- {
- TBYTE ucHigh, ucLow;
- for (int i = 0; i < str.GetLength(); i++)
- {
- if ((TBYTE)str[i] < 0x80)
- {
- continue;
- }
- ucHigh = (TBYTE)str[i];
- ucLow = (TBYTE)str[i + 1];
- if (ucHigh < 0xa1 || ucLow < 0xa1)
- {
- continue;
- }
- return 1;
- }
- return 0;
- }
- int GetType(CString str)
- {
- if (IsHanZi(str))return 0;
- BOOL bDigit = 1;
- BOOL bAlpha = 1;
- for (int i = 0; i < str.GetLength(); i++)
- {
- if (!::isdigit(str.GetAt(i)))
-
- bDigit = 0;
- if (!((str.GetAt(i) <= 'z' && str.GetAt(i) >= 'a') || (str.GetAt(i) <= 'Z' && str.GetAt(i) >= 'A')))
-
- bAlpha = 0;
- if (bDigit == 0 && bAlpha == 0)return 0;
- }
- if (bDigit)
- {
-
- return 0;
-
- }
- else if (bAlpha)
- {
- return 2;
- }
- else
- return 0;
- }
- CString FilterBZ(CString &bz)
- {
- bz.Replace("'", "");
-
- if (bz.GetLength() > 1023)
- {
- AfxMessageBox("文字太长, 字符串将被截取!", MB_ICONSTOP);
- bz = bz.Left(1023);
- }
- return bz;
- }
- void RectFitDes(int width, int height, CRect &rc)
- {
- try
- {
- if (width == 0 || height == 0)return;
-
- float fscale = (float)width / (float)height;
-
- float rcscale = ((float)rc.Width()) / ((float)rc.Height());
- int rcwid = rc.Width();
- int rchei = rc.Height();
- int dt = 0;
-
- if (rcscale < fscale)
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
- dt = (rchei - rcwid / fscale) / 2;
- rc.top += dt;
- rc.bottom -= dt;
- }
- else
- {
- dt = (rcwid - rchei*fscale) / 2;
- rc.left += dt;
- rc.right -= dt;
- }
- }
- catch (...)
- {
- }
- }
- BOOL IsHasRights(int pos)
- {
- return 1;
- if (g_user.rights.GetLength() > pos)
- {
- BOOL ret = atoi(g_user.rights.Mid(pos, 1));
- if (ret == 0)AfxMessageBox("没有相关权限!", MB_ICONINFORMATION);
- return ret;
- }
- AfxMessageBox("没有相关权限!", MB_ICONINFORMATION);
- return 0;
- }
- BOOL IsHasRights2(int pos)
- {
- return 1;
- if (g_user.rights.GetLength() > pos)
- {
- BOOL ret = atoi(g_user.rights.Mid(pos, 1));
- return ret;
- }
- return 0;
- }
- BOOL IsHasRightsnew(int pos)
- {
- #if JEFF_TEST_OFF
- CString strTest = _T("");
- strTest.Format(_T("%d"), pos);
- AfxMessageBox(strTest);
- return TRUE;
- #else
- if (g_user.rights.GetLength() > pos)
- {
- BOOL ret = atoi(g_user.rights.Mid(pos, 1));
- if (ret == 0)AfxMessageBox("没有相关权限! 请与系统管理员联系!", MB_ICONINFORMATION);
- return ret;
- }
- AfxMessageBox("没有相关权限! 请与系统管理员联系!", MB_ICONINFORMATION);
- #endif
- return 0;
- }
- BOOL IsHasRights2new(int pos)
- {
- #if JEFF_TEST_OFF
- CString strTest = _T("");
- strTest.Format(_T("%d"), pos);
- AfxMessageBox(strTest);
- return TRUE;
- #else
- if (g_user.rights.GetLength() > pos)
- {
- BOOL ret = atoi(g_user.rights.Mid(pos, 1));
- return ret;
- }
- #endif
- return 0;
- }
- BOOL IsHasRightsnew2(int pos, CString rights)
- {
- #if JEFF_TEST_OFF
- CString strTest = _T("");
- strTest.Format(_T("%d,%s"), pos, rights);
- AfxMessageBox(strTest);
- return TRUE;
- #else
- if (rights.GetLength() > pos)
- {
- BOOL ret = atoi(rights.Mid(pos, 1));
- if (ret == 0)AfxMessageBox("没有相关权限! 请与系统管理员联系!", MB_ICONINFORMATION);
- return ret;
- }
- AfxMessageBox("没有相关权限! 请与系统管理员联系!", MB_ICONINFORMATION);
- #endif
- return 0;
- }
- void FirstLetter(int nCode, CString& strLetter)
- {
- if (nCode >= 1601 && nCode < 1637) strLetter = _T("A");
- if (nCode >= 1637 && nCode < 1833) strLetter = _T("B");
- if (nCode >= 1833 && nCode < 2078) strLetter = _T("C");
- if (nCode >= 2078 && nCode < 2274) strLetter = _T("D");
- if (nCode >= 2274 && nCode < 2302) strLetter = _T("E");
- if (nCode >= 2302 && nCode < 2433) strLetter = _T("F");
- if (nCode >= 2433 && nCode < 2594) strLetter = _T("G");
- if (nCode >= 2594 && nCode < 2787) strLetter = _T("H");
- if (nCode >= 2787 && nCode < 3106) strLetter = _T("J");
- if (nCode >= 3106 && nCode < 3212) strLetter = _T("K");
- if (nCode >= 3212 && nCode < 3472) strLetter = _T("L");
- if (nCode >= 3472 && nCode < 3635) strLetter = _T("M");
- if (nCode >= 3635 && nCode < 3722) strLetter = _T("N");
- if (nCode >= 3722 && nCode < 3730) strLetter = _T("O");
- if (nCode >= 3730 && nCode < 3858) strLetter = _T("P");
- if (nCode >= 3858 && nCode < 4027) strLetter = _T("Q");
- if (nCode >= 4027 && nCode < 4086) strLetter = _T("R");
- if (nCode >= 4086 && nCode < 4390) strLetter = _T("S");
- if (nCode >= 4390 && nCode < 4558) strLetter = _T("T");
- if (nCode >= 4558 && nCode < 4684) strLetter = _T("W");
- if (nCode >= 4684 && nCode < 4925) strLetter = _T("X");
- if (nCode >= 4925 && nCode < 5249) strLetter = _T("Y");
- if (nCode >= 5249 && nCode < 5590) strLetter = _T("Z");
- }
- void GetFirstLetter(CString strName, CString& strFirstLetter)
- {
- TBYTE ucHigh, ucLow;
- int nCode;
- CString strRet;
- strFirstLetter.Empty();
- for (int i = 0; i < strName.GetLength(); i++)
- {
- if ((TBYTE)strName[i] < 0x80)
- {
- strRet = strName.Mid(i, 1);
- strRet.MakeUpper();
- strFirstLetter += strRet;
- continue;
- }
- ucHigh = (TBYTE)strName[i];
- ucLow = (TBYTE)strName[i + 1];
- if (ucHigh < 0xa1 || ucLow < 0xa1)
- continue;
- else
-
-
- nCode = (ucHigh - 0xa0) * 100 + ucLow - 0xa0;
- FirstLetter(nCode, strRet);
- strFirstLetter += strRet;
- i++;
- }
- }
- CString newGUID()
- {
- CString str;
- GUID guid;
- CoInitialize(NULL);
- if (S_OK == ::CoCreateGuid(&guid))
- {
- str.Format(
- "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
- guid.Data1,
- guid.Data2,
- guid.Data3,
- guid.Data4[0], guid.Data4[1],
- guid.Data4[2], guid.Data4[3],
- guid.Data4[4], guid.Data4[5],
- guid.Data4[6], guid.Data4[7]);
- }
- CoUninitialize();
- return str.Left(28);
- }
- CString GetNameFromDomain(CString domain)
- {
- for (int i = 0; i < g_brancharray.GetSize(); i++)
- {
- if (domain == g_brancharray.ElementAt(i).ElementAt(2))
- {
- return g_brancharray.ElementAt(i).ElementAt(0);
- }
- }
- return "";
- }
- void ConvertToPrice(CString &str)
- {
- if (str.Find('.') == -1)return;
- str.TrimRight('0');
- str.TrimRight('.');
- }
- int GetLengthEx(CString str)
- {
- wchar_t wstr[500];
- int k = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, str, strlen(str), wstr, 500);
- return k;
- }
- inline int MultiByteLengthConvertToWideCharLength(LPCCH lpString)
- {
- return MultiByteToWideChar(CP_ACP, 0, lpString, -1, NULL, 0);
- }
- BOOL myisdigit(CString str)
- {
- for (int i = 0; i < str.GetLength(); i++)
- {
- if (!::isdigit(str.GetAt(i)))
- return 0;
- }
- return 1;
- }
- DWORD FindAppProcessID(CString path)
- {
- try
- {
- HANDLE handle = ::CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
- PROCESSENTRY32 Info;
- Info.dwSize = sizeof(PROCESSENTRY32);
- path.MakeLower();
- if (::Process32First(handle, &Info))
- {
- do
- {
- CString ss = Info.szExeFile;
- ss.MakeLower();
- if (ss.Find(path) != -1 || (!ss.CompareNoCase(path)))
- {
- ::CloseHandle(handle);
- return Info.th32ProcessID;
- }
- } while (::Process32Next(handle, &Info));
- ::CloseHandle(handle);
- }
- return -1;
- }
- catch (...)
- {
- }
- }
- BOOL isInnerIP(DWORD a_ip)
- {
- BOOL bValid = 0;
- if ((a_ip >> 24 == 0xa) || (a_ip >> 16 == 0xc0a8) || (a_ip >> 22 == 0x2b0))
- {
- bValid = 1;
- }
- return bValid;
- }
- void MyGetIPByName2(CString &name)
- {
- CString strIP = name;
- name.Empty();
- DWORD dwServerIP = 0;
- HOSTENT *host = gethostbyname(strIP);
- struct in_addr addr;
- if (host != NULL)
- {
- for (int i = 0; host->h_addr_list[i] != NULL; i++)
- {
- memset(&addr, 0, sizeof(addr));
- memcpy(&addr.S_un.S_addr, host->h_addr_list[i], host->h_length);
- dwServerIP = ntohl(addr.S_un.S_addr);
- BYTE* pIP = (BYTE*)&dwServerIP;
- name.Format(_T("%d.%d.%d.%d"), pIP[3], pIP[2], pIP[1], pIP[0]);
- }
- }
- }
- void MyGetIPByName(CString &name)
- {
- g_serverarray.RemoveAll();
- CString strIP = name;
- name.Empty();
- DWORD dwServerIP = 0;
- HOSTENT *host = gethostbyname(strIP);
- struct in_addr addr;
- if (host != NULL)
- {
-
- for (int i = 0; host->h_addr_list[i] != NULL; i++)
- {
- memset(&addr, 0, sizeof(addr));
- memcpy(&addr.S_un.S_addr, host->h_addr_list[i], host->h_length);
- dwServerIP = ntohl(addr.S_un.S_addr);
- BYTE* pIP = (BYTE*)&dwServerIP;
- name.Format(_T("%d.%d.%d.%d"), pIP[3], pIP[2], pIP[1], pIP[0]);
- g_serverarray.Add(name);
- }
- }
- while (g_serverarray.GetSize() > 1)
- {
- CString name;
- BOOL bFind = 0;
- for (int i = 0; i < g_serverarray.GetSize(); i++)
- {
- DWORD dwServerIP = inet_addr(g_serverarray.ElementAt(i));
- dwServerIP = htonl(dwServerIP);
- if (isInnerIP(dwServerIP) == 0)
- {
-
- g_serverarray.RemoveAt(i);
- bFind = 1;
- break;
- }
-
-
- }
- if (bFind == 0)
- {
- break;
- }
- }
- }
- int IsExistFolder(char *szPath)
- {
- if ((_access(szPath, 0)) != -1)
- {
-
-
- if ((_access(szPath, 2)) != -1)
- {
-
- CString str;
- str.Format("共享文件夹<%s>: 存在!\n", szPath);
- WriteClientLog(str);
- return 1;
- }
-
-
-
-
-
-
-
-
- }
- else
- {
-
- CString str;
- str.Format("◆共享文件夹<%s>: 不存在,请设置共享或访问权限!◆\n", szPath);
- WriteClientLog(str);
- return -1;
- }
- }
- CString GetW(CString str)
- {
- int x = atoi(str);
- if (x > 9999)
- {
- str.Format("%d", x);
- str = str.Right(5);
- str = str.Left(1);
- return str;
- }
- return "";
- }
- CString GetK(CString str)
- {
- int x = atoi(str);
- if (x > 999)
- {
- str.Format("%d", x);
- str = str.Right(4);
- str = str.Left(1);
- return str;
- }
- return "";
- }
- CString GetB(CString str)
- {
- int x = atoi(str);
- if (x > 99)
- {
- str.Format("%d", x);
- str = str.Right(3);
- str = str.Left(1);
- return str;
- }
- return "";
- }
- CString GetS(CString str)
- {
- int x = atoi(str);
- if (x > 9)
- {
- str.Format("%d", x);
- str = str.Right(2);
- str = str.Left(1);
- return str;
- }
- return "";
- }
- CString GetG(CString str)
- {
- int x = atoi(str);
- if (x > 0)
- {
- str.Format("%d", x);
- str = str.Right(1);
- return str;
- }
- return "";
- }
- CString GetHMoney(CString str)
- {
- if (str.IsEmpty())return "";
- if (str == "0")return "零";
- if (atoi(str) < 1 || atoi(str) > 9)return "";
- CString ret[] = { "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
- return ret[atoi(str) - 1];
- }
- BOOL CheckDateOK2(CString str)
- {
- if (str.IsEmpty())return 0;
- CString tip;
- int i;
- CString demo = CTime::GetCurrentTime().Format("%Y-%m-%d");
- if (str.GetLength() != demo.GetLength())
- goto ll;
-
- if (str.GetAt(4) != '-')
- goto ll;
- if (str.GetAt(7) != '-')
- goto ll;
- for (i = 0; i < str.GetLength(); i++)
- {
- if (i == 4 || i == 7)continue;
- if (str.GetAt(i) < '0' || str.GetAt(i) > '9')
- goto ll;
- }
- return 1;
- ll:
- return 0;
- }
- CString GetDomainFromBranch(CString branch)
- {
- if (branch.IsEmpty())return "";
- for (int i = 0; i < g_brancharray.GetSize(); i++)
- {
- if (branch == g_brancharray.ElementAt(i).ElementAt(0))
- {
- return g_brancharray.ElementAt(i).ElementAt(2);
- }
- }
- return "";
- }
- CString GetBranchPhotoPath(CString branch)
- {
- if (branch.IsEmpty())return "";
- for (int i = 0; i < g_brancharray.GetSize() - 1; i++)
- {
- if (branch == g_brancharray.ElementAt(i).ElementAt(0))
- {
- return "\\" + g_brancharray.ElementAt(i).ElementAt(2);
- }
- }
- return "";
- }
- CTime GetTmFromStr(CString date)
- {
- try
- {
- CTime tm(atoi(date.Mid(0, 4)), atoi(date.Mid(5, 2)), atoi(date.Mid(8, 2)), 0, 0, 0);
- CString ss;
- ss.Format("%d-%d-%d", tm.GetYear(), tm.GetMonth(), tm.GetDay());
- return tm;
- }
- catch (...)
- {
- date = "1980-01-01";
- CTime tm(atoi(date.Mid(0, 4)), atoi(date.Mid(5, 2)), atoi(date.Mid(8, 2)), 0, 0, 0);
- return tm;
- }
- }
- BOOL lyfzCopyFileEx(LPCTSTR lpExistingFileName, LPCTSTR lpNewFileName, const BOOL &bFailIfExists)
- {
-
- if (!bFailIfExists)
- return CopyFile(lpExistingFileName, lpNewFileName, bFailIfExists);
-
- TCHAR szNewFileName[_MAX_PATH] = { 0 };
- TCHAR szDrive[_MAX_DRIVE] = { 0 };
- TCHAR szDir[_MAX_DIR] = { 0 };
- TCHAR szFna[_MAX_FNAME] = { 0 };
- TCHAR szExt[_MAX_EXT] = { 0 };
- sprintf(szNewFileName, "%s", lpNewFileName);
- _tsplitpath(szNewFileName, szDrive, szDir, szFna, szExt);
- int nIndex = 1;
- while (PathFileExists(szNewFileName))
- {
- sprintf(szNewFileName, "%s%s%s (%d)%s", szDrive, szDir, szFna, nIndex++, szExt);
- }
- return CopyFile(lpExistingFileName, szNewFileName, bFailIfExists);
- }
- void lyfzImportImage(LPCTSTR lpDestDirectory, CStringArray &strArrayOfImage, const BOOL &bFailIfExists)
- {
-
- int nlen = strlen(lpDestDirectory);
- TCHAR szNewFileName[_MAX_PATH] = { 0 };
- TCHAR szTempDirectory[_MAX_PATH] = { 0 };
- if (lpDestDirectory[nlen - 1] != '\\')
- sprintf(szTempDirectory, "%s\\", lpDestDirectory);
- else
- sprintf(szTempDirectory, "%s", lpDestDirectory);
-
- lyfzCreateDirectory(szTempDirectory);
-
- CString strImage;
- INT_PTR nSize = strArrayOfImage.GetSize();
- for (INT_PTR i = 0; i < nSize; i++)
- {
- strImage = strArrayOfImage.ElementAt(i);
- strImage = strImage.Mid(strImage.ReverseFind('\\') + 1);
-
- sprintf(szNewFileName, "%s%s", szTempDirectory, strImage);
- lyfzCopyFileEx(szNewFileName, strArrayOfImage.ElementAt(i), bFailIfExists);
- }
- }
- BOOL lyfzCreateDirectory(LPCTSTR lpDestDirectory)
- {
- BOOL bExists = FALSE;
- TCHAR szNewFileName[_MAX_PATH] = { 0 };
- TCHAR szDrive[_MAX_DRIVE] = { 0 };
- TCHAR szDir[_MAX_DIR] = { 0 };
- TCHAR szFna[_MAX_FNAME] = { 0 };
- TCHAR szExt[_MAX_EXT] = { 0 };
- int nIndex = 0;
- do
- {
- bExists = PathFileExists(lpDestDirectory);
- if (!bExists)
- {
- memset(szDrive, 0, _MAX_DRIVE);
- memset(szDir, 0, _MAX_DIR);
- memset(szFna, 0, _MAX_FNAME);
- memset(szExt, 0, _MAX_EXT);
- lyfzSplitpath(lpDestDirectory, szDrive, szDir, ++nIndex);
- sprintf(szNewFileName, _T("%s%s"), szDrive, szDir);
- CreateDirectory(szNewFileName, NULL);
-
-
-
-
-
-
- }
- } while (!bExists);
- return TRUE;
- }
- void lyfzSplitpath(const char *path, char *drive, char *dir, const int &nTimes)
- {
- int nlen = strlen(path);
- int i = 0;
- int npoint = 0;
- int nsprit = 0;
- int ncolon = 0;
- int ntimes = -1;
- while (nlen > i++)
- {
- if (path[i] == ':')
- ncolon = i;
- else if (path[i] == '\\')
- {
- if (nTimes == ntimes++) break;
- nsprit = i;
- }
- }
- memcpy(drive, path, ncolon + 1);
- memcpy(dir, &path[ncolon + 1], nsprit - ncolon);
- }
- void ShowSystemErrorInfo(CString &strDescription, const DWORD &dwError)
- {
- #if 0
- LPVOID lpMsgBuf;
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- dwError,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR)&lpMsgBuf,
- 0, NULL);
-
- CString strDisplay;
- strDisplay.Format("失败错误码=%d,Windows内部描述:%s", dwError, lpMsgBuf);
- strDescription += strDisplay;
- AfxMessageBox(strDescription);
- LocalFree(lpMsgBuf);
- #endif
- LPVOID lpMsgBuf;
- BOOL fOk = FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- dwError,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR)&lpMsgBuf,
- 0, NULL);
- if (!fOk)
- {
-
- HMODULE hDll = LoadLibraryEx(TEXT("netmsg.dll"), NULL, DONT_RESOLVE_DLL_REFERENCES);
- if (hDll != NULL)
- {
- FormatMessage(
- FORMAT_MESSAGE_FROM_HMODULE |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- hDll,
- dwError,
- MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
- (LPTSTR)&lpMsgBuf,
- 0,
- NULL);
- FreeLibrary(hDll);
- }
- }
- if (lpMsgBuf != NULL)
- {
- CString strDisplay;
- strDisplay.Format("%s.错误码=%d,Windows描述:%s", strDescription, dwError, (LPCTSTR)LocalLock(lpMsgBuf));
-
- AfxMessageBox(strDisplay);
- LocalFree(lpMsgBuf);
- }
- else
- {
-
- AfxMessageBox("未知道错误");
- }
- }
- void WriteClientLog(const CString &strLogContent)
- {
- try
- {
- CStdioFile fp;
- CString path = g_mainpath + "\\客户端日志.txt";
- if (PathFileExists(path))
- {
- fp.Open(path, CFile::modeWrite);
- int length = fp.GetLength();
- if (length > 5 * 1024 * 1024)
- {
- fp.Close();
- ::DeleteFile(path);
- return;
- }
- fp.SeekToEnd();
- }
- else
- fp.Open(path, CFile::modeCreate | CFile::modeWrite);
- fp.WriteString(CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S") + " " + strLogContent + "\n");
- fp.Close();
- }
- catch (...)
- {
- }
- }
- BOOL IsDirectoryLegitimate(const CString &strDirectory)
- {
- if (strDirectory.Find('/') != -1 ||
- strDirectory.Find('\\') != -1 ||
- strDirectory.Find(':') != -1 ||
- strDirectory.Find('*') != -1 ||
- strDirectory.Find('?') != -1 ||
- strDirectory.Find('\"') != -1 ||
- strDirectory.Find('>') != -1 ||
- strDirectory.Find('<') != -1 ||
- strDirectory.Find('|') != -1
- )
- return FALSE;
- return TRUE;
- }
- void ExportCutImageToFile(LPCCH lpOrderCutImageInfo, LPCCH lpSrcDirectory, LPCCH lpSaveDirectory)
- {
- if (FALSE == lyfzCreateDirectory(lpSaveDirectory))
- return;
- CStringArray saSrcPhoto;
- GetCountOfOrderFolderPhotoFile(lpSrcDirectory, saSrcPhoto);
- CString strImageName;
- CString strCutScheme;
- CRect rtCut;
- CString strTemp;
- CString strImageInfo(lpOrderCutImageInfo);
- int nIndex = -1;
- do
- {
-
- nIndex = strImageInfo.Find(';');
- strTemp = strImageInfo.Left(nIndex);
- strImageInfo = strImageInfo.Mid(nIndex + 1);
- int SrcImageWid;
- int SrcImageHei;
- int ntempIndex = -1;
- if (nIndex != -1)
- {
- if (FALSE == AnalysisImagInfo(saSrcPhoto,lpSrcDirectory, lpSaveDirectory, strTemp, strImageName, strCutScheme, rtCut))
- continue;
- }
- else
- {
- if (strImageInfo.IsEmpty())
- break;
- AnalysisImagInfo(saSrcPhoto,lpSrcDirectory, lpSaveDirectory, strImageInfo, strImageName, strCutScheme, rtCut);
- break;
- }
- } while (nIndex != -1);
- }
- BOOL AnalysisImagInfo(CStringArray &saSrcPhoto, LPCCH lpSrcDirectory, LPCCH lpSaveDirectory, CString &strImageInfo, CString &strImageName, CString &strCutScheme, CRect &rtCut)
- {
- int ntempIndex = -1;
- strImageName = strImageInfo.Left(3);
- strImageInfo.Delete(0, 4);
- CString strSrcImagePath;
- BOOL bExist = FALSE;
- for (int i = 0; i < saSrcPhoto.GetSize(); i++)
- {
- CString strTemp = saSrcPhoto.ElementAt(i);
- strSrcImagePath = strTemp;
- _splitpath((LPCTSTR)saSrcPhoto.ElementAt(i), NULL, NULL, strTemp.GetBuffer(0), NULL);
- strTemp.ReleaseBuffer();
- if ( strTemp == strImageName)
- {
- bExist = TRUE;
-
- break;
- }
- }
- if (FALSE == bExist)
- return FALSE;
- ntempIndex = strImageInfo.Find(',');
- strCutScheme = strImageInfo.Left(ntempIndex);
- strImageInfo.Delete(0, ntempIndex + 1);
-
- ntempIndex = strImageInfo.Find(',');
- LONG SrcImageWid = _ttol(strImageInfo.Left(ntempIndex));
- strImageInfo.Delete(0, ntempIndex + 1);
-
- ntempIndex = strImageInfo.Find(',');
- LONG SrcImageHei = _ttol(strImageInfo.Left(ntempIndex));
- strImageInfo.Delete(0, ntempIndex + 1);
-
- ntempIndex = strImageInfo.Find(',');
- rtCut.left = _ttol(strImageInfo.Left(ntempIndex));
- strImageInfo.Delete(0, ntempIndex + 1);
-
- ntempIndex = strImageInfo.Find(',');
- rtCut.top = _ttol(strImageInfo.Left(ntempIndex));
- strImageInfo.Delete(0, ntempIndex + 1);
-
- ntempIndex = strImageInfo.Find(',');
- rtCut.right = _ttol(strImageInfo.Left(ntempIndex));
- strImageInfo.Delete(0, ntempIndex + 1);
-
- rtCut.bottom = _ttol(strImageInfo.Left(ntempIndex));
-
-
- Image *SrcImage = NULL;
-
- if (FALSE == PathFileExists(strSrcImagePath))
- {
- AfxMessageBox(_T("相片源文件不存在"));
- return FALSE;
- }
-
- LoadImageFromBuf(&SrcImage, strSrcImagePath);
- if (SrcImage == NULL)
- {
- AfxMessageBox(_T("加载源图片失败"));
- return FALSE;
- }
- int orientation = GetOrientation(SrcImage);
- if (orientation == 8)
- SrcImage->RotateFlip(Rotate270FlipNone);
- else if (orientation == 6)
- SrcImage->RotateFlip(Rotate90FlipNone);
- if (SrcImage->GetWidth() == 0)
- return FALSE;
- float scale = 1.0;
- scale *= (float)SrcImage->GetWidth() / (float)SrcImageWid;
- rtCut.left *= scale;
- rtCut.right *= scale;
- rtCut.top *= scale;
- rtCut.bottom *= scale;
- #if 0
- Graphics graph(SrcImage);
- Pen blackPen(Color(255, 255, 0, 0), 1);
- graph.DrawRectangle(&blackPen, rtCut.left, rtCut.top, rtCut.Width(), rtCut.Height());
- SaveImageToFile(SrcImage, CString(lpSaveDirectory + strImageName + _T(".jpg")));
- delete SrcImage;
- #else
- Bitmap bp(rtCut.Width(), rtCut.Height());
- Graphics *graphic = Graphics::FromImage(&bp);
- graphic->Clear(Color(255, 255, 255, 255));
- graphic->SetInterpolationMode(InterpolationModeHighQualityBicubic);
- graphic->SetSmoothingMode(SmoothingModeHighQuality);
- graphic->SetPixelOffsetMode(PixelOffsetModeHighQuality);
- graphic->SetCompositingMode(CompositingModeSourceOver);
- graphic->SetCompositingQuality(CompositingQualityHighQuality);
- graphic->SetTextRenderingHint(TextRenderingHintAntiAliasGridFit);
- graphic->DrawImage(SrcImage, RectF(0, 0, rtCut.Width(), rtCut.Height()), rtCut.left, rtCut.top, rtCut.Width(), rtCut.Height(), UnitPixel);
- delete SrcImage;
- delete graphic;
-
-
-
-
- SaveImageToFile(&bp, CString(lpSaveDirectory + strImageName + _T(":") + strCutScheme + _T(".jpg")));
- #endif
- return TRUE;
- }
- int GetCountOfOrderFolderPhotoFile( const TCHAR *pOrderFolder, CStringArray &StrPhotoArray)
- {
- CStringArray StrSubFoloderArray;
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCTSTR(pOrderFolder), LPCTSTR(_T("*.*")));
- if (o.count() == 0)
- return 0;
-
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_dir();
- for (it = coo.begin(); it != coo.end(); it++)
- {
- if (FindArray(&StrSubFoloderArray, (*it).c_str()) == -1)
- StrSubFoloderArray.Add((*it).c_str());
- }
- int nIndex = -1;
- CString strOrderNumberImage;
-
-
- for (int n = 0; n < StrSubFoloderArray.GetSize(); n++)
- {
- ffsco op;
- op.dirs(0);
- op.find(LPCTSTR(StrSubFoloderArray.ElementAt(n)), LPCTSTR(_T("*.jpg")));
- ffsco::typeT coo;
- ffsco::typeT::iterator itp;
- coo = op.co_file();
- for (itp = coo.begin(); itp != coo.end(); itp++)
- {
- strOrderNumberImage = (*itp).c_str();
- nIndex = strOrderNumberImage.ReverseFind('\\');
- strOrderNumberImage = strOrderNumberImage.Right(strOrderNumberImage.GetLength() - nIndex -1);
- if (strOrderNumberImage.Left(1) != _T("m") && strOrderNumberImage.Left(1) != _T("s"))
- {
- StrPhotoArray.Add((*itp).c_str());
- }
- }
- }
- return 0;
- }
- VOID GetFileNameFromFullPath(CONST CString &strFullPath, CString &strRet)
- {
-
- if (strFullPath.IsEmpty() || !PathFileExists(strFullPath)) return;
- INT nIndex = strFullPath.ReverseFind(_T('\\'));
-
- }
- BOOL LoadMicroShareLibrary()
- {
- if (g_hlyfzMicroShareDLL == NULL)
- g_hlyfzMicroShareDLL = LoadLibrary(_T("lyfzMicroShare.dll"));
- if (g_hlyfzMicroShareDLL == NULL)
- {
- AfxMessageBox(_T("加载微共享模块失败!"));
- return FALSE;
- }
- g_lyfzCreateShare = (lyfzCreateShare)::GetProcAddress(g_hlyfzMicroShareDLL, "lyfzCreateShare");
- if (!g_lyfzCreateShare)
- {
- FreeLibrary(g_hlyfzMicroShareDLL);
- g_hlyfzMicroShareDLL = NULL;
- AfxMessageBox(_T("加载导入导出模块接口失败!"));
- return FALSE;
- }
- return TRUE;
- }
- void FreeMicroShareLibrary()
- {
- if (g_hlyfzMicroShareDLL)
- FreeLibrary(g_hlyfzMicroShareDLL);
- g_hlyfzMicroShareDLL = NULL;
- g_lyfzCreateShare = NULL;
- }
- BOOL OpenShareDirectory()
- {
-
- if (strcmp(g_szModulePath, _T("")) == 0)
- return FALSE;
- TCHAR szdbcfgFile[MAX_PATH] = { _T("") };
- sprintf(szdbcfgFile, _T("%s%s"), g_szModulePath, _T("dbconfig.dat"));
-
- if (!PathFileExists(szdbcfgFile)) return FALSE;
-
- CFile cf;
- CFileException e;
- if (!cf.Open(szdbcfgFile, CFile::modeRead, &e))
- {
-
- e.ReportError();
- return FALSE;
- }
- DBSAVE dbcfg;
-
- ZeroMemory(&dbcfg, sizeof(DBSAVE));
- INT nCount = cf.Read(&dbcfg, sizeof(DBSAVE));
- if (nCount != sizeof(DBSAVE))
- {
- cf.Close();
- return FALSE;
- }
-
- cf.Close();
-
- TCHAR szHost[51] = {0};
- for (int i = 0; i < 50; i++)
- {
- if (dbcfg.server[i])
- szHost[i] = 500 - dbcfg.server[i];
- if (dbcfg.user[i])
- dbcfg.user[i] = 500 - dbcfg.user[i];
- if (dbcfg.psw[i])
- dbcfg.psw[i] = 500 - dbcfg.psw[i];
- }
- CString strHost = _T("");
- strHost.Format(_T("%s"),szHost);
- strHost.TrimLeft();
- strHost.TrimRight(".");
- strHost.TrimRight();
- if (strHost.Find(".ly.com") == -1 && strHost.Find("192.168.") == -1)
- MyGetIPByName(strHost);
-
- TCHAR szShareOriginal[MAX_PATH] = {_T("")};
- TCHAR szShareEarly[MAX_PATH] = { _T("") };
- TCHAR szShareFurther[MAX_PATH] = { _T("") };
- TCHAR szShareDesign[MAX_PATH] = { _T("") };
- sprintf(szShareOriginal, _T("\\\\%s\\%s"), strHost, _T("客户原片(管理软件)$"));
- sprintf(szShareEarly, _T("\\\\%s\\%s"), strHost, _T("修好的片(管理软件)$"));
- sprintf(szShareFurther, _T("\\\\%s\\%s"), strHost, _T("精修好的片(管理软件)$"));
- sprintf(szShareDesign, _T("\\\\%s\\%s"), strHost, _T("设计好的片(管理软件)$"));
- if (!PathFileExists(szShareOriginal) || !PathFileExists(szShareEarly) ||
- !PathFileExists(szShareFurther) || !PathFileExists(szShareDesign) )
- return FALSE;
- return TRUE;
- }
- BOOL IsValidDate(LPCTSTR lpDate)
- {
- if (lpDate == NULL || _tcscmp(lpDate, _T("")) == 0)
- return FALSE;
- CString strDate = lpDate;
- if (strDate.IsEmpty()) return FALSE;
-
- static int nYear = 0;
- static int nMonth = 0;
- static int nDay = 0;
- nYear = nMonth = nDay = 0;
- nYear = _ttoi(strDate.Left(4));
- nMonth = _ttoi(strDate.Mid(5, 2));
- nDay = _ttoi(strDate.Mid(8, 2));
- CONST static INT nNormalMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
- CONST static INT nLeapMonth[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
- if ((nDay <= 0) || (nDay > 31) || (nMonth <= 0) || (nMonth > 12)) return FALSE;
- if ((nYear % 400 == 0) || (nYear % 4 == 0 && nYear % 100 != 0))
- {
- if (nDay > nLeapMonth[nMonth - 1]) return FALSE;
- }
- else
- {
- if (nDay > nNormalMonth[nMonth - 1]) return FALSE;
- }
- return TRUE;
- }
- BOOL IsValidLunanrDate(LPCTSTR lpDate)
- {
- if (lpDate == NULL || _tcscmp(lpDate, _T("")) == 0)
- return FALSE;
- CString strDate = lpDate;
- if (strDate.IsEmpty()) return FALSE;
- static int lunar_year, lunar_month, lunar_day;
- lunar_year = lunar_month = lunar_day = 0;
- lunar_year = _ttoi(strDate.Left(4));
- lunar_month = _ttoi(strDate.Mid(5, 2));
- lunar_day = _ttoi(strDate.Mid(8, 2));
-
- if (lunar_year <= BEGIN_YEAR || lunar_year > BEGIN_YEAR + NUMBER_YEAR - 1)
- return FALSE;
- if (lunar_month < 1 || lunar_month > 12)
- return FALSE;
-
- int nYearIndex = lunar_year - BEGIN_YEAR;
- int leap_month = (LUNAR_YEARS[nYearIndex] >> 20) & 0xF;
-
- int month_day = 0;
- if ((LUNAR_YEARS[nYearIndex] >> (7 + 13 - lunar_month)) & 0x1)
- month_day = 30;
- else
- month_day = 29;
- if (lunar_day < 0 || lunar_day > month_day)
- return FALSE;
- return TRUE;
- }
|