doscalls.pas 242 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2014 by the Free Pascal development team.
  4. Basic OS/2 constants, types and functions implemented (mostly)
  5. in DOSCALL1.DLL. Only functions available in all 32-bit OS/2
  6. versions (i.e. starting with OS/2 2.0) are included here
  7. to make sure that programs using this unit could still run on
  8. these old versions. Certain functions supported in later versions
  9. which could be emulated on older versions are provided in unit
  10. DosCall2 (using dynamic loading of the respective entry points).
  11. See the file COPYING.FPC, included in this distribution,
  12. for details about the copyright.
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16. **********************************************************************}
  17. {$IFNDEF FPC_DOTTEDUNITS}
  18. unit DosCalls;
  19. {$ENDIF FPC_DOTTEDUNITS}
  20. {***************************************************************************}
  21. interface
  22. {***************************************************************************}
  23. {$IFDEF FPC_DOTTEDUNITS}
  24. uses System.Strings;
  25. {$ELSE FPC_DOTTEDUNITS}
  26. uses Strings;
  27. {$ENDIF FPC_DOTTEDUNITS}
  28. type PString = PShortString;
  29. {$PACKRECORDS 1}
  30. type TByteArray=array[0..$fff0] of byte;
  31. PByteArray=^TByteArray;
  32. TCharArray=array[0..$fff0] of AnsiChar;
  33. PCharArray=^TCharArray;
  34. TWordArray=array[0..$7ff8] of word;
  35. PWordArray=^TWordArray;
  36. {****************************************************************************
  37. Thread related routines.
  38. ****************************************************************************}
  39. type TThreadEntry = function (Param: pointer): cardinal; cdecl;
  40. ThreadEntry = TThreadEntry;
  41. const dtSuspended =1; {Thread is started suspended instead of
  42. started at once.}
  43. dtStack_Commited =2; {Allocate all stack space at once. The
  44. operating system normally allocates more
  45. memory to the stack if the stack grows with
  46. the given stacksize as limit. This has the
  47. restriction that you cannot create a stack
  48. frame > 4 kb. at once. If you want to do
  49. this, or for other reasons you can allocate
  50. the complete stack at once with this flag.}
  51. (* The following for compatibility only *)
  52. CREATE_READY =0; { defect 65437 }
  53. CREATE_SUSPENDED =dtSuspended;
  54. STACK_SPARSE =0;
  55. STACK_COMMITTED =dtStack_Commited;
  56. { Wait option values }
  57. dtWait =0; {Wait until termination.}
  58. dtNoWait =1; {Do not wait. Return with error if not yet
  59. terminated.}
  60. (* The following for compatibility only *)
  61. DCWW_WAIT =dtWait;
  62. DCWW_NOWAIT =dtNoWait;
  63. {Create a new thread.
  64. TID = Thread ID of new thread is returned here.
  65. Address = Thread entry point. The new thread starts executing here.
  66. AParam = This one is passed to the thread entry procedure.
  67. Flags = Flags. Either dtsuspended or dt_stackcommited.
  68. StackSize = Size of the stack of the new thread.}
  69. function DosCreateThread(var TID:longint;Address:TThreadEntry;
  70. AParam:pointer;Flags,StackSize:longint):cardinal;cdecl;
  71. function DosCreateThread (var TID: cardinal; Address: TThreadEntry;
  72. AParam: pointer; Flags, StackSize: cardinal): cardinal; cdecl;
  73. (* Overloaded version for compatibility. *)
  74. function DosCreateThread(var TID:longint;Address:pointer;
  75. AParam:Pointer;Flags,StackSize:longint):cardinal;cdecl;
  76. function DosCreateThread (var TID: cardinal; Address: pointer;
  77. AParam: Pointer; Flags, StackSize: cardinal): cardinal; cdecl;
  78. {Suspend a running thread.}
  79. function DosSuspendThread(TID:cardinal):cardinal; cdecl;
  80. {Resume a suspended thread.}
  81. function DosResumeThread(TID:cardinal):cardinal; cdecl;
  82. {Terminate a specific thread.}
  83. function DosKillThread(TID:cardinal):cardinal; cdecl;
  84. {Wait until a specific thread has ended.
  85. TID = Thread to terminate. Can also be zero. In that case we
  86. wait until the next thread terminates. Its thread ID is
  87. returned back.
  88. Option = Flags. Either dtWait or dtNoWait.}
  89. function DosWaitThread(var TID:longint;Option:longint):cardinal; cdecl;
  90. function DosWaitThread(var TID:cardinal;Option:cardinal):cardinal; cdecl;
  91. {All other threads in the same process are suspended until a
  92. DosExitCritSec.}
  93. function DosEnterCritSec: cardinal; cdecl;
  94. {Resume the other threads again.}
  95. function DosExitCritSec: cardinal; cdecl;
  96. { DosExit codes }
  97. const deThread=0; {Terminate thread only.}
  98. deProcess=1; {Terminate the whole process.}
  99. (* The following for compatibility only *)
  100. Exit_Thread = deThread;
  101. Exit_Process = deProcess;
  102. {Terminate the thread or the program. Never returns, so it's defined as
  103. procedure.}
  104. procedure DosExit(Action,Result:cardinal); cdecl;
  105. type PThreadInfoBlock=^TThreadInfoBlock;
  106. PPThreadInfoBlock=^PThreadInfoBlock;
  107. PSysThreadIB=^TSysThreadIB;
  108. PProcessInfoBlock=^TProcessInfoBlock;
  109. PPProcessInfoBlock=^PProcessInfoBlock;
  110. TThreadInfoBlock=record
  111. Exh_Chain, {Head of exception handler chain.}
  112. Stack, {Pointer to the thread's stack.}
  113. StackLimit:pointer; {Pointer to the thread's stack-end.}
  114. TIB2:PSysThreadIB; {Pointer to system specific thread info.}
  115. Version, {Version of this datastructure.}
  116. Ordinal:cardinal; {Thread ordinal number.}
  117. end;
  118. ThreadInfoBlock=TThreadInfoBlock;
  119. TSysThreadIB=record
  120. TID, {Thread ID.}
  121. Priority, {Low byte of low word: thread priority.
  122. High byte of low word: thread class
  123. 1 = Idle
  124. 2 = Regular
  125. 3 = Time critical
  126. 4 = Server}
  127. Version:cardinal; {Version of this datastructure.}
  128. MCCount, {Must complete count. ??? Info wanted!}
  129. MCForceFlag:word; {Must complete force flag. Info wanted!}
  130. end;
  131. SysThreadIB=TSysThreadIB;
  132. TProcessInfoBlock=record
  133. PID, {Process ID.}
  134. ParentPID, {Parent's process ID.}
  135. HMTE:cardinal; {Module handle of executable program.
  136. ??? Info wanted!}
  137. Cmd, {Command line options.}
  138. Env:PByteArray; {Environment strings.}
  139. flStatus, {1 means that the process is in exit list
  140. processing.}
  141. tType:cardinal; {Type of process:
  142. 0: Full screen protected mode.
  143. 1: DOS emulation.
  144. 2: Windowable full screen protected
  145. mode program.
  146. 3: Presentation manager program.
  147. 4: Detached mode process.}
  148. end;
  149. ProcessInfoBlock=TProcessInfoBlock;
  150. {OS/2 keeps information about the current process and the current thread
  151. is the datastructures TProcessInfoBlock and TThreadInfoBlock. All data
  152. can both be read and be changed. Use DosGetInfoBlocks to get their
  153. address. The service cannot fail, so it is defined as procedure. The
  154. second version of the call might be useful if you only want address of one
  155. of those datastructures, since you can supply nil for the other parameter
  156. then - beware, omitting one of these parameters (passing nil) is only
  157. supported on newer OS/2 versions, and causes SIGSEGV on e.g. OS/2 v2.1!!!}
  158. procedure DosGetInfoBlocks(var ATIB:PThreadInfoBlock;
  159. var APIB:PProcessInfoBlock); cdecl;
  160. procedure DosGetInfoBlocks(PATIB:PPThreadInfoBlock;
  161. PAPIB:PPProcessInfoBlock); cdecl;
  162. {Wait a number of milliseconds. Cannot fail, so it is defined as procedure.}
  163. procedure DosSleep (MSec:cardinal); cdecl;
  164. {Beep the speaker. You do not need to check for an error if you can
  165. guarantee that the frequency is correct.}
  166. function DosBeep(Freq,MS:cardinal):cardinal; cdecl;
  167. {****************************************************************************
  168. Process handling routines.
  169. ****************************************************************************}
  170. { User's Debug Buffer structure }
  171. type PDbgBuf = ^TDbgBuf;
  172. TDbgBuf = record
  173. Pid: cardinal; { Debuggee Process id }
  174. Tid: cardinal; { Debuggee Thread id }
  175. Cmd: longint; { Command or Notification }
  176. Value: longint; { Generic Data Value }
  177. Addr: pointer; { Debuggee Address }
  178. Buffer: pointer; { Debugger Buffer Address }
  179. Len: cardinal; { Length of Range }
  180. index: cardinal; { Generic Identifier Index }
  181. MTE: cardinal; { Module Table Entry Handle }
  182. EAX: cardinal; { Register Set }
  183. ECX: cardinal;
  184. EDX: cardinal;
  185. EBX: cardinal;
  186. ESP: cardinal;
  187. EBP: cardinal;
  188. ESI: cardinal;
  189. EDI: cardinal;
  190. EFlags: cardinal;
  191. EIP: cardinal;
  192. CSLim: cardinal;
  193. CSBase: cardinal;
  194. CSAcc: byte;
  195. CSAtr: byte;
  196. CS: word;
  197. DSLim: cardinal;
  198. DSBase: cardinal;
  199. DSAcc: byte;
  200. DSAtr: byte;
  201. DS: word;
  202. ESLim: cardinal;
  203. ESBase: cardinal;
  204. ESAcc: byte;
  205. ESAtr: byte;
  206. ES: word;
  207. FSLim: cardinal;
  208. FSBase: cardinal;
  209. FSAcc: byte;
  210. FSAtr: byte;
  211. FS: word;
  212. GSLim: cardinal;
  213. GSBase: cardinal;
  214. GSAcc: byte;
  215. GSAtr: byte;
  216. GS: word;
  217. SSLim: cardinal;
  218. SSBase: cardinal;
  219. SSAcc: byte;
  220. SSAtr: byte;
  221. SS: word;
  222. end;
  223. { DosDebug Command Numbers
  224. *
  225. * These numbers are placed in the Cmd field of the uDB on
  226. * entry to DosDebug.
  227. *
  228. * These numbers identify which command DosDebug is requested
  229. * to perform.
  230. *
  231. }
  232. const DBG_C_Null = 0; { Null }
  233. DBG_C_ReadMem = 1; { Read Word }
  234. DBG_C_ReadMem_I = 1; { Read Word }
  235. DBG_C_ReadMem_D = 2; { Read Word (same as 1) }
  236. DBG_C_ReadReg = 3; { Read Register Set }
  237. DBG_C_WriteMem = 4; { Write Word }
  238. DBG_C_WriteMem_I = 4; { Write Word }
  239. DBG_C_WriteMem_D = 5; { Write Word (same as 4) }
  240. DBG_C_WriteReg = 6; { Write Register Set }
  241. DBG_C_Go = 7; { Go }
  242. DBG_C_Term = 8; { Terminate }
  243. DBG_C_SStep = 9; { Single Step }
  244. DBG_C_Stop = 10; { Stop }
  245. DBG_C_Freeze = 11; { Freeze Thread }
  246. DBG_C_Resume = 12; { Resume Thread }
  247. DBG_C_NumToAddr = 13; { Object Number to Address }
  248. DBG_C_ReadCoRegs = 14; { Read Coprocessor Registers }
  249. DBG_C_WriteCoRegs = 15; { Write Coprocessor Registers }
  250. { 16 is reserved }
  251. DBG_C_ThrdStat = 17; { Get Thread Status }
  252. DBG_C_MapROAlias = 18; { Map read-only alias }
  253. DBG_C_MapRWAlias = 19; { Map read-write alias }
  254. DBG_C_UnMapAlias = 20; { Unmap Alias }
  255. DBG_C_Connect = 21; { Connect to Debuggee }
  256. DBG_C_ReadMemBuf = 22; { Read Memory Buffer }
  257. DBG_C_WriteMemBuf = 23; { Write Memory Buffer }
  258. DBG_C_SetWatch = 24; { Set Watchpoint }
  259. DBG_C_ClearWatch = 25; { Clear Watchpoint }
  260. DBG_C_RangeStep = 26; { Range Step }
  261. DBG_C_Continue = 27; { Continue after an Exception }
  262. DBG_C_AddrToObject = 28; { Address to Object }
  263. DBG_C_XchgOpcode = 29; { Exchange opcode and go }
  264. DBG_C_LinToSel = 30; { 32 to 16 conversion A001}
  265. DBG_C_SelToLin = 31; { 16 to 32 conversion A001}
  266. {------ Constants -------------------}
  267. DBG_L_386 = 1;
  268. DBG_O_OBJMTE = $10000000;
  269. {------ Notifications ---------------}
  270. DBG_N_SUCCESS = 0;
  271. DBG_N_ERROR = -1;
  272. DBG_N_ProcTerm = -6;
  273. DBG_N_Exception = -7;
  274. DBG_N_ModuleLoad = -8;
  275. DBG_N_CoError = -9;
  276. DBG_N_ThreadTerm = -10;
  277. DBG_N_AsyncStop = -11;
  278. DBG_N_NewProc = -12;
  279. DBG_N_AliasFree = -13;
  280. DBG_N_Watchpoint = -14;
  281. DBG_N_ThreadCreate = -15;
  282. DBG_N_ModuleFree = -16;
  283. DBG_N_RangeStep = -17;
  284. DBG_X_PRE_FIRST_CHANCE = 0;
  285. DBG_X_FIRST_CHANCE = 1;
  286. DBG_X_LAST_CHANCE = 2;
  287. DBG_X_STACK_INVALID = 3;
  288. DBG_W_Local = $0000001;
  289. DBG_W_Global = $0000002;
  290. DBG_W_Execute = $00010000;
  291. DBG_W_Write = $00020000;
  292. DBG_W_ReadWrite = $00030000;
  293. {You need a heavy manual if you want to know how this procedure works. Used
  294. for writing debuggers.}
  295. function DosDebug (DebugBuf: PDbgBuf):cardinal; cdecl;
  296. function DosDebug (var APDbgBuf: TDbgBuf): cardinal; cdecl;
  297. { codeTerminate values (also passed to ExitList routines) }
  298. const TC_exit = 0;
  299. TC_harderror = 1;
  300. TC_trap = 2;
  301. TC_killprocess = 3;
  302. TC_exception = 4;
  303. { DosExitList options }
  304. const ExLst_Add = 1;
  305. ExLst_Remove = 2;
  306. ExLst_Exit = 3;
  307. type TExitProc=procedure(Reason:cardinal); cdecl;
  308. {Add/remove an exitprocedure to the exit list. Also used to terminate an
  309. exit procedure. An exit procedure will be called on exiting of the program.
  310. OrderCode = One of the EXLST_XXXX constants.
  311. Proc = Address of the exit procedure.
  312. An exit procedure is called with one of the TC_XXXX constants. When it is
  313. done it must call DosExitList with ExLst_Exit.
  314. Exit procedures are called in random order.}
  315. function DosExitList(OrderCode:cardinal;Proc:TExitProc):cardinal; cdecl;
  316. { DosExecPgm options }
  317. const deSync = 0; {Wait until program terminates.}
  318. deAsync = 1; {Do not wait.}
  319. deAsyncResult = 2; {Do not wait. DosWaitChild will follow to
  320. check if process has been terminated. If
  321. you use this, you must use DosWaitChild,
  322. because OS/2 will not free memory that is
  323. allocated for the result codes if you don't.}
  324. deTrace = 3; {For debugging.}
  325. deBackground = 4; {Do not run as child. Run in a separate
  326. session.}
  327. deSuspended = 5; {Child will be loaded, but not executed.}
  328. deAsyncResultDb = 6; {Similar to deAsyncResult, but for debugging.}
  329. (* The following for compatibility only *)
  330. EXEC_SYNC =deSync;
  331. EXEC_ASYNC =deAsync;
  332. EXEC_ASYNCRESULT =deAsyncResult;
  333. EXEC_TRACE =deTrace;
  334. EXEC_BACKGROUND =deBackground;
  335. EXEC_LOAD =deSuspended;
  336. EXEC_ASYNCRESULTDB =deAsyncResultDb;
  337. type TResultCodes=record
  338. case byte of
  339. 0: (
  340. TerminateReason, {0 = Normal termination.
  341. 1 = Critical error.
  342. 2 = Trapped. (GPE, etc.)
  343. 3 = Killed by DosKillProcess.}
  344. ExitCode:cardinal); {Exit code of child.}
  345. 1: (CodeTerminate: cardinal); {For compatibility only}
  346. 2: (PID: cardinal); {Process ID returned for asynchronous execution}
  347. end;
  348. {Execute a program.
  349. ObjName = If a DLL cannot be found, its name will be returned here.
  350. ObjLen = Size of your ObjName buffer.
  351. ExecFlag = One of the deXXXX constants.
  352. Res = See TResultcodes.
  353. Args = Arguments. ASCIIZ strings. End of Args given by an empty
  354. string (#0). First arg must be filename without path and
  355. extension. nil is also allowed.
  356. Env = Environment. ASCIIZ strings. A variable has the format
  357. NAME=CONTENTS. End of Env given by an empty string (#0).
  358. nil is also allowed meaning inherit parent's environment.
  359. FileName = Filename with full path and extension. Is not sensitive
  360. for the PATH environment variable.}
  361. function DosExecPgm(ObjName:PAnsiChar;ObjLen:longint;ExecFlag:cardinal;
  362. Args,Env:PByteArray;var Res:TResultCodes;
  363. FileName:PAnsiChar):cardinal; cdecl;
  364. function DosExecPgm(var ObjName:string;ExecFlag:cardinal;
  365. Args,Env:PByteArray;var Res:TResultCodes;
  366. const FileName:string):cardinal;
  367. const
  368. DCWA_PROCESS = 0;
  369. DCWA_PROCESSTREE = 1;
  370. {Wait until a child process terminated. Sometimes called DosCWait.
  371. Action = 0 = Wait until child terminates (DCWA_PROCESS).
  372. 1 = Wait until child and all its childs terminate
  373. (DCWA_PROCESSTREE).
  374. Option = Flags. Either dtWait or dtNoWait.
  375. Res = See TResultCodes.
  376. TermPID = Process ID that has been terminated. Usefull when
  377. terminating a random process.
  378. PID = Process ID of process to terminate. Use a zero to
  379. terminate a random process.}
  380. function DosWaitChild(Action,Option:longint;var Res:TResultCodes;
  381. var TermPID:longint;PID:longint):cardinal; cdecl;
  382. function DosWaitChild(Action,Option:cardinal;var Res:TResultCodes;
  383. var TermPID:cardinal;PID:cardinal):cardinal; cdecl;
  384. const dpProcess = 0;
  385. dpProcessChilds = 1;
  386. dpThread = 2;
  387. dpSameClass = 0;
  388. dpIdleClass = 1;
  389. dpRegular = 2;
  390. dpTimeCritical = 3;
  391. {Set priority of a thread or all threads in another process.
  392. Scope = 0 = Set for all threads of a process.
  393. 1 = Set for all threads of a process and its childs.
  394. 2 = Set for a thread of the current process.
  395. TrClass = 0 = Do not change class.
  396. 1 = Change to idle time class.
  397. 2 = Change to regular class.
  398. 3 = Change to time-critical class.
  399. Delta = Value to add to priority. Resulting priority must be in
  400. the range 0..31 (Delta itself must be within -31..31).
  401. PortID = Process ID when Scope=0 or 1, thread ID when Scope=2.}
  402. function DosSetPriority(Scope,TrClass: cardinal;Delta:longint;PortID:cardinal):cardinal; cdecl;
  403. {Terminate a process. If the process isn't a child process, it can refuse
  404. to terminate.
  405. Action = 0 = Terminate process and all its childs.
  406. 1 = Terminate process only.
  407. PID = Process ID of process to terminate.}
  408. function DosKillProcess(Action,PID:cardinal):cardinal; cdecl;
  409. const AppTyp_NotSpec = $0000; {Apptype is unknown.}
  410. AppTyp_NotWindowCompat = $0001; {App cannot run in a window.}
  411. AppTyp_WindowCompat = $0002; {App can run in a window.}
  412. AppTyp_WindowAPI = $0003; {App uses PM}
  413. AppTyp_Bound = $0008; {App uses Family API.}
  414. AppTyp_DLL = $0010; {File is a DLL.}
  415. AppTyp_DOS = $0020; {App is a PC-DOS program.}
  416. AppTyp_PhysDrv = $0040; {App is a physical device driver.}
  417. AppTyp_VirtDrv = $0080; {App is virtual device driver.}
  418. AppTyp_ProtDLL = $0100; {File is a protected mode DLL.}
  419. AppTyp_WindowsReal = $0200; {M$ Winslows app, real mode.}
  420. AppTyp_WindowsProt = $0400; {M$ Winslows app, protected mode.}
  421. AppTyp_32bit = $4000; {App is 32 bit.}
  422. {Get the application type of an executable file on disk.
  423. FileName = Name of file to get type from.
  424. Flags = Receives a bitfield using the AppTyp constants.}
  425. function DosQueryAppType(FileName:PAnsiChar;var Flags:longint):cardinal; cdecl;
  426. function DosQueryAppType (FileName: PAnsiChar; var Flags: cardinal): cardinal;
  427. cdecl;
  428. const diPrinter = 0; {Get number of printer (parallel) ports.}
  429. diRS232 = 1; {Get number of serial ports.}
  430. diFloppy = 2; {Get number of floppy drives.}
  431. diCopro = 3; {Get number of FPU's installed (either 0 or 1).}
  432. diSubModel = 4; {??? System submodel type?}
  433. diModel = 5; {??? System model type?}
  434. diAdapter = 6; {0=Monochrome display, 1=other. ??? Does OS/2
  435. support monochrome displays?}
  436. {Get information about attached devices.
  437. DevInfo = Receives requested information.
  438. Item = One of the dixxxx constants.}
  439. function DosDevConfig(var DevInfo:byte;Item:cardinal):cardinal; cdecl;
  440. {****************************************************************************
  441. File handling related routines.
  442. ****************************************************************************}
  443. const MaxPathLength=260;
  444. MaxPathComponent=256;
  445. type TFileLock=record
  446. case boolean of
  447. false: (Offset, Range: longint);
  448. true: (lOffset, lRange: longint);
  449. end;
  450. PFileLock=^TFileLock;
  451. FileLock=TFileLock;
  452. {Lock or unlock an area of a file. Other processes may not access that part
  453. of the file.
  454. Unlock = Area to unlock. (0,0) = Do not unlock.
  455. Lock = Area to lock. (0,0) = Do not lock.
  456. Timeout = Number of miliseconds to wait if another process has locked
  457. the file.
  458. Flags = Bitfield:
  459. Bit 0: 0 = Other processes are denied access.
  460. 1 = Other processes may still read from the area.
  461. Bit 1: 0 = Normal locking mode.
  462. 1 = Atomic mode. Refer IBM's documentation.}
  463. function DosSetFileLocks(Handle:THandle;var Unlock,Lock:TFileLock;
  464. Timeout,Flags: cardinal):cardinal; cdecl;
  465. {Cancel a filelock area.
  466. Handle = File handle.
  467. Lock = Area that is locked now.}
  468. function DosCancelLockRequest(Handle:THandle;var Lock:TFileLock):cardinal;
  469. cdecl;
  470. {Data structures for extended attributes. Reading IBM's documentation is
  471. highly recommended before experimenting with EAs.}
  472. const fEA_needEA=$80;
  473. eaBinary = $fffe;
  474. eaASCII = $fffd;
  475. eaBitmap = $fffb;
  476. eaMetaFile = $fffa;
  477. eaIcon = $fff9;
  478. eaEA = $ffee;
  479. eaMVMT = $ffdf;
  480. eaMVST = $ffde;
  481. eaASN1 = $ffdd;
  482. type TgEA = record
  483. case byte of
  484. 1: (NameLen: byte;
  485. Name: array [0..0] of AnsiChar);
  486. 2: (cbName: byte; { name length not including NULL }
  487. szName: AnsiChar); { attribute name }
  488. end;
  489. PgEA = ^TgEA;
  490. GEA = TgEA;
  491. TgEAList = record
  492. ListLen: cardinal; { total bytes of structure including full list }
  493. List: array [0..0] of TgEA; { variable length GEA structures }
  494. end;
  495. PgEAList = ^TgEAList;
  496. GEAList = TgEAList;
  497. TfEA = record
  498. case byte of
  499. 1: (EA,
  500. NameLen: byte;
  501. Value: word);
  502. 2: (fEA: byte; { flags }
  503. cbName: byte; { name length not including NULL }
  504. cbValue: word); { value length }
  505. end;
  506. PfEA = ^TfEA;
  507. FEA=TfEA;
  508. TfEAList = record
  509. Size: cardinal; { total bytes of structure including full list }
  510. List: array [0..0] of TfEA; { variable length FEA structures }
  511. end;
  512. PfEAList = ^TfEAlist;
  513. FEAList = TfEAList;
  514. TEAOp = record
  515. case byte of
  516. 1: (gEAList: PgEAList;
  517. fEAList: PfEAList;
  518. Error: cardinal);
  519. 2: (fpGEAList: PGEAList; { general EA list }
  520. fpFEAList: PFEAList; { full EA list }
  521. oError: cardinal);
  522. end;
  523. PEAOp = ^TEAOp;
  524. EAOp = TEAOp;
  525. TfEA2 = record
  526. NextEntry: cardinal;
  527. Flags,
  528. NameLen: byte;
  529. Value: word;
  530. szName: array [0..0] of AnsiChar;
  531. end;
  532. PfEA2 = ^TfEA2;
  533. FEA2 = TfEA2;
  534. TfEA2List = record
  535. ListLen: cardinal;
  536. List: array [0..0] of TfEA2;
  537. end;
  538. PfEA2List = ^TfEA2List;
  539. FEA2List = TfEA2List;
  540. TgEA2 = record
  541. case byte of
  542. 1: (NextEntry: cardinal;
  543. NameLen: byte;
  544. Name: array [0..0] of AnsiChar);
  545. 2: (oNextEntryOffset: cardinal; { new field }
  546. cbName: byte;
  547. szName: array [0..0] of byte); { new field }
  548. end;
  549. PgEA2 = ^TgEA2;
  550. GEA2 = TgEA2;
  551. TgEA2list = record
  552. ListLen: cardinal;
  553. List: array [0..0] of TgEA2;
  554. end;
  555. PgEA2List = ^TgEA2List;
  556. GEA2List = TgEAList;
  557. TEAOp2 = record
  558. case byte of
  559. 1: (gEA2List: PgEA2List;
  560. fEA2List: PfEA2List;
  561. Error: cardinal);
  562. 2: (fpGEA2List: PGEA2List; { GEA set }
  563. fpFEA2List: PFEA2List; { FEA set }
  564. oError: cardinal); { offset of FEA error }
  565. end;
  566. PEAOp2 = ^TEAOp2;
  567. EAOp2 = TEAOp2;
  568. TEASizeBuf = record { struct for FSCTL fn 2 - max ea size }
  569. case byte of
  570. 1: (MaxEASize: word;
  571. MaxEAListSize: cardinal);
  572. 2: (cbMaxEASize: word; { max size of one EA }
  573. cbMaxEAListSize: cardinal);{ max size of the full EA list }
  574. end;
  575. PEASizeBuf = ^TEASizeBuf;
  576. EASizeBuf = TEASizeBuf;
  577. {*******************End of extented attribute datastructures.***************}
  578. {Usefull constanst for Action parameter.}
  579. { DosOpen() actions }
  580. const doOpened = 1;
  581. doCreated = 2;
  582. doOverwritten = 3;
  583. FILE_EXISTED = doOpened;
  584. FILE_CREATED = doCreated;
  585. FILE_TRUNCATED = doOverwritten;
  586. {Usefull constants for OpenFlags parameter.}
  587. { DosOpen() open flags }
  588. const doFail = 0;
  589. doOpen = 1;
  590. doOverwrite = 2;
  591. (*
  592. fixed by KO M.H. on 1999.07.04
  593. contents : Creation flags is 10 hex not 10 dec.
  594. *)
  595. doCreate = 16;
  596. FILE_OPEN = doOpen;
  597. FILE_TRUNCATE = doOverwrite;
  598. FILE_CREATE = doCreate;
  599. { this nibble applies if file already exists xxxx }
  600. OPEN_ACTION_FAIL_IF_EXISTS =doFail; { ---- ---- ---- 0000 }
  601. OPEN_ACTION_OPEN_IF_EXISTS =doOpen; { ---- ---- ---- 0001 }
  602. OPEN_ACTION_REPLACE_IF_EXISTS =doOverwrite; { ---- ---- ---- 0010 }
  603. { this nibble applies if file does not exist xxxx }
  604. OPEN_ACTION_FAIL_IF_NEW =doFail; { ---- ---- 0000 ---- }
  605. OPEN_ACTION_CREATE_IF_NEW =DoCreate; { ---- ---- 0001 ---- }
  606. {Useful constants for openmode parameter.}
  607. const doRead = 0;
  608. doWrite = 1;
  609. doReadWrite = 2;
  610. doDenyRW = 16;
  611. doDenyWrite = 32;
  612. doDenyRead = 48;
  613. doDenyNone = 64;
  614. doNoInherit = 128;
  615. doSequential = 256;
  616. doRandom = 512;
  617. doNoCache = 4096;
  618. doFailOnErr = 8192;
  619. doWriteThru = 16384;
  620. doDASD = 32768;
  621. { Dos(Protect)Open(L)/Dos(Protect)SetFHState flags }
  622. OPEN_ACCESS_READONLY =doRead; { ---- ---- ---- -000 }
  623. OPEN_ACCESS_WRITEONLY =doWrite; { ---- ---- ---- -001 }
  624. OPEN_ACCESS_READWRITE =doReadWrite; { ---- ---- ---- -010 }
  625. OPEN_SHARE_DENYREADWRITE =doDenyRW; { ---- ---- -001 ---- }
  626. OPEN_SHARE_DENYWRITE =doDenyWrite; { ---- ---- -010 ---- }
  627. OPEN_SHARE_DENYREAD =doDenyRead; { ---- ---- -011 ---- }
  628. OPEN_SHARE_DENYNONE =doDenyNone; { ---- ---- -100 ---- }
  629. OPEN_FLAGS_NOINHERIT =doNoInherit; { ---- ---- 1--- ---- }
  630. OPEN_FLAGS_NO_LOCALITY =$0000; { ---- -000 ---- ---- }
  631. OPEN_FLAGS_SEQUENTIAL =doSequential; { ---- -001 ---- ---- }
  632. OPEN_FLAGS_RANDOM =doRandom; { ---- -010 ---- ---- }
  633. OPEN_FLAGS_RANDOMSEQUENTIAL =doSequential
  634. or doRandom; { ---- -011 ---- ---- }
  635. OPEN_FLAGS_NO_CACHE =doNoCache; { ---1 ---- ---- ---- }
  636. OPEN_FLAGS_FAIL_ON_ERROR =doFailOnErr; { --1- ---- ---- ---- }
  637. OPEN_FLAGS_WRITE_THROUGH =doWriteThru; { -1-- ---- ---- ---- }
  638. OPEN_FLAGS_DASD =doDASD; { 1--- ---- ---- ---- }
  639. OPEN_FLAGS_NONSPOOLED =$00040000;
  640. OPEN_SHARE_DENYLEGACY =$10000000;
  641. OPEN_FLAGS_PROTECTED_HANDLE =$40000000;
  642. { Open a file.
  643. FileName = Name of file.
  644. Handle = Receives filehandle.
  645. Action = Receives result of opening.
  646. 1 = Existing file opened.
  647. 2 = File did not exist. Created.
  648. 3 = File existed. Overwritten.
  649. InitSize = Initial size of file when creating or overwriting.
  650. Ignored when you do not. Must be zero when the file is
  651. created or overwritten in read-only mode.
  652. Attrib = Attributes when creating or overwriting files.
  653. OpenFlags = Bitfield describing what to do when file exists or doesn't
  654. exist.
  655. OpenMode = Bitfield describing describing how to open a file.
  656. EA = Extended attributes to give file when created. Use a nil
  657. pointer if you don't want to give it extended attributes.
  658. Use it only when creating or overwriting file. Use nil
  659. when not. Only the FEA list will be used.
  660. The bits in the openflags parameter have the following meanings:
  661. Bit 0-3: Action to take when file exists. 0000 = Return with error.
  662. 0001 = Open it.
  663. 0010 = Overwrite it.
  664. Bit 4-7: Action to take when file does not 0000 = Return with error.
  665. exist. 0001 = Create it.
  666. The bits in the filemode parameter have the following meanings:
  667. Bit 0-2: Access mode: 000 = Read-only
  668. 001 = Write-only
  669. 010 = Read/Write
  670. Bit 3: Reserved.
  671. Bit 4-6: Sharing mode. 001 = Deny all
  672. 010 = Deny write
  673. 011 = Deny read
  674. 100 = Deny none
  675. Bit 7: Inheritance. 0 = Handle will be inherited by childs.
  676. 1 = Handle will not be inherited.
  677. Bit 8-11: Reserved.
  678. Bit 12: Cache flag. 0 = Use caching.
  679. 1 = Disable both read and write caching.
  680. Bit 13: Error handling. 0 = Use critical error handler.
  681. 1 = Return just an error code.
  682. Bit 14: Write cache flag. 0 = Write operations may be cached.
  683. 1 = Write operations must be executed
  684. before write operation functions return.
  685. Bit 15: DASD flag. 0 = Open a file or device.
  686. 1 = Open a drive as file.
  687. Bit 29: 32-bit access flag. 0 = Allow opening the file using DosOpen.
  688. 1 = Avoid file to be open using DosOpen as well.
  689. Bit 30: Protection flag. 0 = File handle is not protected.
  690. 1 = File handle is protected.
  691. When the DASD flag is set, the whole drive is read as a single file. The
  692. file starts with 512 bytes of bootsector, then 512 bytes of the second sector etc.
  693. The filename must consist of the driveletter followed by a semicolon.}
  694. function DosOpen(FileName:PAnsiChar;var Handle: longint; var Action:longint;
  695. InitSize:longint;Attrib,OpenFlags,FileMode:longint;
  696. EA:PEAOp2):cardinal; cdecl;
  697. function DosOpen(FileName:PAnsiChar;var Handle: THandle;var Action:cardinal;
  698. InitSize,Attrib,OpenFlags,FileMode:cardinal;
  699. EA:PEAOp2):cardinal; cdecl;
  700. {This variant of DosOpen always creates or overwrites a file.}
  701. function DosCreate(FileName:PAnsiChar;var Handle: THandle;
  702. Attrib,OpenMode:cardinal):cardinal;
  703. {This variant of DosOpen always opens an existing file.}
  704. function DosOpen(FileName:PAnsiChar;var Handle: THandle;
  705. Attrib,OpenMode:cardinal):cardinal;
  706. {There are also string variants.}
  707. function DosOpen(const FileName:string;var Handle: longint; var Action:longint;
  708. InitSize,Attrib,OpenFlags,OpenMode:longint;
  709. ea:PEAOp2):cardinal;
  710. function DosOpen(const FileName:string;var Handle: THandle;var Action:cardinal;
  711. InitSize,Attrib,OpenFlags,OpenMode:cardinal;
  712. ea:PEAOp2):cardinal;
  713. function DosCreate(const FileName:string;var Handle: THandle;
  714. Attrib,OpenMode:cardinal):cardinal;
  715. function DosOpen(const FileName:string;var Handle: THandle;
  716. Attrib,OpenMode:cardinal):cardinal;
  717. {Close a file.
  718. Cannot fail if handle does exist.}
  719. function DosClose (Handle: THandle): cardinal; cdecl;
  720. {Read from a file or other type of handle.
  721. Handle = File handle.
  722. Buffer = The read data is stored here.
  723. Count = Number of bytes to read.
  724. ActCount = Number of bytes actually read.}
  725. function DosRead (Handle: longint; var Buffer; Count: longint;
  726. var ActCount:longint):cardinal; cdecl;
  727. function DosRead (Handle: THandle; var Buffer; Count: cardinal;
  728. var ActCount:cardinal):cardinal; cdecl;
  729. {Write to a file or other type of handle.
  730. Handle = File handle.
  731. Buffer = The data to be written.
  732. Count = Number of bytes to write.
  733. ActCount = Number of bytes actually written.}
  734. function DosWrite (Handle: longint; const Buffer; Count: longint;
  735. var ActCount:longint):cardinal; cdecl;
  736. function DosWrite (Handle: THandle; const Buffer; Count: cardinal;
  737. var ActCount:cardinal):cardinal; cdecl;
  738. const dsZeroBased=0; {Set filepointer from begin of file.}
  739. dsRelative=1; {Set filepointer relative to the current one.}
  740. dsEndBased=2; {Set filepointer from end of file.}
  741. (* The following for compatibility only *)
  742. FILE_BEGIN = dsZeroBased; { Move relative to beginning of file }
  743. FILE_CURRENT = dsRelative; { Move relative to current fptr position }
  744. FILE_END = dsEndBased; { Move relative to end of file }
  745. {Change the filepointer of a file.}
  746. function DosSetFilePtr (Handle: longint; Pos: longint; Method: cardinal;
  747. var PosActual: longint): cardinal; cdecl;
  748. function DosSetFilePtr (Handle: THandle; Pos: longint; Method: cardinal;
  749. var PosActual: cardinal): cardinal; cdecl;
  750. {This variant seeks always from begin of file and does not return the
  751. actual position.}
  752. function DosSetFilePtr (Handle: THandle; Pos: longint): cardinal;
  753. {This variant returns the current filepointer.}
  754. function DosGetFilePtr (Handle: longint; var PosActual: longint): cardinal;
  755. function DosGetFilePtr (Handle: THandle; var PosActual: cardinal): cardinal;
  756. {Use DosQueryFileInfo or DosQueryPathInfo to get the size of a file.}
  757. {Change the size of a file.}
  758. function DosSetFileSize (Handle: THandle; Size: cardinal): cardinal; cdecl;
  759. {Flush update the changes to a file to disk.}
  760. function DosResetBuffer (Handle: THandle): cardinal; cdecl;
  761. {Duplicate or redirect a handle.
  762. To duplicate a handle: Fill handle with source handle and duplicate with -1.
  763. Copy of handle will be returned in duplicate.
  764. To redirect a handle: Fill handle with handle to which the handle to
  765. redirect will be redirected. The handle that will be
  766. redirected should be placed in duplicate.}
  767. function DosDupHandle (Handle: THandle; var Duplicate: THandle): cardinal;
  768. cdecl;
  769. {Return information about a specific handle. See DosOpen for a
  770. description of FileMode.}
  771. function DosQueryFHState (Handle: longint; var FileMode: longint): cardinal;
  772. cdecl;
  773. function DosQueryFHState (Handle: THandle; var FileMode: cardinal): cardinal;
  774. cdecl;
  775. {Set information about a specific handle. See DosOpen for a description
  776. of FileMode.}
  777. function DosSetFHState (Handle: THandle; FileMode: cardinal): cardinal; cdecl;
  778. {Useful constants for the handle type.}
  779. const dhFile = 0;
  780. dhDevice = 1;
  781. dhPipe = 2;
  782. dhNetwork = 8192;
  783. {Determine if a handle belongs to a file, a device or a pipe.
  784. Handle = Handle tp query info about.
  785. HandType = Bits 0-1: 00 = File
  786. 01 = Device
  787. 02 = Pipe
  788. Bit 15: 0 = Local.
  789. 1 = On network.}
  790. function DosQueryHType (Handle: longint; var HandType: longint;
  791. var Attr: longint): cardinal; cdecl;
  792. function DosQueryHType (Handle: THandle; var HandType:cardinal;
  793. var Attr:cardinal):cardinal; cdecl;
  794. {****************************************************************************
  795. File management related routines.
  796. ****************************************************************************}
  797. {Edit a filename using wildcard.
  798. Example editing CONFIG.SYS with *.BAK becomes CONFIG.BAK.
  799. Usefull when parsing commands like 'copy config.sys *.bak'.
  800. All filename characters are casemapped.'
  801. MetaLevel = 0 Use modern semantics
  802. MetaLevel = 1 Use OS/2 1.2 semantics
  803. Source = string to edit
  804. Edit = editstring
  805. Target = destination buffer
  806. TargetLen = size of the destination buffer}
  807. function DosEditName(MetaLevel:cardinal;Source,Edit:PAnsiChar;
  808. Target:PAnsiChar;TargetLen:cardinal):cardinal; cdecl;
  809. function DosEditName(MetaLevel:cardinal;const Source,Edit:string;
  810. var Target:string):cardinal;
  811. {Move or rename a file.
  812. OldFile = old name of file
  813. NewFile = new name of file}
  814. function DosMove(OldFile,NewFile:PAnsiChar):cardinal; cdecl;
  815. function DosMove(const OldFile,NewFile:string):cardinal;
  816. const dcExisting=1; {Overwrite existing files.}
  817. dcAppend=2; {Append to existing file.}
  818. dcFailEAs=4; {Discard EAs if not supported by target FS}
  819. {Copy a file.
  820. OldFile = source file
  821. NewFile = destination file}
  822. function DosCopy(OldFile,NewFile:PAnsiChar;Option:cardinal):cardinal; cdecl;
  823. function DosCopy(const OldFile,NewFile:string;Option:cardinal):cardinal;
  824. {Delete a file from disk.}
  825. function DosDelete(FileName:PAnsiChar):cardinal; cdecl;
  826. function DosDelete(const FileName:string):cardinal;
  827. {Destroy a file on disk. DosForceDelete makes sure that the file cannot
  828. be unerased anymore.}
  829. function DosForceDelete(FileName:PAnsiChar):cardinal; cdecl;
  830. function DosForceDelete(const FileName:string):cardinal;
  831. {Create a new directory.
  832. Name = Name of directory to create.
  833. EA = Extented attributes to give the directory. Use nil if you
  834. do not want do give it extented attributes. Only the FEA
  835. list is used.}
  836. function DosCreateDir(Name:PAnsiChar;EA:PEAOp2):cardinal; cdecl;
  837. function DosCreateDir(const Name:string;EA:PEAOp2):cardinal;
  838. {Variants without the EA parameter (nil is used).}
  839. function DosCreateDir(Name:PAnsiChar):cardinal;
  840. function DosCreateDir(const Name:string):cardinal;
  841. {Remove a directory.}
  842. function DosDeleteDir(Name:PAnsiChar):cardinal; cdecl;
  843. function DosDeleteDir(const Name:string):cardinal;
  844. {Set the current drive. Cannot fail if the driveletter is correct.}
  845. function DosSetDefaultDisk(DiskNum:cardinal):cardinal; cdecl;
  846. {Get the current drive. Because it cannot fail, it is declared as procedure.}
  847. procedure DosQueryCurrentDisk(var DiskNum:longint;var Logical:longint); cdecl;
  848. procedure DosQueryCurrentDisk(var DiskNum:cardinal;var Logical:cardinal); cdecl;
  849. {Set the current directory.}
  850. function DosSetCurrentDir(Name:PAnsiChar):cardinal; cdecl;
  851. function DosSetCurrentDir(const Name:string):cardinal;
  852. {Get the current directory.}
  853. function DosQueryCurrentDir(DiskNum:longint;var Buffer;
  854. var BufLen:longint):cardinal; cdecl;
  855. function DosQueryCurrentDir(DiskNum:cardinal;var Buffer:string):cardinal;
  856. function DosQueryCurrentDir(DiskNum:cardinal;var Buffer;
  857. var BufLen:cardinal):cardinal; cdecl;
  858. {Send/receive information to a device.
  859. Handle = A file handle to a device, instead of a file.
  860. Category = The category of functions the function is in.
  861. Func = Function to call.
  862. Params = Parameters for the function.
  863. ParamLen = Size of the params buffer.
  864. ParamSize = Size of the parametrs to send to the device
  865. Receives size of the returned parameters.
  866. Data = Data to send to device.
  867. DataLen = Size of your data buffer.
  868. DataSize = Size of the data to send to device.
  869. Receives size of the data returned by the device.}
  870. function DosDevIOCtl(Handle,Category,Func:longint;var Params;
  871. ParamLen:longint;var ParamSize:longint;
  872. var Data;DataLen:longint;var DataSize:
  873. longint):cardinal; cdecl;
  874. function DosDevIOCtl (Handle: THandle; Category,Func:cardinal;var Params;
  875. ParamLen:cardinal;var ParamSize:cardinal;
  876. var Data;DataLen:cardinal;var DataSize:cardinal):cardinal; cdecl;
  877. {****************************************************************************
  878. File searching related routines.
  879. ****************************************************************************}
  880. const faReadOnly = 1;
  881. faHidden = 2;
  882. faSystem = 4;
  883. faReserve = 8;
  884. faDirectory = 16;
  885. faArchive = 32;
  886. ilStandard = 1; (* Use TFileStatus3/TFindFileBuf3 *)
  887. ilQueryEASize = 2; (* Use TFileStatus4/TFindFileBuf4 *)
  888. ilQueryEAs = 3;
  889. ilQueryFullName = 5;
  890. ilStandardL = 11; (* Use TFileStatus3L/TFindFileBuf3L *)
  891. ilQueryEASizeL = 12; (* Use TFileStatus4L/TFindFileBuf4L *)
  892. ilQueryEAsL = 13;
  893. FIL_Standard = ilStandard;
  894. FIL_QueryEASize = ilQueryEASize;
  895. FIL_QueryEAsFromList = ilQueryEAs;
  896. FIL_StandardL = ilStandardL;
  897. FIL_QueryEASizeL = ilQueryEASizeL;
  898. FIL_QueryEAsFromListL = ilQueryEAsL;
  899. {Format of date records:
  900. Bit 0..4: day
  901. Bit 5..8: month
  902. Bit 9..15: year minus 1980
  903. Format of time records:
  904. Bit 0..4: seconds divided by 2
  905. Bit 5..10: minutes
  906. Bit 11..15: hours}
  907. type
  908. TFileStatus = object
  909. end;
  910. PFileStatus = ^TFileStatus;
  911. TFileStatus3 = object (TFileStatus)
  912. DateCreation, {Date of file creation.}
  913. TimeCreation, {Time of file creation.}
  914. DateLastAccess, {Date of last access to file.}
  915. TimeLastAccess, {Time of last access to file.}
  916. DateLastWrite, {Date of last modification of file.}
  917. TimeLastWrite:word; {Time of last modification of file.}
  918. FileSize, {Size of file.}
  919. FileAlloc:cardinal; {Amount of space the file really
  920. occupies on disk.}
  921. AttrFile:cardinal; {Attributes of file.}
  922. end;
  923. PFileStatus3=^TFileStatus3;
  924. TFileStatus4=object(TFileStatus3)
  925. cbList:cardinal; {Length of entire EA set.}
  926. end;
  927. PFileStatus4=^TFileStatus4;
  928. TFileStatus3L = object (TFileStatus)
  929. DateCreation, {Date of file creation.}
  930. TimeCreation, {Time of file creation.}
  931. DateLastAccess, {Date of last access to file.}
  932. TimeLastAccess, {Time of last access to file.}
  933. DateLastWrite, {Date of last modification of file.}
  934. TimeLastWrite:word; {Time of last modification of file.}
  935. FileSize, {Size of file.}
  936. FileAlloc:int64; {Amount of space the file really
  937. occupies on disk.}
  938. AttrFile:cardinal; {Attributes of file.}
  939. end;
  940. PFileStatus3L=^TFileStatus3L;
  941. TFileStatus4L=object(TFileStatus3L)
  942. cbList:cardinal; {Length of entire EA set.}
  943. end;
  944. PFileStatus4L=^TFileStatus4L;
  945. TFileFindBuf3=object(TFileStatus)
  946. NextEntryOffset: cardinal; {Offset of next entry}
  947. DateCreation, {Date of file creation.}
  948. TimeCreation, {Time of file creation.}
  949. DateLastAccess, {Date of last access to file.}
  950. TimeLastAccess, {Time of last access to file.}
  951. DateLastWrite, {Date of last modification of file.}
  952. TimeLastWrite:word; {Time of last modification of file.}
  953. FileSize, {Size of file.}
  954. FileAlloc:cardinal; {Amount of space the file really
  955. occupies on disk.}
  956. AttrFile:cardinal; {Attributes of file.}
  957. Name:string; {Also possible to use as ASCIIZ.
  958. The byte following the last string
  959. character is always zero.}
  960. end;
  961. PFileFindBuf3=^TFileFindBuf3;
  962. TFileFindBuf4=object(TFileStatus)
  963. NextEntryOffset: cardinal; {Offset of next entry}
  964. DateCreation, {Date of file creation.}
  965. TimeCreation, {Time of file creation.}
  966. DateLastAccess, {Date of last access to file.}
  967. TimeLastAccess, {Time of last access to file.}
  968. DateLastWrite, {Date of last modification of file.}
  969. TimeLastWrite:word; {Time of last modification of file.}
  970. FileSize, {Size of file.}
  971. FileAlloc:cardinal; {Amount of space the file really
  972. occupies on disk.}
  973. AttrFile:cardinal; {Attributes of file.}
  974. cbList:cardinal; {Size of the file's extended attributes.}
  975. Name:string; {Also possible to use as ASCIIZ.
  976. The byte following the last string
  977. character is always zero.}
  978. end;
  979. PFileFindBuf4=^TFileFindBuf4;
  980. TFileFindBuf3L=object(TFileStatus)
  981. NextEntryOffset: cardinal; {Offset of next entry}
  982. DateCreation, {Date of file creation.}
  983. TimeCreation, {Time of file creation.}
  984. DateLastAccess, {Date of last access to file.}
  985. TimeLastAccess, {Time of last access to file.}
  986. DateLastWrite, {Date of last modification of file.}
  987. TimeLastWrite:word; {Time of last modification of file.}
  988. FileSize, {Size of file.}
  989. FileAlloc:int64; {Amount of space the file really
  990. occupies on disk.}
  991. AttrFile:cardinal; {Attributes of file.}
  992. Name:string; {Also possible to use as ASCIIZ.
  993. The byte following the last string
  994. character is always zero.}
  995. end;
  996. PFileFindBuf3L=^TFileFindBuf3L;
  997. TFileFindBuf4L=object(TFileStatus)
  998. NextEntryOffset: cardinal; {Offset of next entry}
  999. DateCreation, {Date of file creation.}
  1000. TimeCreation, {Time of file creation.}
  1001. DateLastAccess, {Date of last access to file.}
  1002. TimeLastAccess, {Time of last access to file.}
  1003. DateLastWrite, {Date of last modification of file.}
  1004. TimeLastWrite:word; {Time of last modification of file.}
  1005. FileSize, {Size of file.}
  1006. FileAlloc:int64; {Amount of space the file really
  1007. occupies on disk.}
  1008. AttrFile:cardinal; {Attributes of file.}
  1009. cbList:cardinal; {Size of the file's extended attributes.}
  1010. Name:string; {Also possible to use as ASCIIZ.
  1011. The byte following the last string
  1012. character is always zero.}
  1013. end;
  1014. PFileFindBuf4L=^TFileFindBuf4L;
  1015. {Find first file matching a filemask. In contradiction to DOS, a search
  1016. handle is returned which should be closed with FindClose when done.
  1017. FileMask = Filemask to search.
  1018. Handle = Search handle will be returned here, fill with -1 before
  1019. call.
  1020. Attrib = File attributes to search for.
  1021. AFileStatus = Return buffer.
  1022. FileStatusLen = Size of return buffer.
  1023. Count = Fill with maximum number of files to search for, the
  1024. actual number of matching files found is returned here.
  1025. InfoLevel = One of the ilXXXX constants. Consult IBM documentation
  1026. for exact meaning. For normal use: Use ilStandard and
  1027. use PFileFindBuf3 for AFileStatus.}
  1028. function DosFindFirst (FileMask: PAnsiChar; var Handle: THandle; Attrib: cardinal;
  1029. AFileStatus: PFileStatus; FileStatusLen: cardinal;
  1030. var Count: cardinal; InfoLevel: cardinal): cardinal;
  1031. cdecl;
  1032. function DosFindFirst (const FileMask: string; var Handle: THandle;
  1033. Attrib: cardinal; AFileStatus: PFileStatus;
  1034. FileStatusLen: cardinal; var Count: cardinal;
  1035. InfoLevel: cardinal): cardinal;
  1036. {Find next matching file.}
  1037. function DosFindNext (Handle: THandle; AFileStatus: PFileStatus;
  1038. FileStatusLen: cardinal; var Count: cardinal): cardinal;
  1039. cdecl;
  1040. {Close a search handle. Cannot fail if handle does exist.}
  1041. function DosFindClose (Handle: THandle): cardinal; cdecl;
  1042. {Get info about a file.
  1043. Handle = Handle of file.
  1044. InfoLevel = One of the ilXXXX constants. Consult IBM documentation
  1045. for exect meaning. For normal use: Use ilStandard and
  1046. PFileFindBuf3 for AFileStatus.
  1047. AFileStatus = An info return buffer.
  1048. FileStatusLen = Size of info buffer.}
  1049. function DosQueryFileInfo (Handle: THandle; InfoLevel: cardinal;
  1050. AFileStatus: PFileStatus; FileStatusLen: cardinal): cardinal; cdecl;
  1051. {Set info about a file. File must be opened with write permissions. See
  1052. above fo the parameters.}
  1053. function DosSetFileInfo (Handle: THandle; InfoLevel: cardinal;
  1054. AFileStatus: PFileStatus; FileStatusLen: cardinal): cardinal; cdecl;
  1055. {Return info about a file. In contradiction to the above functions, the
  1056. file does not have to be open.}
  1057. function DosQueryPathInfo(FileName:PAnsiChar;InfoLevel:cardinal;
  1058. AFileStatus:PFileStatus;FileStatusLen:cardinal):cardinal; cdecl;
  1059. function DosQueryPathInfo(const FileName:string;InfoLevel:cardinal;
  1060. AFileStatus:PFileStatus;FileStatusLen:cardinal):cardinal;
  1061. {Set information about a file.}
  1062. function DosSetPathInfo(FileName:PAnsiChar;InfoLevel:cardinal;
  1063. AFileStatus:PFileStatus;FileStatusLen,
  1064. Options:cardinal):cardinal; cdecl;
  1065. {Get info about the names and lengths of the EA's for a file or directory.
  1066. RefType = 0 = AFile is a pointer to a file-handle.
  1067. 1 = AFile is a pointer to an ASCIIZ string.
  1068. AFile = Pointer file's name or handle.
  1069. Entry = Number of EA to query inof about. (1 = first EA).
  1070. Buf = Buffer where requested info is returned. For InfoLevel
  1071. 1, the buffer is a TfEA2 datastructure.
  1072. BufLen = Size of buf in bytes.
  1073. Count = Number of EA's to return info for. Number of EA's that
  1074. actually fitted in buf is returned here.
  1075. InfoLevel = Level of information to return. Only level 1 is
  1076. currently allowed.}
  1077. function DosEnumAttribute(RefType:longint;AFile:pointer;
  1078. Entry:longint;var Buf;BufSize:longint;
  1079. var Count:longint;InfoLevel:longint):cardinal; cdecl;
  1080. function DosEnumAttribute(RefType:cardinal;AFile:pointer;
  1081. Entry:cardinal;var Buf;BufSize:cardinal;
  1082. var Count:cardinal;InfoLevel:cardinal):cardinal; cdecl;
  1083. function DosEnumAttribute (RefType: cardinal; AFile: PAnsiChar;
  1084. Entry: cardinal; var Buf; BufSize:cardinal;
  1085. var Count: cardinal; InfoLevel: cardinal): cardinal; cdecl;
  1086. function DosEnumAttribute(RefType: cardinal; const AFile: THandle;
  1087. Entry: cardinal; var Buf; BufSize: cardinal;
  1088. var Count: cardinal; InfoLevel: cardinal): cardinal; cdecl;
  1089. function DosEnumAttribute (Handle: longint; Entry: longint; var Buf;
  1090. BufSize: longint; var Count: longint; InfoLevel: longint): cardinal;
  1091. function DosEnumAttribute (Handle: THandle; Entry: cardinal; var Buf;
  1092. BufSize: cardinal; var Count: cardinal; InfoLevel: cardinal): cardinal;
  1093. function DosEnumAttribute (const FileName: string;
  1094. Entry: cardinal; var Buf; BufSize: cardinal;
  1095. var Count: cardinal; InfoLevel: cardinal): cardinal;
  1096. {Get an environment variable.
  1097. Name = Name of environment variable to get.
  1098. Value = Receives pointer to environment string.}
  1099. function DosScanEnv(Name:PAnsiChar;var Value:PAnsiChar):cardinal; cdecl;
  1100. {There is, of course a string variant.}
  1101. function DosScanEnv(const Name:string;var Value:string):cardinal;
  1102. const dsPathOnly = 0; {Do not search current dir. (Unless it is
  1103. in the directory list.)}
  1104. dsCurrentDir = 1; {Search in the current direcotry and in the
  1105. directory list.}
  1106. dsEnvironment = 2; {The dirlist parameter is not a directory
  1107. list, but an environment variable
  1108. containing one.}
  1109. dsIgnoreNetErrs = 4; {Ignore network errors when searching.}
  1110. {Search for a file in a given number of directories.
  1111. Flags = A combination of the dsXXXX constants.
  1112. DirList = Directory list or environment variable containing list
  1113. to search in.
  1114. FileName = Filename to search for. May contain wildcards.
  1115. FullName = Receives filename found, including path.
  1116. FullLen = Length of your fullname buffer.}
  1117. function DosSearchPath(Flag:cardinal;DirList,FileName:PAnsiChar;
  1118. FullName:PAnsiChar;FullLen:cardinal):cardinal; cdecl;
  1119. function DosSearchPath(Flag:cardinal;const DirList,FileName:string;
  1120. var FullName:string):cardinal;
  1121. {****************************************************************************
  1122. File system related routines.
  1123. ****************************************************************************}
  1124. type TFSInfo=record
  1125. case word of
  1126. 1:
  1127. (File_Sys_ID,
  1128. Sectors_Per_Cluster,
  1129. Total_Clusters,
  1130. Free_Clusters:cardinal;
  1131. Bytes_Per_Sector:word);
  1132. 2: {For date/time description,
  1133. see file searching realted
  1134. routines.}
  1135. (Label_Date, {Date when volumelabel created.}
  1136. Label_Time:word; {Time when volumelabel created.}
  1137. VolumeLabel:string); {Volume label. Can also be used
  1138. as ASCIIZ, because the byte
  1139. following the last character of
  1140. the string is always zero.}
  1141. end;
  1142. PFSInfo=^TFSInfo;
  1143. TAttachData=record
  1144. case integer of {Flag in [0,1,2].}
  1145. 0,1: {Flag = 0.}
  1146. (Count:word;
  1147. Data:TCharArray);
  1148. 2: {Flag = 2.}
  1149. (PipeHandle: THandle;
  1150. {Handle of named pipe opened by spooler.}
  1151. SpoolName:string);
  1152. {Name of spooler object. Can also be used
  1153. as ASCIIZ, because the bute following
  1154. the last character is always zero.}
  1155. end;
  1156. PAttachData=^TAttachData;
  1157. TFSQBuffer2=record
  1158. _Type:word;
  1159. NameLen:word;
  1160. FSDNameLen:word;
  1161. FSADataLen:word;
  1162. Name:AnsiChar;
  1163. Nul1:byte;
  1164. FSDName:AnsiChar;
  1165. Nul2:byte;
  1166. FSAData:AnsiChar;
  1167. Nul3:byte;
  1168. end;
  1169. PFSQBuffer2=^TFSQBuffer2;
  1170. const fsAttach = 0; {Attach a drive.}
  1171. fsDetach = 1; {Detach a drive.}
  1172. fsSpoolAttach = 2; {Attach a spool device.}
  1173. fsSpoolDetach = 3; {Detach a spool device.}
  1174. {IBM DOCS: "DosFSAttach attaches or detaches a drive to or from a remote file
  1175. system driver (FSD), or a pseudocharacter device name to or from a local or
  1176. remote FSD."
  1177. DevName = When flag is 0 or 1, the name of a drive or a pseudo-
  1178. character device. When using a drivename use the drive-
  1179. letter followed by a colon.
  1180. When flag is 2 or 3, the name of a spooled device.
  1181. FileSystem = Name of the driver that should be attached or detached
  1182. to DevName. Use nil when flag is 2 or 3.
  1183. Data = Should contain a number of ASCIIZ strings that will
  1184. be passed to the filesystem driver when flag is 0 or 1.
  1185. Should contain de pipehandle and spoolname when flag is
  1186. 2. Should be nil when flag is 3.
  1187. DataLen = Number of bytes in data parameter.
  1188. Flag = One of the dsXXXX constants. See above}
  1189. function DosFSAttach(DevName,FileSystem:PAnsiChar;var Data:TAttachData;
  1190. DataLen,Flag:cardinal):cardinal; cdecl;
  1191. function DosFSAttach(const DevName,FileSystem:string;var Data:TAttachData;
  1192. DataLen,Flag:cardinal):cardinal;
  1193. {IBMDOCS: "DosQueryFSAttach obtains information about an attached file system
  1194. (local or remote), or about a character device or pseudocharacter device
  1195. attached to the file system."
  1196. DevName = Name info drive or pseudo character device to query
  1197. info about. Ignored for InfoLevels 2 and 3.
  1198. Ordinal = Index into list of character/pseudo-character
  1199. devices. Starts at 1. Ignored for infolevel 1.
  1200. InfoLevel = 1 = Return information about a drive or device named
  1201. by DevName.
  1202. 2 = Return information about a (pseudo) charachter
  1203. device numbered by Ordinal.
  1204. 3 = Return information about a drive numbered by
  1205. Ordinal.
  1206. Buffer = Will be filled with infomation.
  1207. BufLen = Size of your buffer in bytes. Number of bytes filled
  1208. in your buffer is returned here.}
  1209. function DosQueryFSAttach(DevName:PAnsiChar;Ordinal,InfoLevel:longint;
  1210. var Buffer:TFSQBuffer2;var BufLen:longint):cardinal; cdecl;
  1211. function DosQueryFSAttach(const DevName:string;Ordinal,InfoLevel:longint;
  1212. var Buffer:TFSQBuffer2;var BufLen:longint):cardinal;
  1213. function DosQueryFSAttach(DevName:PAnsiChar;Ordinal,InfoLevel:cardinal;
  1214. var Buffer:TFSQBuffer2;var BufLen:cardinal):cardinal; cdecl;
  1215. function DosQueryFSAttach(const DevName:string;Ordinal,InfoLevel:cardinal;
  1216. var Buffer:TFSQBuffer2;var BufLen:cardinal):cardinal;
  1217. const FSCtl_Handle=1;
  1218. FSCtl_PathName=2;
  1219. FSCtl_FSDName=3;
  1220. FSCtl_Error_Info=1;
  1221. FSCtl_Max_EASize=2;
  1222. {IBMDOCS: "DosFSCtl provides an extended standard interface between an
  1223. application and a file-system driver (FSD).
  1224. Consult IBM documentation about this function..}
  1225. function DosFSCtl (Data: pointer; DataLen: longint; var ResDataLen: longint;
  1226. Parms: pointer; ParmsLen: longint; var ResParmsLen: longint;
  1227. _Function: longint; Route: PAnsiChar;
  1228. Handle, Method: longint): cardinal; cdecl;
  1229. function DosFSCtl (Data: pointer; DataLen: longint; var ResDataLen: longint;
  1230. Parms: pointer;ParmsLen: longint; var ResParmsLen: longint;
  1231. _Function: longint; const Route: string;
  1232. Handle, Method: longint): cardinal;
  1233. function DosFSCtl (Data: pointer; DataLen: cardinal; var ResDataLen: cardinal;
  1234. Parms: pointer; ParmsLen: cardinal; var ResParmsLen: cardinal;
  1235. _Function: cardinal; Route: PAnsiChar;
  1236. Handle: THandle;Method: cardinal): cardinal; cdecl;
  1237. function DosFSCtl (Data: pointer; DataLen: cardinal; var ResDataLen: cardinal;
  1238. Parms: pointer; ParmsLen: cardinal; var ResParmsLen: cardinal;
  1239. _Function: cardinal; const Route: string;
  1240. Handle: THandle; Method: cardinal): cardinal;
  1241. {Get information about a drive.
  1242. InfoLevels:
  1243. 1 Get total/free space etc.
  1244. 2 Get volumelabel.}
  1245. function DosQueryFSInfo (DiskNum, InfoLevel: cardinal; var Buffer: TFSInfo;
  1246. BufLen: cardinal): cardinal; cdecl;
  1247. {Set information about a drive.}
  1248. function DosSetFSInfo (DiskNum, InfoLevel: cardinal; var Buffer: TFSinfo;
  1249. BufLen: cardinal): cardinal; cdecl;
  1250. {Check if verify mode is enabled.}
  1251. function DosQueryVerify (var Enabled: longint): cardinal; cdecl;
  1252. function DosQueryVerify (var Enabled: cardinal): cardinal; cdecl;
  1253. function DosQueryVerify (var Enabled: boolean): cardinal;
  1254. {Turn the verify mode on or off.}
  1255. function DosSetVerify (Enable: cardinal): cardinal; cdecl;
  1256. function DosSetVerify (Enable: boolean): cardinal;
  1257. {Change the number of filehandles our program can open. (Default=50). It
  1258. won't hurt if there are files open when you are calling this.}
  1259. function DosSetMaxFH (Count: cardinal): cardinal; cdecl;
  1260. {Ask for more filehandles (or dump filehandles). It won't hurt if there are
  1261. files open when you are calling this.
  1262. ReqCount = Number of filehandles to ask for. (Negative to dump them.)
  1263. CurMaxFH = Receives the total number of filehandles your program has
  1264. access to.}
  1265. function DosSetRelMaxFH (var ReqCount: longint; var CurMaxFH: longint):
  1266. cardinal; cdecl;
  1267. function DosSetRelMaxFH (var ReqCount: longint; var CurMaxFH: cardinal):
  1268. cardinal; cdecl;
  1269. const dsFull=0; {IBM DOCS: "Perform full system shutdown and
  1270. file-system lock."}
  1271. dsQuiescient=1; {IBM DOCS: "Perform buffer and cache flushing to
  1272. make system quiescent."}
  1273. {Prepare the system for shutdown.}
  1274. function DosShutdown (Flags: cardinal): cardinal; cdecl;
  1275. {Parameters (system variables) for DosQuerySysInfo.}
  1276. const svMaxPathLength = 1; {Maximum length of a pathname.}
  1277. svMaxTextSessions = 2; {Maximum number of text sessions.}
  1278. svMaxPMSessions = 3; {Maximum number of PM sessions.}
  1279. svMaxVDMSessions = 4; {Maximum number of DOS sessions.}
  1280. svBootDrive = 5; {Get the boot drive. (A=1, B=2 etc.)}
  1281. svDynPriVariation = 6; {Dynamic priority variation flag
  1282. (0 = absolute priority, 1 means
  1283. dynamic priority).}
  1284. svMaxWait = 7; {Maximum wait time in seconds.}
  1285. svMinSlice = 8; {Minimum time slice in milliseconds.}
  1286. svMaxSlice = 9; {Maximum time slice in milliseconds.}
  1287. svPageSize = 10; {Size of a page (always 4096 bytes for
  1288. x86).}
  1289. svVersionMajor = 11; {Major version number of kernel:
  1290. 10 for OS/2 1.0 and 1.1,
  1291. 20 for OS/2 2.0 .. OS/2 4.0.}
  1292. svVersionMinor = 12; {Minor version of kernel:
  1293. OS/2 2.0: 00, 2.1: 10, 2.11: 11,
  1294. 3.0: 30, 4.0: 40.}
  1295. svVersionRevision = 13; {Revision of kernel. Until now all
  1296. OS/2 versions return 0.}
  1297. svMsCount = 14; {Uptime in milliseconds.}
  1298. svTimeLow = 15; {System time in seconds since
  1299. 1 January 1970 0:00:00, low dword.}
  1300. svTimeHigh = 16; {System time in seconds since
  1301. 1 January 1970 0:00:00, high dword.}
  1302. svTotPhysMem = 17; {Amount in bytes of physical memory
  1303. in system.}
  1304. svTotResMem = 18; {Amount in bytes of resident memory
  1305. in system.}
  1306. svTotAvailMem = 19; {Amount in bytes of available
  1307. memory.}
  1308. svMaxPrMem = 20; {Maximum amount of memory the current
  1309. process can request for its
  1310. private use.}
  1311. svMaxShMem = 21; {Maximum amount of shared memory
  1312. the current process can request.}
  1313. svTimerInterval = 22; {Timer interval in tenths of a
  1314. millisecond.}
  1315. svMaxCompLength = 23; {Maximum length of a component in a
  1316. pathname.}
  1317. svForegroundFSSession = 24; {Session ID of the foreground
  1318. full-screen session. Presentation
  1319. Manager and all sessions running under
  1320. PM (including PM, windowed VIO, VDM
  1321. and seamless Win 3.x) return ID 1.}
  1322. svForegroundProcess = 25; {Process ID of the current foreground
  1323. process.}
  1324. svNumProcessors = 26; {Number of CPUs in machine - supported
  1325. since WarpServer Advanced SMP.}
  1326. {The following parameters are only supported in WSeB/MCP/eCS
  1327. or OS/2 Warp 4.0 with FP14 and above.}
  1328. svMaxHPrMem = 27; {Maximum amount of high memory the
  1329. process can request for its private
  1330. use in total (not necessarily at once
  1331. because of potential fragmentation).}
  1332. svMaxHShMem = 28; {Maximum amount of high shared memory
  1333. the process can request.}
  1334. svMaxProcesses = 29; {Maximum number of concurrent processes
  1335. supported.}
  1336. svVirtualAddressLimit = 30; {Size of the user address space in MB
  1337. (i.e. the value of the rounded
  1338. VIRTUALADDRESSLIMIT as specified in
  1339. CONFIG.SYS, or the default value of
  1340. 512).}
  1341. svMax = 30; {The maximum parameter number
  1342. for WSeB/MCP/eCS.}
  1343. {Aliases for compatibility...}
  1344. QSV_MAX_PATH_LENGTH = svMaxPathLength;
  1345. QSV_MAX_TEXT_SESSIONS = svMaxTextSessions;
  1346. QSV_MAX_PM_SESSIONS = svMaxPMSessions;
  1347. QSV_MAX_VDM_SESSIONS = svMaxVDMSessions;
  1348. QSV_BOOT_DRIVE = svBootDrive;
  1349. QSV_DYN_PRI_VARIATION = svDynPriVariation;
  1350. QSV_MAX_WAIT = svMaxWait;
  1351. QSV_MIN_SLICE = svMinSlice;
  1352. QSV_MAX_SLICE = svMaxSlice;
  1353. QSV_PAGE_SIZE = svPageSize;
  1354. svMajorVersion = svVersionMajor;
  1355. QSV_VERSION_MAJOR = svVersionMajor;
  1356. svMinorVersion = svVersionMinor;
  1357. QSV_VERSION_MINOR = svVersionMinor;
  1358. svRevision = svVersionRevision;
  1359. QSV_VERSION_REVISION = svVersionRevision;
  1360. QSV_MS_COUNT = svMsCount;
  1361. QSV_TIME_LOW = svTimeLow;
  1362. QSV_TIME_HIGH = svTimeHigh;
  1363. svPhysMem = svTotPhysMem;
  1364. QSV_TOTPHYSMEM = svTotPhysMem;
  1365. svResMem = svTotResMem;
  1366. QSV_TOTRESMEM = svTotResMem;
  1367. svAvailMem = svTotAvailMem;
  1368. QSV_TOTAVAILMEM = svTotAvailMem;
  1369. svPrMem = svMaxPrMem;
  1370. svShMem = svMaxShMem;
  1371. QSV_MAXPRMEM = svMaxPrMem;
  1372. QSV_MAXSHMEM = svMaxShMem;
  1373. QSV_TIMER_INTERVAL = svTimerInterval;
  1374. QSV_MAX_COMP_LENGTH = svMaxCompLength;
  1375. QSV_FOREGROUND_FS_SESSION = svForegroundFSSession;
  1376. svForegroundSession = svForegroundFSSession;
  1377. QSV_FOREGROUND_PROCESS = svForegroundProcess;
  1378. QSV_NUMPROCESSORS = svNumProcessors;
  1379. QSV_MAXHPRMEM = svMaxHPrMem;
  1380. QSV_MAXHSHMEM = svMaxHShMem;
  1381. QSV_MAXPROCESSES = svMaxProcesses;
  1382. QSV_VIRTUALADDRESSLIMIT = svVirtualAddressLimit;
  1383. QSV_MAX = svMax;
  1384. {Get one or more system variables.
  1385. First = First variable to get.
  1386. Last = Last variable to get.
  1387. Buf = Receives variables.
  1388. BufSize = Size of the buffer (every system variable is a cardinal).}
  1389. function DosQuerySysInfo(First,Last:cardinal;var Buf;BufSize:cardinal):cardinal;
  1390. cdecl;
  1391. type
  1392. TQSVValues = array [1..svMax] of cardinal;
  1393. PQSVValues = ^TQSVValues;
  1394. function DosQuerySysInfo(First,Last:cardinal;Buf:PQSVValues;
  1395. BufSize:cardinal):cardinal;cdecl;
  1396. {Return information about a partitionable disk.}
  1397. function DosPhysicalDisk(Func:cardinal;Buf:pointer;BufSize:cardinal;
  1398. Params:pointer;ParamSize:cardinal):cardinal; cdecl;
  1399. {****************************************************************************
  1400. Memory allocation related routines.
  1401. ****************************************************************************}
  1402. const mfPag_Read = $00001; {Give read access to memory.}
  1403. mfPag_Write = $00002; {Give write access to memory.}
  1404. mfPag_Execute = $00004; {Allow code execution in memory.}
  1405. mfPag_Guard = $00008; {Used for dynamic memory growing. Create
  1406. uncommitted memory and make the first
  1407. page guarded. Once it is accessed it
  1408. will be made committed, and the next
  1409. uncommitted page will be made guarded.}
  1410. mfPag_Commit = $00010; {Make the memory committed.}
  1411. mfPag_Decommit = $00020; {Decommit the page.}
  1412. mfObj_Tile = $00040; {Also allocate 16-bit segments of 64k
  1413. which map the memory. (Makes 16<>32 bit
  1414. pointer conversion possible.}
  1415. mfObj_Protected = $00080;
  1416. mfObj_Gettable = $00100;
  1417. mfObj_Giveable = $00200;
  1418. mfObj_Any = $00400; {Allow using high memory (> 512 MB).}
  1419. mfPag_Default = $00400;
  1420. mfPag_Shared = $02000;
  1421. mfPag_Free = $04000;
  1422. mfPag_Base = $10000;
  1423. mfSub_Init = $00001; {Use base, if not set, choose a base
  1424. address yourself.}
  1425. mfSub_Grow = $00002; {Grow the specified heap, instead of
  1426. allocating it. Ignore mfSub_Init.}
  1427. mfSub_Sparse = $00004;
  1428. mfSub_Serialize = $00008;
  1429. (* Plus a little bit compatibility... *)
  1430. pag_Read = mfPag_Read;
  1431. pag_Write = mfPag_Write;
  1432. pag_Execute = mfPag_Execute;
  1433. pag_Guard = mfPag_Guard;
  1434. pag_Commit = mfPag_Commit;
  1435. pag_Decommit = mfPag_Decommit;
  1436. obj_Tile = mfObj_Tile;
  1437. obj_Protected = mfObj_Protected;
  1438. obj_Gettable = mfObj_Gettable;
  1439. obj_Giveable = mfObj_Giveable;
  1440. obj_Any = mfObj_Any;
  1441. pag_Default = mfPag_Default;
  1442. pag_Shared = mfPag_Shared;
  1443. pag_Free = mfPag_Free;
  1444. pag_Base = mfPag_Base;
  1445. sub_Init = mfSub_Init;
  1446. sub_Grow = mfSub_Grow;
  1447. sub_Sparse = mfSub_Sparse;
  1448. sub_Serialize = mfSub_Serialize;
  1449. {Get some memory.
  1450. P = Pointer to memory will be returned here.
  1451. Size = Number of bytes to get. The size is rounded up to a multiple
  1452. of 4096. This is probably not the case on non-intel 386
  1453. versions of OS/2.
  1454. Flags = One or more of the mfXXXX constants.}
  1455. function DosAllocMem(var P:pointer;Size,Flag:cardinal):cardinal; cdecl;
  1456. {Free a memory block.}
  1457. function DosFreeMem(P:pointer):cardinal; cdecl;
  1458. {Set settings for a block of memory.
  1459. P = Pointer to the memory. Doesn't need to be the start of the
  1460. memory block allocated with DosAllocMem, but must be a multiple
  1461. of 4096.
  1462. Size = Number of bytes to change settings for. Is rounded up to a
  1463. multile of 4096.
  1464. Flags = New flags for the memory.}
  1465. function DosSetMem(P:pointer;Size,Flag:cardinal):cardinal; cdecl;
  1466. {Give another process access to a shared memory block.
  1467. P = Pointer to the shared memory object.
  1468. PID = Process of destination process.
  1469. Flag = Permissions the the destination process gets.}
  1470. function DosGiveSharedMem(P:pointer;PID,Flag:cardinal):cardinal; cdecl;
  1471. {Get access to a shared memory object.
  1472. P = Pointer to shared memory object.
  1473. Flag = Permissions to ask.}
  1474. function DosGetSharedMem(P:pointer;Flag:cardinal):cardinal; cdecl;
  1475. {Get access to a shared memory object that has a name.
  1476. P = Pointer to shared memory object.
  1477. Name = Name of the memory object. (Starting with '\SHAREMEM\'.
  1478. Flag = Permissions to ask.}
  1479. function DosGetNamedSharedMem(var P:pointer;Name:PAnsiChar;Flag:cardinal):cardinal;
  1480. cdecl;
  1481. function DosGetNamedSharedMem(var P:pointer;const Name:string;
  1482. Flag:cardinal):cardinal;
  1483. {Allocate memory so that it can later be shared with another program.
  1484. P = Reveives pointer to memory.
  1485. Name = Optional: name to give memory. Must start with '\SHAREMEM\'.
  1486. Use nil for the PAnsiChar or '' for the string variant for no name.
  1487. Size = Number of bytes to allocate.}
  1488. function DosAllocSharedMem(var P:pointer;Name:PAnsiChar;
  1489. Size,Flag:cardinal):cardinal; cdecl;
  1490. function DosAllocSharedMem(var P:pointer;const Name:string;Size,
  1491. Flag:cardinal):cardinal;
  1492. {Get the size and flags of a block of memory.
  1493. P = Pointer to the block of memory.
  1494. Size = Receives block size.
  1495. Flag = Receives the flags.}
  1496. function DosQueryMem(P:pointer;var Size,Flag:longint):cardinal; cdecl;
  1497. function DosQueryMem (P: pointer; var Size, Flag: cardinal): cardinal; cdecl;
  1498. {Allocate a block of memory in a heap.
  1499. Base = Pointer to the start of the heap.
  1500. P = Receives pointer to the memory bock.
  1501. Size = Number of bytes to allocate.}
  1502. function DosSubAllocMem(Base:pointer;var P:pointer;Size:cardinal):cardinal;
  1503. cdecl;
  1504. {Free a block of memory in a heap.
  1505. Base = Pointer to the start of the heap.
  1506. P = Pointer to memory block to free.
  1507. Size = Number of bytes to free.}
  1508. function DosSubFreeMem(Base,P:pointer;Size:cardinal):cardinal; cdecl;
  1509. {Turn a block of memory into a heap.
  1510. Base = Pointer to memory block to turn into a heap.
  1511. Flag = One or more of the mfSub_XXXX flags.
  1512. Size = Size of the requested heap.}
  1513. function DosSubSetMem(Base:pointer;Flag,Size:cardinal):cardinal; cdecl;
  1514. {Destroy a heap. (Memory remains allocated).
  1515. Base = Pointer to the heap to destroy.}
  1516. function DosSubUnsetMem(Base:pointer):cardinal; cdecl;
  1517. {****************************************************************************
  1518. Semaphore related routines
  1519. ****************************************************************************}
  1520. const smShared = $0001; {Semaphore is shared.}
  1521. smMWWaitAny = $0002; {MuxWait only: Wait until a semaphore
  1522. is cleared.}
  1523. smMWWaitAll = $0004; {MuxWait only: Wait until all semaphores
  1524. are cleared.}
  1525. Sem_Indefinite_Wait = cardinal (-1);
  1526. {DosRequestMutExSem blocks the calling
  1527. thread indefinitely.}
  1528. Sem_Immediate_Return = 0; {DosRequestMutExSem returns immediately
  1529. without blocking the calling thread.}
  1530. (* The following two flag values are only available
  1531. on Warp 3 FP 29, Warp 4 FP 5 and above. *)
  1532. dce_AutoReset = $1000; {This will cause the (event) semaphore
  1533. to be reset automatically at the time
  1534. it is posted.}
  1535. dce_PostOne = $0800; {This will cause only one thread to be
  1536. posted where multiple threads are
  1537. waiting on an event semaphore created
  1538. with this attribute. dce_PostOne also
  1539. causes the semaphore to be reset
  1540. automatically when it is posted.}
  1541. (* The following just for compatibility. *)
  1542. dcMW_Wait_Any = smMWWaitAny;
  1543. dcMW_Wait_All = smMWWaitAll;
  1544. type PSemRecord=^TSemRecord;
  1545. TSemRecord=record
  1546. Semaphore: THandle; {Handle of semaphore to link.}
  1547. User: cardinal;
  1548. end;
  1549. PSemArray=^TSemArray;
  1550. TSemArray=array[0..$ffff] of TSemRecord;
  1551. {Create an event semaphore.
  1552. Name = Optional: Name of semaphore to create. Must start with '\SEM32\.
  1553. Use nil for PAnsiChar or '' for string variant for noname. An
  1554. unnamed semaphore is not shared unless the sm_Shared flag is
  1555. set.
  1556. Handle = Receives handle of semaphore.
  1557. Attr = One or more of the smXXXX constants.
  1558. State = Initial state: 0 = Reset (false), 1 = Posted (true).}
  1559. function DosCreateEventSem (Name: PAnsiChar;var Handle: THandle;
  1560. Attr, State: cardinal): cardinal; cdecl;
  1561. function DosCreateEventSem (const Name: string; var Handle: THandle;
  1562. Attr, State: cardinal): cardinal;
  1563. function DosCreateEventSem (Name: PAnsiChar;var Handle: THandle;
  1564. Attr: cardinal; State: boolean): cardinal;
  1565. function DosCreateEventSem (const Name: string; var Handle: THandle;
  1566. Attr: cardinal; State: boolean): cardinal;
  1567. {Open a semaphore created by another process or thread.
  1568. Name = Name of semaphore.
  1569. Handle = Receives handle of semaphore.}
  1570. function DosOpenEventSem (Name: PAnsiChar; var Handle: THandle): cardinal; cdecl;
  1571. function DosOpenEventSem (const Name: string; var Handle: THandle): cardinal;
  1572. {Close an event semaphore.
  1573. Handle = Handle of a semaphore to close.}
  1574. function DosCloseEventSem (Handle: THandle): cardinal; cdecl;
  1575. {Reset an event semaphore: *** probeer *** operation.
  1576. Handle = Handle of semaphore.
  1577. PostCount = Number of times DosPostEventSem has been called since last
  1578. reset.
  1579. Note: Returns errorcode 300 if semaphore is already reset.}
  1580. function DosResetEventSem(Handle:longint;var PostCount:longint):cardinal;
  1581. cdecl;
  1582. function DosResetEventSem (Handle: THandle; var PostCount: cardinal): cardinal;
  1583. cdecl;
  1584. {Post an event semaphore: *** verhoog *** operation.
  1585. Handle = Handle of semaphore.
  1586. Note: Returns errorcode 299 if semaphore is already posted.}
  1587. function DosPostEventSem (Handle: THandle): cardinal; cdecl;
  1588. {Wait until an event semaphore is posted (wait until *** verhoog *** operation).
  1589. Handle = Handle of semaphore.
  1590. Timeout = Return with errorcode if timeout milliseconds have past and the
  1591. semaphore is still reset. To return immediately use 0,
  1592. to wait forever use -1.}
  1593. function DosWaitEventSem (Handle: THandle; Timeout: cardinal): cardinal; cdecl;
  1594. {Check if an event semaphore is posted (if a *** verhoog *** operation has been done).
  1595. Handle = Handle of semaphore.
  1596. Posted = Receives number of times DosPostEventSem was called since
  1597. the last reset.}
  1598. function DosQueryEventSem (Handle: longint; var Posted: longint): cardinal;
  1599. cdecl;
  1600. function DosQueryEventSem (Handle: THandle; var Posted: cardinal): cardinal;
  1601. cdecl;
  1602. {Create a Mutual Exclusion semaphore (mutex).
  1603. Name = Optional: Name to give to semaphore. Must start with '\SEM32\'.
  1604. Use nil for PAnsiChar or '' for string variant to use no name.
  1605. If a name if used the semaphore is shared.
  1606. Handle = Receives handle of semaphore.
  1607. Attr = One or more of the smXXXX constants.
  1608. State = Initial state: (0/false=Not owned, 1/true=Owned.)}
  1609. function DosCreateMutExSem (Name: PAnsiChar; var Handle: THandle;
  1610. Attr: cardinal; State: boolean): cardinal;
  1611. function DosCreateMutExSem (const Name: string; var Handle: THandle;
  1612. Attr: cardinal; State: boolean): cardinal;
  1613. function DosCreateMutExSem (Name: PAnsiChar; var Handle: THandle;
  1614. Attr, State: cardinal): cardinal; cdecl;
  1615. function DosCreateMutExSem (const Name: string; var Handle: THandle;
  1616. Attr, State: cardinal): cardinal;
  1617. {Open a shared mutex semaphore.
  1618. Name = Name of semaphore to open, always starts with '\SEM32\'.
  1619. Handle = Receives handle to semaphore.}
  1620. function DosOpenMutExSem (Name: PAnsiChar; var Handle: THandle): cardinal; cdecl;
  1621. function DosOpenMutExSem (const Name: string; var Handle: THandle): cardinal;
  1622. {Close a mutex semaphore.
  1623. handle = Handle of semaphore to close.}
  1624. function DosCloseMutExSem (Handle: THandle): cardinal; cdecl;
  1625. {Request ownership of a mutex semaphore. If the semaphore is already owned the
  1626. process is halted until the semaphore is released.
  1627. Handle = Handle of semaphore.
  1628. Timeout = Return with errorcode if the semaphore is still owned after
  1629. timeout milliseconds; special values are Sem_Indefinite_Wait
  1630. and Sem_Immediate_Return.}
  1631. function DosRequestMutExSem (Handle: THandle; Timeout: cardinal): cardinal;
  1632. cdecl;
  1633. {Release the ownership of a mutex semaphore.
  1634. Handle = Handle of semaphore to release.}
  1635. function DosReleaseMutExSem (Handle: THandle): cardinal; cdecl;
  1636. {Query the PID and TIB of the owner of a mutex semaphore.
  1637. Handle = Handle of semaphore.
  1638. PID = Receives process ID of owner.
  1639. TID = Receives thread ID of owner.
  1640. Count = Number of threads (within and outside current process) waiting
  1641. for ownership of semaphore.}
  1642. function DosQueryMutExSem(Handle:longint;var PID,TID,Count:longint):
  1643. cardinal; cdecl;
  1644. function DosQueryMutExSem (Handle: THandle; var PID, TID, Count: cardinal):
  1645. cardinal; cdecl;
  1646. {Create a Multiple Wait (MuxWait) semaphore.
  1647. Name = Optional: Name to give semaphore. Must start with '\SEM32\'.
  1648. Use nil for PAnsiChar or '' for string variant to use no name.
  1649. If a name if used the semaphore is shared.
  1650. Handle = Receives handle of semaphore.
  1651. CSemRec = Number of semaphores to link muxwait semaphore with.
  1652. SemArray = Array of semaphore records to link with muxwait semaphore.
  1653. Attr = One or more of the smXXXX constants.}
  1654. function DosCreateMuxWaitSem (Name: PAnsiChar; var Handle: THandle;
  1655. CSemRec: cardinal; var SemArray: TSemArray; Attr: cardinal): cardinal; cdecl;
  1656. function DosCreateMuxWaitSem (Name: PAnsiChar; var Handle: THandle;
  1657. CSemRec: cardinal; SemArray: PSemArray; Attr: cardinal): cardinal; cdecl;
  1658. function DosCreateMuxWaitSem (const Name: string; var Handle: THandle;
  1659. CSemRec: cardinal; var SemArray: TSemArray;
  1660. Attr: cardinal): cardinal;
  1661. {Open a MuxWait semaphore.
  1662. Name = Name of semaphore to open.
  1663. Handle = Receives handle of semaphore.}
  1664. function DosOpenMuxWaitSem (Name: PAnsiChar; var Handle: THandle): cardinal; cdecl;
  1665. function DosOpenMuxWaitSem (const Name: string; var Handle: THandle): cardinal;
  1666. {Close a MuxWait semaphore.}
  1667. function DosCloseMuxWaitSem (Handle: THandle): cardinal; cdecl;
  1668. {Wait for the MuxWait semaphore to be cleared.
  1669. Handle = Handle of semaphore.
  1670. Timeout = Timeout. See above.
  1671. User = Receives user value of the semaphore that caused the muxwait
  1672. semaphore to be cleared.}
  1673. function DosWaitMuxWaitSem(Handle:longint;Timeout:longint;
  1674. var User:longint):cardinal;cdecl;
  1675. function DosWaitMuxWaitSem (Handle: THandle; Timeout: cardinal;
  1676. var User: cardinal): cardinal; cdecl;
  1677. {Add a semaphore to the MuxWait semaphore.
  1678. Handle = Handle of semaphore.
  1679. SemRec = The semaphore to add.}
  1680. function DosAddMuxWaitSem (Handle: THandle; var SemRec: TSemRecord): cardinal;
  1681. cdecl;
  1682. {Remove a semaphore from the MuxWait semaphore.
  1683. Handle = Handle of muxwait semaphore.
  1684. Sem = Handle of semaphore to remove.}
  1685. function DosDeleteMuxWaitSem (Handle, Sem: THandle): cardinal; cdecl;
  1686. {Query the semaphores from a MuxWait semaphore.
  1687. Handle = Handle of semaphore.
  1688. CSemRec = Input: Size of our array. Output: Number of items in array.
  1689. SemRecs = Array where TSemRecords are stored.
  1690. Attr = Flags used by creation of semaphore.}
  1691. function DosQueryMuxWaitSem (Handle: longint; var CSemRec: longint;
  1692. var SemRecs: TSemArray; var Attr: longint): cardinal; cdecl;
  1693. function DosQueryMuxWaitSem (Handle: THandle; var CSemRec: cardinal;
  1694. var SemRecs: TSemArray; var Attr: cardinal): cardinal; cdecl;
  1695. {****************************************************************************
  1696. Timing related routines.
  1697. ****************************************************************************}
  1698. type TDateTime=packed record
  1699. case byte of
  1700. 1:
  1701. (Hour,
  1702. Minute,
  1703. Second,
  1704. Sec100,
  1705. Day,
  1706. Month: byte;
  1707. Year: word;
  1708. TimeZone: smallint;
  1709. WeekDay: byte);
  1710. 2: (* For compatibility *)
  1711. (Hours,
  1712. Minutes,
  1713. Seconds,
  1714. Hundredths,
  1715. _Day,
  1716. _Month: byte;
  1717. _Year: word;
  1718. _TimeZone: smallint;
  1719. _WeekDay: byte);
  1720. end;
  1721. PDateTime=^TDateTime;
  1722. {Get the date and time.}
  1723. function DosGetDateTime(var Buf:TDateTime):cardinal; cdecl;
  1724. {Set the date and time.}
  1725. function DosSetDateTime(var Buf:TDateTime):cardinal; cdecl;
  1726. {Start a one shot timer.
  1727. MSec = Number of miliseconds the timer will run.
  1728. HSem = Handle of event semaphore that is posted when time has expired.
  1729. TimHandle = Receives timer handle.}
  1730. function DosAsyncTimer (MSec: cardinal; HSem: THandle;
  1731. var TimHandle: THandle): cardinal; cdecl;
  1732. {Start a cyclic timer.
  1733. MSec = Number of miliseconds the timer will run.
  1734. HSem = Handle of event semaphore that is posted when time has expired.
  1735. TimHandle = Receives timer handle.}
  1736. function DosStartTimer (MSec: cardinal; HSem: THandle;
  1737. var TimHandle: THandle): cardinal; cdecl;
  1738. {Stop a timer and destroy its handle. There is no need to check for an
  1739. error code if you know your timer handle is correct.}
  1740. function DosStopTimer (TimHandle: THandle): cardinal; cdecl;
  1741. {Get the frequency of the high resolution timer.}
  1742. function DosTmrQueryFreq(var Freq:longint):cardinal; cdecl;
  1743. function DosTmrQueryFreq(var Freq:cardinal):cardinal; cdecl;
  1744. {Get the current value of the high resolution timer.}
  1745. function DosTmrQueryTime(var Time:comp):cardinal; cdecl;
  1746. function DosTmrQueryTime (var Time: QWord): cardinal; cdecl;
  1747. {****************************************************************************
  1748. DLL specific routines.
  1749. ****************************************************************************}
  1750. {Load a DLL in memory if it is not yet loaded.
  1751. ObjName = When the DLL cannot be found, or one of the DLL's it needs
  1752. cannot be found, the name of the DLL will be put here.
  1753. ObjLen = Size of the ObjName result buffer.
  1754. DLLName = Name of DLL to load. Do not give an extension or a path,
  1755. just the name. OS/2 will automatically search through the
  1756. LIBPATH for the DLL.
  1757. Handle = Receives DLL handle.}
  1758. function DosLoadModule (ObjName: PAnsiChar; ObjLen: cardinal; DLLName: PAnsiChar;
  1759. var Handle: THandle): cardinal; cdecl;
  1760. function DosLoadModule (var ObjName: string; ObjLen: cardinal;
  1761. const DLLName: string; var Handle: THandle): cardinal;
  1762. {Let OS/2 know that we do not need a DLL anymore. If we were the only process
  1763. using the DLL, it is unloaded.}
  1764. function DosFreeModule (Handle: THandle): cardinal; cdecl;
  1765. {Get the address of a procedure.
  1766. Handle = DLL handle,
  1767. Ordinal = Procedure to get address for. 0=Use its name.
  1768. ProcName = Name of the procedure to query address for. Must be nil
  1769. for PAnsiChar or '' for string variant if Ordinal is nonzero.
  1770. Address = Receives address of procedure.}
  1771. function DosQueryProcAddr (Handle: THandle; Ordinal: cardinal; ProcName: PAnsiChar;
  1772. var Address: pointer): cardinal; cdecl;
  1773. function DosQueryProcAddr (Handle: THandle; Ordinal: cardinal;
  1774. const ProcName: string; var Address: pointer): cardinal;
  1775. {Get the handle of a loaded DLL or a loaded executable.
  1776. DLLName = Name of DLL.
  1777. Handle = Receives DLL handle if present.}
  1778. function DosQueryModuleHandle (DLLName: PAnsiChar; var Handle: THandle): cardinal;
  1779. cdecl;
  1780. function DosQueryModuleHandle (const DLLName: string;
  1781. var Handle: THandle): cardinal;
  1782. {Get the pathname of a loaded DLL or a loaded executable.
  1783. Handle = Handle of DLL.
  1784. NameLen = Maximum length of AnsiChar array.
  1785. Name = PAnsiChar (or string) where name is returned.}
  1786. function DosQueryModuleName (Handle: THandle; NameLen: cardinal;
  1787. Name: PAnsiChar): cardinal; cdecl;
  1788. {function DosQueryModuleName(Handle:THandle;var Name:OpenString):cardinal;}
  1789. const pt16bit=0;
  1790. pt32bit=1;
  1791. {Return if a procedure is either 16 or 32 bit.
  1792. Handle = Handle of DLL.
  1793. Ordinal = DLL index number. 0 means use Name.
  1794. Name = Must be nil for PAnsiChar or '' for string variant if Ordinal
  1795. is zero. Otherwise it contains the procedure name.
  1796. ProcType = One of the ptXXXX constants.}
  1797. function DosQueryProcType (Handle,Ordinal:longint;Name:PAnsiChar;
  1798. var ProcType:longint):cardinal; cdecl;
  1799. function DosQueryProcType(Handle,Ordinal:longint;const Name:string;
  1800. var ProcType:longint):cardinal;
  1801. function DosQueryProcType (Handle: THandle; Ordinal: cardinal; Name:PAnsiChar;
  1802. var ProcType: cardinal): cardinal; cdecl;
  1803. function DosQueryProcType (Handle: THandle; Ordinal: cardinal; const Name: string;
  1804. var ProcType: cardinal): cardinal;
  1805. {****************************************************************************
  1806. Resource related routines.
  1807. ****************************************************************************}
  1808. {Possible resource types:}
  1809. const rtPointer = 1; {Mouse pointer.}
  1810. rtBitmap = 2; {Bitmap}
  1811. rtMenu = 3; {Menu template.}
  1812. rtDialog = 4; {Dialog template.}
  1813. rtString = 5; {A string table.}
  1814. rtFontDir = 6; {Font directory.}
  1815. rtFont = 7; {A font.}
  1816. rtAccelTable = 8; {Accelerator table.}
  1817. rtRcData = 9; {Binary data.}
  1818. rtMessage = 10; {Error message table.}
  1819. rtDlgInclude = 11; {Dialog include filename.}
  1820. rtVKeyTbl = 12; {Key to vkey tables.}
  1821. rtKeyTbl = 13; {Key to ugl tables.}
  1822. rtCharTbl = 14; {Glyph to character tables.}
  1823. rtDisplayInfo = 15; {Screen display information.}
  1824. rtFKAShort = 16; {Function key area short form.}
  1825. rtFKALong = 17; {Function key area long form.}
  1826. rtHelpTable = 18; {Help table.}
  1827. rtHelpSubTable = 19; {Sub help table.}
  1828. rtFDDir = 20; {DBCS unique/font driver directory.}
  1829. rtFD = 21; {DBCS unique/font driver.}
  1830. {Get the address of a resource object.
  1831. Handle = Handle of DLL (or executable) to get resource from.
  1832. ResType = One of the rtXXXX constants.
  1833. ResName = Number associated to resource object by resource compiler.}
  1834. function DosGetResource (Handle: THandle; ResType, ResName: cardinal;
  1835. var P: pointer): cardinal; cdecl;
  1836. {Remove a resource object from memory.
  1837. P = Pointer to resource.}
  1838. function DosFreeResource (P: pointer): cardinal; cdecl;
  1839. {Get the size of a resource object.
  1840. Handle = Handle to DLL (or executable).
  1841. IDT = One of the rtXXXX constants.
  1842. IDN = Number associated to resource object by resource compiler.
  1843. Size = Receives resource size.}
  1844. function DosQueryResourceSize (Handle,IDT,IDN:longint;var Size:longint):cardinal;
  1845. cdecl;
  1846. function DosQueryResourceSize (Handle: THandle; IDT, IDN: cardinal;
  1847. var Size: cardinal): cardinal; cdecl;
  1848. {****************************************************************************
  1849. Country and codepage specific routines.
  1850. ****************************************************************************}
  1851. type TCountryCode=record
  1852. Country, {Country to query info about (0=current).}
  1853. CodePage:cardinal; {Code page to query info about (0=current).}
  1854. end;
  1855. PCountryCode=^TCountryCode;
  1856. CountryCode=TCountryCode;
  1857. TTimeFmt=(Clock12,Clock24);
  1858. TCountryInfo=record
  1859. Country,CodePage:cardinal; {Country and codepage requested.}
  1860. case byte of
  1861. 0:(
  1862. DateFormat:cardinal; {1=ddmmyy 2=yymmdd 3=mmddyy}
  1863. CurrencyUnit:array[0..4] of AnsiChar;
  1864. ThousandSeparator:AnsiChar; {Thousands separator.}
  1865. Zero1:byte; {Always zero.}
  1866. DecimalSeparator:AnsiChar; {Decimals separator,}
  1867. Zero2:byte;
  1868. DateSeparator:AnsiChar; {Date separator.}
  1869. Zero3:byte;
  1870. TimeSeparator:AnsiChar; {Time separator.}
  1871. Zero4:byte;
  1872. CurrencyFormat, {Bit field:
  1873. Bit 0: 0=indicator before value
  1874. 1=indicator after value
  1875. Bit 1: 1=insert space after
  1876. indicator.
  1877. Bit 2: 1=Ignore bit 0&1, replace
  1878. decimal separator with
  1879. indicator.}
  1880. DecimalPlace:byte; {Number of decimal places used in
  1881. currency indication.}
  1882. TimeFormat:TTimeFmt; {12/24 hour.}
  1883. Reserve1:array[0..1] of word;
  1884. DataSeparator:AnsiChar; {Data list separator}
  1885. Zero5:byte;
  1886. Reserve2:array[0..4] of word);
  1887. 1:(
  1888. fsDateFmt:cardinal; {1=ddmmyy 2=yymmdd 3=mmddyy}
  1889. szCurrency:array[0..4] of AnsiChar; {null terminated currency symbol}
  1890. szThousandsSeparator:array[0..1] of AnsiChar;
  1891. {Thousands separator + #0}
  1892. szDecimal:array[0..1] of AnsiChar; {Decimals separator + #0}
  1893. szDateSeparator:array[0..1] of AnsiChar;
  1894. {Date separator + #0}
  1895. szTimeSeparator:array[0..1] of AnsiChar;
  1896. {Time separator + #0}
  1897. fsCurrencyFmt, {Bit field:
  1898. Bit 0: 0=indicator before value
  1899. 1=indicator after value
  1900. Bit 1: 1=insert space after
  1901. indicator.
  1902. Bit 2: 1=Ignore bit 0&1, replace
  1903. decimal separator with
  1904. indicator}
  1905. cDecimalPlace:byte; {Number of decimal places used in
  1906. currency indication}
  1907. fsTimeFmt:byte; {0=12,1=24 hours}
  1908. abReserved1:array[0..1] of word;
  1909. szDataSeparator:array[0..1] of AnsiChar;
  1910. {Data list separator + #0}
  1911. abReserved2:array[0..4] of word);
  1912. end;
  1913. PCountryInfo=^TCountryInfo;
  1914. CountryInfo=TCountryInfo;
  1915. TDBCSRange=record
  1916. Start,Stop:byte;
  1917. end;
  1918. TDBCSArray=array[0..$ffff] of TDBCSRange;
  1919. PDBCSArray=^TDBCSArray;
  1920. const CurrentCountry:TCountryCode=(Country:0;CodePage:0);
  1921. {Get country specific information.
  1922. Size = Size of our datastructure. (SizeOf(TCountryInfo))
  1923. ActualSize = Size of OS/2's datastructure. ActualSize bytes of
  1924. our TCountryInfo have been filled.}
  1925. function DosQueryCtryInfo(Size:longint;var Country:TCountryCode;
  1926. var Res:TCountryInfo;var ActualSize:longint):cardinal; cdecl;
  1927. function DosQueryCtryInfo(Size:cardinal;var Country:TCountryCode;
  1928. var Res:TCountryInfo;var ActualSize:cardinal):cardinal; cdecl;
  1929. {Get info about a code page with a DBCS character set.}
  1930. function DosQueryDBCSEnv(Size:cardinal;var Country:TCountryCode;
  1931. Buf:PAnsiChar):cardinal; cdecl;
  1932. {Convert a string to uppercase.
  1933. Size = Length of string.
  1934. Country = Country and codepage for converting.
  1935. AString = String to convert.}
  1936. function DosMapCase(Size:cardinal;var Country:TCountryCode;
  1937. AString:PAnsiChar):cardinal; cdecl;
  1938. function DosMapCase(var Country:TCountryCode;
  1939. var AString:string):cardinal;
  1940. {Get a collate table (a table for comparing which character is smaller and
  1941. which one is greater).
  1942. Size = Length of the databuffer the program has.
  1943. Country = Country to query table for. (0,0) is default country and
  1944. codepage.
  1945. Buf = Buffer to return table in. It's filled with the sort
  1946. weights of the ascii code. For example the 128th byte
  1947. contains the weight for ascii code 128.
  1948. TableLen = Length of collating table.}
  1949. function DosQueryCollate(Size:longint;var Country:TCountryCode;
  1950. Buf:PByteArray;var TableLen:longint):cardinal; cdecl;
  1951. function DosQueryCollate (Size: cardinal; var Country: TCountryCode;
  1952. Buf:PByteArray; var TableLen: cardinal): cardinal; cdecl;
  1953. {Get the current codepage. The return buffer (CodePages) is filled with the
  1954. current code page followed by the list of prepared codepages as specified in
  1955. CONFIG.SYS - all of them returned as DWORDs, typically not more than 3 should
  1956. be necessary. Return value of 473 indicates that not all values fit into the
  1957. provided space.}
  1958. function DosQueryCP(Size:longint; PCodePages: PWordArray;
  1959. var ActSize:longint):cardinal; cdecl;
  1960. function DosQueryCP(Size: cardinal; PCodePages: PWordArray;
  1961. var ActSize:cardinal):cardinal; cdecl;
  1962. function DosQueryCP (Size: cardinal; var CodePages;
  1963. var ActSize: cardinal): cardinal; cdecl;
  1964. {Change the codepage, but only for the current process.}
  1965. function DosSetProcessCP (CP: cardinal): cardinal; cdecl;
  1966. {****************************************************************************
  1967. Exception handling related functions
  1968. ****************************************************************************}
  1969. {Exception constants.}
  1970. const
  1971. Xcpt_Continue_Search = $00000000;
  1972. Xcpt_Continue_Execution = $ffffffff;
  1973. Xcpt_Continue_Stop = $00716668;
  1974. Xcpt_Signal_Intr = $1;
  1975. Xcpt_Signal_KillProc = $3;
  1976. Xcpt_Signal_Break = $4;
  1977. Xcpt_Fatal_Exception = $c0000000;
  1978. Xcpt_Severity_Code = $c0000000;
  1979. Xcpt_Customer_Code = $20000000;
  1980. Xcpt_Facility_Code = $1fff0000;
  1981. Xcpt_Exception_Code = $0000ffff;
  1982. Xcpt_Unknown_Access = $00000000;
  1983. Xcpt_Read_Access = $00000001;
  1984. Xcpt_Write_Access = $00000002;
  1985. Xcpt_Execute_Access = $00000004;
  1986. Xcpt_Space_Access = $00000008;
  1987. Xcpt_Limit_Access = $00000010;
  1988. Xcpt_Data_Unknown = $ffffffff;
  1989. Xcpt_Guard_Page_Violation = $80000001;
  1990. Xcpt_Unable_To_Grow_Stack = $80010001;
  1991. Xcpt_Access_Violation = $c0000005;
  1992. Xcpt_In_Page_Error = $c0000006;
  1993. Xcpt_Illegal_Instruction = $c000001c;
  1994. Xcpt_Invalid_Lock_Sequence = $c000001d;
  1995. Xcpt_Noncontinuable_Exception = $c0000024;
  1996. Xcpt_Invalid_Disposition = $c0000025;
  1997. Xcpt_Unwind = $c0000026;
  1998. Xcpt_Bad_Stack = $c0000027;
  1999. Xcpt_Invalid_Unwind_Target = $c0000028;
  2000. Xcpt_Array_Bounds_Exceeded = $c0000093;
  2001. Xcpt_Float_Denormal_Operand = $c0000094;
  2002. Xcpt_Float_Divide_By_Zero = $c0000095;
  2003. Xcpt_Float_Inexact_Result = $c0000096;
  2004. Xcpt_Float_Invalid_Operation = $c0000097;
  2005. Xcpt_Float_Overflow = $c0000098;
  2006. Xcpt_Float_Stack_Check = $c0000099;
  2007. Xcpt_Float_Underflow = $c000009a;
  2008. Xcpt_Integer_Divide_By_Zero = $c000009b;
  2009. Xcpt_Integer_Overflow = $c000009c;
  2010. Xcpt_Privileged_Instruction = $c000009d;
  2011. Xcpt_Datatype_Misalignment = $c000009e;
  2012. Xcpt_Breakpoint = $c000009f;
  2013. Xcpt_Single_Step = $c00000a0;
  2014. Xcpt_Process_Terminate = $c0010001;
  2015. Xcpt_Async_Process_Terminate = $c0010002;
  2016. Xcpt_Signal = $c0010003;
  2017. Context_Control = $00000001; { SS:ESP, CS:EIP, EFLAGS and EBP set }
  2018. Context_Integer = $00000002; { EAX, EBX, ECX, EDX, ESI and EDI set }
  2019. Context_Segments = $00000004; { DS, ES, FS, and GS set }
  2020. Context_Floating_Point = $00000008; { numeric coprocessor state set }
  2021. Context_Full = Context_Control or
  2022. Context_Integer or
  2023. Context_Segments or
  2024. Context_Floating_Point;
  2025. const
  2026. MaxExceptionParameters = 4; { Enough for all system exceptions. }
  2027. type PExceptionRegistrationRecord=^TExceptionRegistrationRecord;
  2028. PExceptionReportRecord=^TExceptionReportRecord;
  2029. PContextRecord=^TContextRecord;
  2030. TExceptionHandler = function (Report: PExceptionReportRecord;
  2031. RegRec: PExceptionRegistrationRecord;
  2032. Context: PContextRecord;
  2033. DispContext: pointer): cardinal;
  2034. cdecl;
  2035. TExceptionRegistrationRecord=record
  2036. Prev_Structure:PExceptionRegistrationRecord;
  2037. ExceptionHandler:TExceptionHandler;
  2038. end;
  2039. TExceptionReportRecord=record
  2040. Exception_Num,
  2041. HandlerFlags:cardinal;
  2042. Nested_RepRec:PExceptionReportRecord;
  2043. Address:pointer;
  2044. ParamCount:cardinal;
  2045. Parameters:array [0..MaxExceptionParameters] of cardinal;
  2046. end;
  2047. TContextRecord=record
  2048. ContextFlags:cardinal;
  2049. Env:array[1..7] of cardinal;
  2050. FPUStack:array[0..7] of extended;
  2051. Reg_GS,
  2052. Reg_FS,
  2053. Reg_ES,
  2054. Reg_DS,
  2055. Reg_EDI,
  2056. Reg_ESI,
  2057. Reg_EAX,
  2058. Reg_EBX,
  2059. Reg_ECX,
  2060. Reg_EDX,
  2061. Reg_EBP,
  2062. Reg_EIP,
  2063. Reg_CS,
  2064. Flags,
  2065. Reg_ESP,
  2066. Reg_SS:cardinal;
  2067. end;
  2068. {Warning!!! Never use Presentation Manager functions from exception
  2069. handlers!}
  2070. {Install an exceptionhandler. The Prev_Structure field of RegRec should be
  2071. nil, it will be filled in be OS/2. RegRec must be on the stack: It must be a
  2072. local variable.}
  2073. function DosSetExceptionHandler(var RegRec:TExceptionRegistrationRecord):cardinal;
  2074. cdecl;
  2075. {Uninstall an exception handler.}
  2076. function DosUnSetExceptionHandler(var RegRec:TExceptionRegistrationRecord
  2077. ):cardinal; cdecl;
  2078. {Trigger an exception.}
  2079. function DosRaiseException(var Excpt:TExceptionReportRecord):cardinal; cdecl;
  2080. {Send a signal to a process.}
  2081. function DosSendSignalException(PID,Exception:cardinal):cardinal; cdecl;
  2082. {Call and remove a set of exceptionhandlers}
  2083. function DosUnwindException(var Handler:TExceptionRegistrationRecord;
  2084. TargetIP:pointer;
  2085. var RepRec:TExceptionReportRecord):cardinal; cdecl;
  2086. {Full screen applications can get Ctrl-C and Ctrl-Break focus. For all
  2087. processes sharing one screen, only one can have Ctrl-C focus.
  2088. Enable = 0 = Release focus, 1 = Get focus.
  2089. Times = Number of times focus has been get minus number of times it
  2090. has been released.}
  2091. function DosSetSignalExceptionFocus(Enable:longint;var Times:longint):cardinal;
  2092. cdecl;
  2093. function DosSetSignalExceptionFocus (Enable: cardinal;
  2094. var Times: cardinal): cardinal; cdecl;
  2095. function DosSetSignalExceptionFocus (Enable: boolean;
  2096. var Times: cardinal): cardinal;
  2097. {Tell OS/2 that if an exception occurs, it must queue it up, until a
  2098. DosExitMustComplete follows. Urgent exceptions still occur. The only
  2099. possible error is that the nesting becomes too high, so error checking
  2100. is only needed in seldom cases.
  2101. Nesting = Number of DosEnterMustComplete calls minus number of
  2102. DosExitMustComplete calls.}
  2103. function DosEnterMustComplete(var Nesting:longint):cardinal; cdecl;
  2104. function DosEnterMustComplete(var Nesting:cardinal):cardinal; cdecl;
  2105. {Tell OS/2 that it can send exceptions again. See above}
  2106. function DosExitMustComplete(var Nesting:longint):cardinal; cdecl;
  2107. function DosExitMustComplete(var Nesting:cardinal):cardinal; cdecl;
  2108. {Tell we want further signal exceptions.
  2109. SignalNum = Signal nummer to acknowlegde.}
  2110. function DosAcknowledgeSignalException (SignalNum: cardinal): cardinal; cdecl;
  2111. {****************************************************************************
  2112. Queue related routines.
  2113. ****************************************************************************}
  2114. type
  2115. TRequestData = record
  2116. case boolean of
  2117. false: (PID0:longint; {ID of process that wrote element.}
  2118. Data0:longint); {Information from process
  2119. writing the data.}
  2120. true: (PID, Data: cardinal);
  2121. end;
  2122. PRequestData = ^TRequestData;
  2123. {Useful constants for priority parameters.}
  2124. const quFIFO=0;
  2125. quLIFO=1;
  2126. quPriority=2;
  2127. quNoConvert_Address=0;
  2128. quConvert_Address=4;
  2129. {Close a queue. If the calling process has created the queue, it is
  2130. destroyed. If you can guarantee the handle is correct, there is no need
  2131. to check for error codes.}
  2132. function DosCloseQueue (Handle: THandle): cardinal; cdecl;
  2133. {Create a queue. The process that creates a queue, owns that queue, and is
  2134. the only one who can read from that queue. Other processes can only write
  2135. to that queue. The queuename must have the format '\QUEUES\name.ext' .
  2136. Handle = Receives queue handle.
  2137. Priority = 0 = Use FIFO system.
  2138. 1 = Use LIFO system.
  2139. 2 = Use priority system.
  2140. Add 4 to convert addresses of data inserted by 16-bit
  2141. processes to 32 bit pointers.
  2142. Name = Name of queue to create.}
  2143. function DosCreateQueue (var Handle: THandle; Priority: cardinal;
  2144. Name: PAnsiChar): cardinal; cdecl;
  2145. function DosCreateQueue (var Handle: THandle; Priority: cardinal;
  2146. const Name: string): cardinal;
  2147. {Open an existing queue. You cannot read from the queue unless you are the
  2148. process that created it. The name must have the format '\QUEUES\name.ext'}
  2149. function DosOpenQueue(var Parent_PID:longint;var Handle:longint;
  2150. Name:PAnsiChar):cardinal; cdecl;
  2151. function DosOpenQueue(var Parent_PID:longint;var Handle:longint;
  2152. const Name:string):cardinal;
  2153. function DosOpenQueue (var Parent_PID: cardinal; var Handle: THandle;
  2154. Name: PAnsiChar): cardinal; cdecl;
  2155. function DosOpenQueue (var Parent_PID: cardinal; var Handle: THandle;
  2156. const Name: string): cardinal;
  2157. {Read a record from a queue, but do not remove it from the queue.
  2158. Handle = Handle of queue to read from.
  2159. ReqBuffer = Receives information about read data.
  2160. DataLen = Receives length of data read.
  2161. DataPtr = Receives the address of the data.
  2162. Element = 0 = Return first element in queue.
  2163. 1 = Return next element in queue. Can be repeated.
  2164. Current element number is returned here, for use
  2165. with DosReadQueue.
  2166. Wait = 0 = Wait until there is a queue element available.
  2167. 1 = Return with an error when queue is empty.
  2168. Priority = Receives priority of queue record (1..15).
  2169. ASem = Use NIL if Wait=0, give a handle of a semaphore when
  2170. Wait=1. The semaphore will be cleared when there is an
  2171. element inserted it the queue.
  2172. !! event queue}
  2173. function DosPeekQueue(Handle:longint;var ReqBuffer:TRequestData;
  2174. var DataLen:longint;var DataPtr:pointer;
  2175. var Element:longint;Wait:longint;
  2176. var Priority:byte;ASem:longint):cardinal; cdecl;
  2177. function DosPeekQueue (Handle: THandle; var ReqBuffer: TRequestData;
  2178. var DataLen: cardinal; var DataPtr: pointer;
  2179. var Element: cardinal; Wait: boolean;
  2180. var Priority: byte; ASem: THandle): cardinal;
  2181. function DosPeekQueue (Handle: THandle; var ReqBuffer: TRequestData;
  2182. var DataLen: cardinal; var DataPtr: pointer;
  2183. var Element: cardinal; Wait: cardinal;
  2184. var Priority: byte; ASem: THandle): cardinal; cdecl;
  2185. {Empty a queue. You must be the process the created the queue.}
  2186. function DosPurgeQueue (Handle: THandle): cardinal; cdecl;
  2187. {Return the number of elements in the queue.}
  2188. function DosQueryQueue(Handle:longint;var Count:longint):cardinal; cdecl;
  2189. function DosQueryQueue (Handle: THandle; var Count: cardinal): cardinal; cdecl;
  2190. {Read a record from a queue, but do not remove it from the queue.
  2191. Handle = Handle of queue to read from.
  2192. ReqBuffer = Receives information about read data.
  2193. DataLen = Receives length of data read.
  2194. DataPtr = Receives the address of the data.
  2195. Element = 0 = Return first element in queue.
  2196. Otherwise: Return the element numbered with this.
  2197. Wait = 0 = Wait until there is a queue element available.
  2198. 1 = Return with an error when queue is empty.
  2199. Priority = Receives priority of queue record (1..15).
  2200. ASem = Use NIL if Wait=0, give a handle of a semaphore when
  2201. Wait=1. The semaphore will be cleared when there is an
  2202. element inserted it the queue.
  2203. !! event queue}
  2204. function DosReadQueue(Handle:longint;var ReqBuffer:TRequestData;
  2205. var DataLen:longint;var DataPtr:pointer;
  2206. Element,Wait:longint;var Priority:byte;
  2207. ASem:longint):cardinal; cdecl;
  2208. function DosReadQueue (Handle: THandle; var ReqBuffer: TRequestData;
  2209. var DataLen: cardinal; var DataPtr: pointer;
  2210. Element, Wait: cardinal; var Priority: byte;
  2211. ASem: THandle): cardinal; cdecl;
  2212. function DosReadQueue (Handle: THandle; var ReqBuffer: TRequestData;
  2213. var DataLen: cardinal; var DataPtr: pointer;
  2214. Element: cardinal; Wait: boolean; var Priority: byte;
  2215. ASem: THandle): cardinal;
  2216. {Write a data record to a queue.
  2217. Handle = Handle of queue to write to.
  2218. Request = Value that will be inserted in the RequestData field when
  2219. element is read from queue.
  2220. DataLen = Size of data to write.
  2221. DataBuf = Data to write.
  2222. Priority = Priority of data in buffer. Only relevant when queue is
  2223. created with priority support.}
  2224. function DosWriteQueue (Handle: THandle; Request, Datalen: cardinal;
  2225. var DataBuf; Priority: cardinal): cardinal; cdecl;
  2226. {****************************************************************************
  2227. Error handling related routines.
  2228. ****************************************************************************}
  2229. const deHardErr = 1; {Hard errors are enabled, to disable
  2230. do not give this switch.}
  2231. deDisableExceptions = 2; {Exceptions are disabled, to enable
  2232. do not give this switch.}
  2233. {For compatibility with VP:}
  2234. ferr_DisableHardErr = 0; {Disable hard error popups.}
  2235. ferr_EnableHardErr = deHardErr;
  2236. ferr_EnableException = 0; {Enable exception popups.}
  2237. ferr_DisableException = deDisableExceptions;
  2238. {Disable the end user notification of hardware errors and exceptions. Users
  2239. can overide this in config.sys. By default, notification is enabled.
  2240. There is no need for error checking if you can guarantee the parameter is
  2241. correct.}
  2242. function DosError (Error: cardinal): cardinal; cdecl;
  2243. {Get information about an error code.
  2244. It cannot fail, so it is written as procedure.
  2245. Code = Error code to get info about.
  2246. _Class = Receives the error class.
  2247. Action = Receives the recommended action you should take.
  2248. Locus = Receives what could have caused the error.}
  2249. procedure DosErrClass(Code:longint;var _Class,Action,Locus:longint); cdecl;
  2250. procedure DosErrClass (Code: cardinal; var _Class, Action, Locus: cardinal);
  2251. cdecl;
  2252. {****************************************************************************
  2253. Message file specific routines.
  2254. ****************************************************************************}
  2255. type PInsertTable=^TInsertTable;
  2256. TInsertTable=array[1..9] of PAnsiChar;
  2257. {Get a message from a messagefile.
  2258. Table = Table of strings to insert.
  2259. TableSize = Number of strings in table.
  2260. Buf = Address of buffer to store message in.
  2261. BufSize = Size of buffer to store message in.
  2262. MsgNumber = Number of message to get.
  2263. FileName = Name of file to get message from.
  2264. MsgSize = The size of the message returned.}
  2265. function DosGetMessage(Table:PInsertTable;TableSize:longint;Buf:PAnsiChar;
  2266. BufSize,MsgNumber:longint;FileName:PAnsiChar;
  2267. var MsgSize:longint):cardinal;
  2268. function DosGetMessage (Table: PInsertTable; TableSize: cardinal; Buf: PAnsiChar;
  2269. BufSize, MsgNumber: cardinal; FileName: PAnsiChar;
  2270. var MsgSize: cardinal): cardinal; cdecl;
  2271. {And a variant using strings and open arrays.
  2272. function DosGetMessage(const Table:array of PString;var Buf:string;
  2273. BufSize,MsgNumber:longint;const FileName:PAnsiChar):cardinal;}
  2274. {And a variant using strings, but with a PAnsiChar buffer, because of long
  2275. messages, and open arrays.
  2276. function DosGetMessage(const Table:array of PString;Buf:PAnsiChar;
  2277. BufSize,MsgNumber:longint;const FileName:string;
  2278. MsgSize:longint):cardinal;}
  2279. {Insert textstrings into a message. The message must be loaded before with
  2280. DosGetMessage. This function is used when the insert strings are not yet
  2281. known when the message was loaded.
  2282. Table = Table of strings to insert.
  2283. TableSize = Number of struings to insert.
  2284. Message = Message to insert strings into.
  2285. SrcMessageSize = Size of message to insert strings into.
  2286. Buf = Receives adjusted message.
  2287. BufSize = Size of your buffer.
  2288. DstMessageSize = Receives size of adjusted message.}
  2289. function DosInsertMessage(Table:PInsertTable;TableSize:longint;
  2290. Message:PAnsiChar;SrcMessageSize:longint;
  2291. Buf:PAnsiChar;BufSize:longint;
  2292. var DstMessageSize:longint):cardinal; cdecl;
  2293. function DosInsertMessage (Table: PInsertTable; TableSize: cardinal;
  2294. Message: PAnsiChar; SrcMessageSize: cardinal;
  2295. Buf: PAnsiChar; BufSize: cardinal;
  2296. var DstMessageSize: cardinal): cardinal; cdecl;
  2297. {And a variant using strings and open arrays.
  2298. function DosInsertMessage(Table:array of PString;
  2299. const Message:string;
  2300. var Buf:openstring):cardinal;}
  2301. {And a variant using strings, but with a PAnsiChar buffer, because of long
  2302. messages, and open arrays.
  2303. function DosInsertMessage(Table:array of PString;
  2304. Message:PAnsiChar;SrcMessageSize:longint;
  2305. Buf:PAnsiChar;BufSize:longint;
  2306. var DstMessageSize:longint):cardinal;}
  2307. {Write a message to a file.
  2308. Handle = Handle of file.
  2309. Size = Size of message.
  2310. Buf = Buffer where message is located.}
  2311. function DosPutMessage (Handle: THandle; Size: cardinal; Buf: PAnsiChar): cardinal;
  2312. cdecl;
  2313. function DosPutMessage (Handle: THandle; const Buf: string): cardinal;
  2314. {Get info about which codepages and languages a messagefile supports.
  2315. Buf = Receives information.
  2316. BufSize = Size of buffer.
  2317. FileName = Filename of message file.
  2318. InfoSize = Receives size in bytes of the returned info.}
  2319. function DosQueryMessageCP(var Buf;BufSize:longint;FileName:PAnsiChar;
  2320. var InfoSize:longint):cardinal;
  2321. function DosQueryMessageCP(var Buf;BufSize:longint;const FileName:string;
  2322. var InfoSize:longint):cardinal;
  2323. function DosQueryMessageCP (var Buf; BufSize: cardinal; FileName: PAnsiChar;
  2324. var InfoSize: cardinal): cardinal;
  2325. function DosQueryMessageCP (var Buf; BufSize: cardinal; const FileName: string;
  2326. var InfoSize: cardinal): cardinal;
  2327. {****************************************************************************
  2328. Session specific routines.
  2329. ****************************************************************************}
  2330. const
  2331. {Start the new session independent or as a child.}
  2332. ssf_Related_Independent = 0; {Start new session independent
  2333. of the calling session.}
  2334. ssf_Related_Child = 1; {Start new session as a child
  2335. session to the calling session.}
  2336. {Start the new session in the foreground or in the background.}
  2337. ssf_FgBg_Fore = 0; {Start new session in foreground.}
  2338. ssf_FgBg_Back = 1; {Start new session in background.}
  2339. {Should the program started in the new session
  2340. be executed under conditions for tracing?}
  2341. ssf_TraceOpt_None = 0; {No trace.}
  2342. ssf_TraceOpt_Trace = 1; {Trace with no notification
  2343. of descendants.}
  2344. ssf_TraceOpt_TraceAll = 2; {Trace all descendant sessions.
  2345. A termination queue must be
  2346. supplied and Related must be
  2347. ssf_Related_Child (=1).}
  2348. {Will the new session inherit open file handles
  2349. and environment from the calling process.}
  2350. ssf_InhertOpt_Shell = 0; {Inherit from the shell.}
  2351. ssf_InhertOpt_Parent = 1; {Inherit from the calling process.}
  2352. {Specifies the type of session to start.}
  2353. ssf_Type_Default = 0; {Use program's type.}
  2354. ssf_Type_FullScreen = 1; {OS/2 full screen.}
  2355. ssf_Type_WindowableVIO = 2; {OS/2 window.}
  2356. ssf_Type_PM = 3; {Presentation Manager.}
  2357. ssf_Type_VDM = 4; {DOS full screen.}
  2358. ssf_Type_WindowedVDM = 7; {DOS window.}
  2359. {Additional values for Windows programs}
  2360. Prog_31_StdSeamlessVDM = 15; {Windows 3.1 program in its
  2361. own windowed session.}
  2362. Prog_31_StdSeamlessCommon = 16; {Windows 3.1 program in a
  2363. common windowed session.}
  2364. Prog_31_EnhSeamlessVDM = 17; {Windows 3.1 program in enhanced
  2365. compatibility mode in its own
  2366. windowed session.}
  2367. Prog_31_EnhSeamlessCommon = 18; {Windows 3.1 program in enhanced
  2368. compatibility mode in a common
  2369. windowed session.}
  2370. Prog_31_Enh = 19; {Windows 3.1 program in enhanced
  2371. compatibility mode in a full
  2372. screen session.}
  2373. Prog_31_Std = 20; {Windows 3.1 program in a full
  2374. screen session.}
  2375. {Specifies the initial attributes for a OS/2 window or DOS window session.}
  2376. ssf_Control_Visible = 0; {Window is visible.}
  2377. ssf_Control_Invisible = 1; {Window is invisible.}
  2378. ssf_Control_Maximize = 2; {Window is maximized.}
  2379. ssf_Control_Minimize = 4; {Window is minimized.}
  2380. ssf_Control_NoAutoClose = 8; {Window will not close after
  2381. the program has ended.}
  2382. ssf_Control_SetPos = 32768; {Use InitXPos, InitYPos,
  2383. InitXSize, and InitYSize for
  2384. the size and placement.}
  2385. type TStatusData=record
  2386. Length:word; {Length, in bytes, of datastructure.}
  2387. SelectIND:word; {Determines if the session can be
  2388. selected: Don't change/selectable/
  2389. not selectable (0/1/2).}
  2390. BondIND:word; {Determines which section will come
  2391. to the foreground when it is
  2392. selected: Don't change/child to
  2393. foreground when parent selected/
  2394. parent to foreground when parent
  2395. selected.}
  2396. end;
  2397. PStatusData=^TStatusData;
  2398. {Queue data structure for synchronously started sessions.}
  2399. TChildInfo = record
  2400. case boolean of
  2401. false:
  2402. (SessionID,
  2403. Return: word); {Return code from the child process.}
  2404. true:
  2405. (usSessionID,
  2406. usReturn: word); {Return code from the child process.}
  2407. end;
  2408. PChildInfo = ^TChildInfo;
  2409. TStartData=record
  2410. {Note: to omit some fields, use a length smaller than
  2411. SizeOf(TStartData).}
  2412. Length:word; {Length, in bytes, of datastructure
  2413. (24/30/32/50/60).}
  2414. Related:word; {Independent/child session (0/1).}
  2415. FgBg:word; {Foreground/background (0/1).}
  2416. TraceOpt:word; {No trace/trace this/trace all
  2417. (0/1/2).}
  2418. PgmTitle:PAnsiChar; {Program title.}
  2419. PgmName:PAnsiChar; {Filename to program.}
  2420. PgmInputs:PAnsiChar; {Command parameters (nil allowed).}
  2421. TermQ:PAnsiChar; {System queue. (nil allowed).}
  2422. Environment:PAnsiChar; {Environment to pass (nil allowed).}
  2423. InheritOpt:word; {Inherit environment from shell/
  2424. inherit environment from parent
  2425. (0/1).}
  2426. SessionType:word; {Auto/full screen/window/presentation
  2427. manager/full screen Dos/windowed Dos
  2428. (0/1/2/3/4/5/6/7).}
  2429. Iconfile:PAnsiChar; {Icon file to use (nil allowed).}
  2430. PgmHandle:cardinal; {0 or the program handle.}
  2431. PgmControl:word; {Bitfield describing initial state
  2432. of windowed sessions.}
  2433. InitXPos,InitYPos:word; {Initial top coordinates.}
  2434. InitXSize,InitYSize:word; {Initial size.}
  2435. Reserved:word;
  2436. ObjectBuffer:PAnsiChar; {If a module cannot be loaded, its
  2437. name will be returned here.}
  2438. ObjectBuffLen:cardinal; {Size of your buffer.}
  2439. end;
  2440. PStartData=^TStartData;
  2441. StartData=TStartData;
  2442. {Start a new session.
  2443. AStartData = A startdata record.
  2444. SesID = Receives session ID of session created.
  2445. PID = Receives process ID of process created.}
  2446. function DosStartSession(var AStartData:TStartData;
  2447. var SesID,PID:longint):cardinal;cdecl;
  2448. function DosStartSession (var AStartData: TStartData;
  2449. var SesID, PID: cardinal): cardinal; cdecl;
  2450. {Set the status of a child session.
  2451. SesID = ID of session.
  2452. AStatus = Status to set.}
  2453. function DosSetSession (SesID: cardinal; var AStatus: TStatusData): cardinal;
  2454. cdecl;
  2455. {Bring a child session to the foreground.
  2456. SesID = ID of session.}
  2457. function DosSelectSession (SesID: cardinal): cardinal; cdecl;
  2458. {Terminate (a) child session(s).
  2459. Scope = 0 = Terminate specified session.
  2460. 1 = Terminate all child sessions.
  2461. SesID = ID of session to terminate (ignored when terminating
  2462. all).}
  2463. function DosStopSession (Scope, SesID: cardinal): cardinal; cdecl;
  2464. {****************************************************************************
  2465. Named/unnamed pipe specific routines.
  2466. ****************************************************************************}
  2467. type
  2468. TAvailData = record
  2469. cbPipe, {Number of bytes in pipe.}
  2470. cbMessage: word; {Number of bytes in current message.}
  2471. end;
  2472. TPipeInfo = record
  2473. cbOut: word; {Size of outbound data.}
  2474. cbIn: word; {Size of inbound data.}
  2475. MaxInst: byte; {Maximum number of instances.}
  2476. CurInst: byte; {Current number of instances.}
  2477. Name: string; {Name of the pipe. You can use @Name[1] if
  2478. you need a PAnsiChar to the name; the string is
  2479. always followed by a zero.}
  2480. end;
  2481. TPipeSemState = record
  2482. case boolean of
  2483. false: (Status: byte;
  2484. Flag: byte;
  2485. Key: word;
  2486. Avail: word);
  2487. true: (fStatus: byte;
  2488. fFlag: byte;
  2489. usKey: word;
  2490. usAvail: word);
  2491. end;
  2492. PPipeSemState = ^TPipeSemState;
  2493. TPipeSemStates = array [0..$FFFF] of TPipeSemState;
  2494. {Create an unnamed pipe.
  2495. ReadHandle = Receives handle for reading from pipe.
  2496. WriteHandle = Receives handle to write to pipe.
  2497. Size = Size of pipe to create. 0 means default size. If data is
  2498. written into a pipe that is smaller than the sent data, the
  2499. writing thread is suspended until the data has been read
  2500. from the pipe, thus making room for more data to send.}
  2501. function DosCreatePipe (var ReadHandle, WriteHandle: THandle;
  2502. Size: cardinal): cardinal; cdecl;
  2503. const {np_XXXX constants for openmode.}
  2504. np_Access_Inbound = $0000; {Client to server connection.}
  2505. np_Access_Outbound = $0001; {Server to client access.}
  2506. np_Access_Duplex = $0002; {Two way access.}
  2507. np_Inherit = $0000; {Pipe handle is inherited by
  2508. child processes.}
  2509. np_NoInherit = $0080; {Pipe handle is _not_ inherited by
  2510. child processes.}
  2511. np_No_Write_Behind = $4000; {Don't allow write behind for
  2512. remote pipes.}
  2513. {np_XXXX constants for pipemode.}
  2514. np_Unlimited_Instances = $00ff; {Unlimited instances.}
  2515. np_ReadMode_Mesg = $0100; {Read the pipe as a message
  2516. stream instead of as a byte
  2517. stream.}
  2518. np_ReadMode_Message = np_ReadMode_Mesg;
  2519. np_RMesg = np_ReadMode_Message;
  2520. np_WriteMode_Mesg = $0400; {Write the pipe as a message
  2521. stream instead of as a byte
  2522. stream.}
  2523. np_WriteMode_Message = np_WriteMode_Mesg;
  2524. np_Type_Message = np_WriteMode_Mesg;
  2525. np_WMesg = np_WriteMode_Mesg;
  2526. np_Wait = 0; { For compatibility only }
  2527. np_NoWait = $8000; {Dosread and Doswrite do not
  2528. wait is no data can be read or
  2529. written; they return with an
  2530. error message.}
  2531. {Create a named pipe.
  2532. Name = Name of pipe to create.
  2533. Handle = Receives handle to pipe.
  2534. OpenMode = A combination of np_XXXX constants for openmode.
  2535. PipeMode = A combination of np_XXXX constants for pipemode,
  2536. plus a number within [1..254] which determines the number
  2537. of instances that can be created to the pipe, or,
  2538. np_Unlimited_Instance for an unlimited number of
  2539. instances.
  2540. OutBufSize = The number of bytes to allocate for the output buffer.
  2541. InBufSize = The number of bytes to allocate for the input buffer.
  2542. MSec = The maximum time to wait for an available instance.}
  2543. function DosCreateNPipe (Name: PAnsiChar; var Handle: THandle; OpenMode, PipeMode,
  2544. OutBufSize, InBufSize, MSec: cardinal): cardinal;
  2545. cdecl;
  2546. function DosCreateNPipe (const Name: string; var Handle: THandle; OpenMode,
  2547. PipeMode, OutBufSize, InBufSize, MSec: cardinal):
  2548. cardinal;
  2549. {Makes a procedure call to a duplex message pipe.
  2550. Name = Name of pipe.
  2551. Input = Buffer that contains data to be written to the pipe.
  2552. InputSize = Size of the inputdata.
  2553. Output = Buffer that contains data to be read from the pipe.
  2554. OutputSize = Size of the outputbuffer.
  2555. ReadBytes = Receives number of bytes actually read.
  2556. MSec = The maximum time to wait for an available instance.}
  2557. function DosCallNPipe(Name:PAnsiChar;var Input;InputSize:longint;
  2558. var Output;OutputSize:longint;var ReadBytes:longint;
  2559. MSec:longint):cardinal; cdecl;
  2560. function DosCallNPipe(const Name:string;var Input;InputSize:longint;
  2561. var Output;OutputSize:longint;var ReadBytes:longint;
  2562. MSec:longint):cardinal;
  2563. function DosCallNPipe (Name: PAnsiChar; var Input; InputSize: cardinal;
  2564. var Output; OutputSize: cardinal;
  2565. var ReadBytes: cardinal; MSec: cardinal): cardinal;
  2566. cdecl;
  2567. function DosCallNPipe (const Name: string; var Input; InputSize: cardinal;
  2568. var Output; OutputSize: cardinal;
  2569. var ReadBytes: cardinal; MSec: cardinal): cardinal;
  2570. {Prepare a named pipe for a client process.
  2571. Handle = Handle that was returned when pipe was created.}
  2572. function DosConnectNPipe (Handle: THandle): cardinal; cdecl;
  2573. {Acknowledges that a client process has closed a named pipe.
  2574. Handle = Handle that was returned when pipe was created.}
  2575. function DosDisconnectNPipe (Handle: THandle): cardinal; cdecl;
  2576. const np_State_Disconnected = 1; {Pipe is disconnected.}
  2577. np_State_Listening = 2; {Pipe is listening.}
  2578. np_State_Connected = 3; {Pipe is connected.}
  2579. np_State_Closing = 4; {Pipe is closing.}
  2580. {Preview data in a pipe: Read data without removing it.
  2581. Handle = Handle to named pipe.
  2582. Buffer = Buffer to receive data in.
  2583. BufSize = Size of the buffer.
  2584. ReadBytes = Receives number of bytes put in buffer.
  2585. Avail = Receives size of available data.
  2586. State = One of the np_xxxx constants for states.}
  2587. function DosPeekNPipe(Handle:longint;var Buffer;BufSize:longint;
  2588. var ReadBytes:longint;var Avail:TAvailData;
  2589. var State:longint):cardinal; cdecl;
  2590. function DosPeekNPipe (Handle: THandle; var Buffer; BufSize: cardinal;
  2591. var ReadBytes: cardinal; var Avail: TAvailData;
  2592. var State: cardinal): cardinal; cdecl;
  2593. {Get information about a named pipe handle.
  2594. Handle = Handle to pipe.
  2595. State = A combination of np_XXXX constants for (!!!) pipemode.}
  2596. function DosQueryNPHState(Handle:longint;var State:longint):cardinal; cdecl;
  2597. function DosQueryNPHState (Handle: THandle; var State: cardinal): cardinal;
  2598. cdecl;
  2599. {Return information about a named pipe.
  2600. Handle = Handle to pipe.
  2601. InfoLevel = Level of information wanted (1 or 2 allowed).
  2602. Buffer = TPipeInfo datastructure for level 1.
  2603. Unique 4 byte identifier of the client for level 2. Only
  2604. used for LAN based pipe servers.}
  2605. function DosQueryNPipeInfo (Handle: THandle; InfoLevel: cardinal; var Buffer;
  2606. BufSize: cardinal): cardinal; cdecl;
  2607. {Return information of local named pipes that are attached to a semaphore.
  2608. SemHandle = Handle to a shared event or MuxWait semaphore that is
  2609. attached to a named pipe.
  2610. SemArray = Array in which for each pipe attached to the semaphore.
  2611. BufSize = Size of SemArray, in bytes.}
  2612. function DosQueryNPipeSemState (SemHandle: THandle; var SemArray;
  2613. BufSize: cardinal): cardinal; cdecl;
  2614. function DosQueryNPipeSemState (SemHandle: THandle; SemArray: PPipeSemState;
  2615. BufSize: cardinal): cardinal; cdecl;
  2616. {Resets the blocking mode and state of a named pipe.
  2617. Handle = Handle to named pipe.
  2618. State = One of the np_XXXX constants for pipemode.}
  2619. function DosSetNPHState (Handle: THandle; State: cardinal): cardinal; cdecl;
  2620. {Attach a shared event semaphore to a local named pipe.
  2621. PipeHandle = Handle to named pipe.
  2622. SemHandle = Handle to semaphore.
  2623. Key = A key that must be different for each named pipe that is
  2624. attached to the semaphore.}
  2625. function DosSetNPipeSem (PipeHandle, SemHandle: THandle; Key: cardinal):
  2626. cardinal; cdecl;
  2627. {Write to a duplex named pipe; then read from it.
  2628. Handle = Handle to named pipe.
  2629. OutBuf = The data to write.
  2630. OutSize = Size of the data to write.
  2631. InBuf = Receives the read data.
  2632. InSize = Size of the input buffer.
  2633. ReadBytes = Number of bytes read from the pipe.}
  2634. function DosTransactNPipe(Handle:longint;var OutBuf;OutSize:longint;
  2635. var InBuf;InSize:longint;
  2636. var ReadBytes:longint):cardinal; cdecl;
  2637. function DosTransactNPipe (Handle: THandle; var OutBuf; OutSize: cardinal;
  2638. var InBuf; InSize: cardinal;
  2639. var ReadBytes: cardinal): cardinal; cdecl;
  2640. {Waits until an instance of a named pipe becomes available.
  2641. Name = Name of named pipe (always starts with '\PIPE\').
  2642. MSec = Return with an error code if this time has elapsed.}
  2643. function DosWaitNPipe (Name: PAnsiChar; MSec: cardinal): cardinal; cdecl;
  2644. function DosWaitNPipe (const Name: string; MSec: cardinal): cardinal;
  2645. {****************************************************************************
  2646. Virtual device driver related routines.
  2647. ****************************************************************************}
  2648. {Open a virtual device driver.
  2649. Name = Name of virtual device driver.
  2650. Handle = Receives handle to virtual device driver.}
  2651. function DosOpenVDD (Name: PAnsiChar; var Handle: THandle): cardinal; cdecl;
  2652. {Request to talk with a virtual device driver.
  2653. Handle = Handle to virtual device driver.
  2654. SGroup = Handle to the screen group of a DOS session (may be nil).
  2655. Cmd = A number which indicates the service you call.
  2656. InSize = Size of the data to send to the VDD.
  2657. InBuffer = Buffer which contains the data to send to the VDD.
  2658. OutSize = Size of the buffer in which the VDD will return data.
  2659. OutBuffer = Receives the data that the VDD returns.}
  2660. function DosRequestVDD (Handle: THandle; SGroup, Cmd: cardinal;
  2661. InSize: cardinal; var InBuffer;
  2662. OutSize: cardinal; var OutBuffer): cardinal; cdecl;
  2663. {Close a virtual device driver.}
  2664. function DosCloseVDD (Handle: THandle): cardinal; cdecl;
  2665. {****************************************************************************
  2666. 16 <=> 32 bit support related routines
  2667. ****************************************************************************}
  2668. {Convert a 16 bit far pointer to a 32 bit near pointer.
  2669. This procedure needs to be called from assembler.
  2670. This procedure works by mapping an area in your flat address space onto the
  2671. same physical memory address as the selector of the 16 bit far pointer.
  2672. In:
  2673. eax Pointer to convert in selector:offset format.
  2674. Out:
  2675. eax Returned 32 bit near pointer.}
  2676. procedure DosSelToFlat; cdecl;
  2677. type
  2678. TFarPtr = record
  2679. Sel, Offset: word;
  2680. end;
  2681. function SelToFlat (AFarPtr: TFarPtr): pointer;
  2682. function SelToFlat (AFarPtr: cardinal): pointer;
  2683. {The second variant can make use of the register calling convention.}
  2684. {Convert a 32 bit near pointer to a 16 bit far pointer.
  2685. This procedure needs to be called from assembler.
  2686. This procedure works by allocating a selector at the same physical address
  2687. as the pointer you pass points to.
  2688. In:
  2689. eax Pointer to convert in 32 bit near format.
  2690. Out:
  2691. eax Returned 16 bit far pointer in selector:offset format.}
  2692. procedure DosFlatToSel; cdecl;
  2693. {typecast result to TFarPtr}
  2694. function FlatToSel (APtr: pointer): cardinal;
  2695. {Allocate Count dwords in a memory block unique in each thread. A maximum
  2696. of 8 dwords can be allocated at a time, the total size of the thread local
  2697. memory area is 128 bytes; FPC 1.1+ uses one dword from this for internal
  2698. multi-threading support, leaving 124 bytes to programmers.}
  2699. function DosAllocThreadLocalMemory (Count: cardinal; var P: pointer): cardinal;
  2700. cdecl;
  2701. {Deallocate a previously allocated space in the thread local memory area.}
  2702. function DosFreeThreadLocalMemory (P: pointer): cardinal; cdecl;
  2703. const
  2704. { Values for DosQueryRASInfo Index parameter }
  2705. sis_MMIOAddr = 0;
  2706. sis_MEC_Table = 1;
  2707. sis_Sys_Log = 2;
  2708. { The following one for compatibility only }
  2709. SPU_SIS_MEC_TABLE = sis_MEC_Table;
  2710. { Bit flags for the SYSLOG status word. }
  2711. lf_LogEnable = 1; { Logging enabled }
  2712. lf_LogAvailable = 2; { Logging available }
  2713. { DosQueryRASInfo returns information about active trace event recording
  2714. and System Logging facility from the Global Information Segment (InfoSegGDT)
  2715. dump.}
  2716. { Parameters
  2717. * Index - one of the sis_* values:
  2718. sis_MEC_Table - return the address of the table of actively traced major
  2719. event codes in the InfoSegGDT. The table is 32 bytes long, each bit
  2720. represents each major event code from 0 to 255.
  2721. sis_Sys_Log - return the address of the SYSLOG status word from
  2722. the InfoSegGDT. The status may contain a combination of lf_Log* flags
  2723. defined above.}
  2724. { Possible return codes:
  2725. 0 - No_Error
  2726. 5 - Error_Access_Denied
  2727. 87 - Error_Invalid_Parameter}
  2728. function DosQueryRASInfo (Index: cardinal; var PBuffer: pointer): cardinal;
  2729. cdecl;
  2730. const
  2731. { Logging constants }
  2732. ErrLog_Service = 1;
  2733. ErrLog_Version = 1;
  2734. { LogRecord status bits }
  2735. lf_Bit_ProcName = 1; {used to indicate whether the current error log}
  2736. {entry packet contains space in which the error}
  2737. {logging facility can place a long process name}
  2738. {("on" indicates YES, "off" indicates NO) }
  2739. lf_Bit_Origin_256 = 2; {used to indicate whether the current error log }
  2740. {entry packet contains an 8 byte originator name}
  2741. {or a 256 byte originator name ("on" indicates }
  2742. {a 256 byte originator name, "off" indicates an }
  2743. {8 byte originator name) }
  2744. lf_Bit_DateTime = 4; {used to indicate that the caller has placed time}
  2745. {and date values in the Error Log entry packet }
  2746. {and does not wish to have those values modified }
  2747. {during the logging process ("on" indicates that }
  2748. {the error log entry packet already contains time}
  2749. {and date values, "off" indicates the packet does}
  2750. {not already contain time and date values) }
  2751. lf_Bit_Suspend = 8;
  2752. lf_Bit_Resume = 16;
  2753. lf_Bit_Redirect = 32;
  2754. lf_Bit_GetStatus = 64;
  2755. lf_Bit_Register = 128;
  2756. lf_Bit_Remote_Fail = 256;
  2757. type
  2758. { Log entry record header for OS/2 2.x and above used }
  2759. { by 32-bit device drivers and callers of LogAddEntries. }
  2760. TLogRecord = record
  2761. Len: word; { length of this record (including the Len field) }
  2762. Rec_ID: word; { record ID }
  2763. Status: cardinal; { record status bits (see lf_Bit_* constants) }
  2764. Qualifier: array [1..4] of AnsiChar; { qualifier tag }
  2765. Reserved: cardinal;
  2766. Time: cardinal; { hours, minutes, seconds, hundreds }
  2767. Date: cardinal; { day, month, year (stored as word) }
  2768. case byte of
  2769. 0: (Data: array [1..3400] of AnsiChar); { variable data (up to 3400 bytes); }
  2770. { beginning of this area must match }
  2771. { one of the following patterns }
  2772. 1: (Originator256: array [0..255] of AnsiChar; {Originator - if the flag }
  2773. {lf_Bit_Origin_256 is set }
  2774. ProcessName_O256: array [1..260] of AnsiChar; {if lf_Bit_ProcName is set}
  2775. FormatDLLName_O256_ProcName: array [1..12] of AnsiChar; {ASCIIZ DLL name}
  2776. Data_O256_ProcName: array [1..3400] of AnsiChar); {Variable data }
  2777. 2: (Originator256b: array [0..255] of AnsiChar;
  2778. FormatDLLName_O256: array [1..12] of AnsiChar;
  2779. Data_O256: array [1..3400] of AnsiChar);
  2780. 3: (Originator8: array [0..7] of AnsiChar; {Originator - if flag }
  2781. {lf_Bit_Origin_256 clear }
  2782. ProcessName_O8: array [1..260] of AnsiChar; {if lf_Bit_ProcName is set}
  2783. FormatDLLName_O8_ProcName: array [1..12] of AnsiChar;
  2784. Data_O8_ProcName: array [1..3400] of AnsiChar);
  2785. 4: (Originator8b: array [0..7] of AnsiChar;
  2786. FormatDLLName_O8: array [1..12] of AnsiChar;
  2787. Data_O8: array [1..3400] of AnsiChar);
  2788. end;
  2789. LogRecord = TLogRecord;
  2790. PLogRecord = ^TLogRecord;
  2791. { Format of buffer sent to LogAddEntries }
  2792. TLogEntryRec = record
  2793. Version: word; {this version is 1}
  2794. Count: word; {number of log records in this buffer}
  2795. LogRec: array [0..0] of TLogRecord; {repeated count times}
  2796. end;
  2797. LogEntryRec = TLogEntryRec;
  2798. PLogEntryRec = ^TLogEntryRec;
  2799. { Logging facility functions }
  2800. { Open a connection to the system error logging facility (through the system
  2801. logging service device driver). }
  2802. { Possible return codes:
  2803. 0 .......... success
  2804. non-zero ... facility not available }
  2805. function LogOpen (var Handle: cardinal): cardinal; cdecl;
  2806. { Close the connection to the to the system error logging facility. }
  2807. { Possible return codes:
  2808. 0 .......... success
  2809. non-zero ... failure (possible reason - facility not open)}
  2810. function LogClose (Handle: cardinal): cardinal; cdecl;
  2811. { Add error log entries to the internal error log buffer maintained by
  2812. the system logging service device driver.}
  2813. { Parameters:
  2814. Handle - handle returned by previous LogOpen
  2815. Service - specifies the class of logging facility:
  2816. 0 ........... reserved
  2817. 1 ........... error logging
  2818. 2 - $FFFF ... reserved
  2819. LogEntries - buffer containing a variable length error log entry. The first
  2820. word of the buffer contains the number of packets in the error log entry.
  2821. Multiple error log packets (LogRec structure) can be included within
  2822. a single error log entry buffer. If multiple packets are included within
  2823. a buffer, each individual packet should be aligned on a double word
  2824. boundary.
  2825. Version - packet revision number. Can be used to distinguish error logging
  2826. packets that are intended to be handled by different revisions
  2827. of the LogAddEntries API. For the initial version of the API
  2828. (all OS/2 versions from OS/2 v2.0 up to WSeB and eComStation),
  2829. this field should be set to a value of 1. This field is included
  2830. in the packet to support future backward compatibility.
  2831. Count - number of separate error log entry packets contained within
  2832. the user's buffer
  2833. Len - length of this error log entry packet (LogRec) within the user's
  2834. error log entry buffer in bytes (this length includes the length
  2835. of all the error log entry packet control fields and the size
  2836. of the error log entry text). To support efficient logging execution,
  2837. this length should be a multiple of 4 bytes (i.e. if necessary
  2838. the user should pad the error log entry packet).
  2839. Rec_ID - error log record ID for the current error log entry
  2840. (ID registration will be statically registered by the OS/2
  2841. development organization)
  2842. Status - status flags (two byte flag holder containing three single bit
  2843. flags lf_Bit_* - all the other 29 bits in status flags
  2844. are considered reserved at this time and will be zeroed by
  2845. the LogAddEntries API)
  2846. Qualifier - qualifier name is a secondary name field that is provided
  2847. by the caller
  2848. Reserved - four byte reserved field
  2849. Time - time of logging, filled in by the system error logging facility
  2850. (unless lf_Bit_DateTime status flag is set to "on", indicating
  2851. that the caller has preset a time value)
  2852. Date - date of logging, filled in by the system error logging facility
  2853. (unless lf_Bit_DateTime status flag is set to "on", indicating
  2854. that the caller has preset a date value)
  2855. Originator* - originator name (8 or 256 characters depending on Status),
  2856. a primary name field provided by the caller
  2857. ProcName* - process name (0 or 260 characters), an optional long process
  2858. name field that will be filled in by the error logging facility
  2859. if the field is provided by the caller in the error log entry
  2860. packet
  2861. FormatDLLName* - formatting DLL module name (optional); the optional name
  2862. of a DLL module that houses a formatting routine that
  2863. recognizes this type of error log entry and can format it
  2864. for display by the SYSLOG utility. The name is specified
  2865. as an ASCIIZ string that can be up to eight characters
  2866. in length. If no module name is specified in this field,
  2867. then SYSLOG will display the data portion of the error log
  2868. entry as a hexadecimal dump.
  2869. Data* - error log entry data (up to 3400 characters / bytes); an optional
  2870. variable length set of data that can be supplied by the caller
  2871. (the format of the string is under the control of the caller)
  2872. }
  2873. { Possible return codes:
  2874. 0 - success
  2875. non-zero - failure (invalid log type, facility unavailable, facility
  2876. suspended, facility not open, error log buffer temporarily full)
  2877. }
  2878. function LogAddEntries (Handle: cardinal; Service: cardinal;
  2879. LogEntries: PLogEntryRec): cardinal; cdecl;
  2880. function LogAddEntries (Handle: cardinal; Service: cardinal;
  2881. var LogEntries: TLogEntryRec): cardinal; cdecl;
  2882. function DosReplaceModule (OldModule, NewModule, BackupModule: PAnsiChar):
  2883. cardinal; cdecl;
  2884. const
  2885. { Flags allowed for DosQuerySysState parameter EntityList
  2886. (multiple flags may be combined together) and also values
  2887. used as markers of records returned in the provided buffer:
  2888. }
  2889. qs_End = 0; { Marker for the last TFileSys record }
  2890. qs_Process = 1; { Requests process information }
  2891. qs_Semaphore = 2; { Requests semaphore information }
  2892. qs_MTE = 4; { Requests module information }
  2893. qs_FileSys = 8; { Requests file system information }
  2894. qs_ShMemory = 16; { Requests shared memory information }
  2895. qs_Disk = 32; { Not supported apparently? }
  2896. qs_HwConfig = 64; { Not supported apparently? }
  2897. qs_NamedPipe = 128; { Not supported apparently? }
  2898. qs_Thread = 256; { Not supported apparently? }
  2899. qs_ModVer = 512; { Requests module version information }
  2900. qs_Supported = qs_Process or qs_Semaphore or qs_MTE or QS_FileSys or
  2901. qs_ShMemory or qs_ModVer;
  2902. type
  2903. { Global record
  2904. Holds all global system information. Placed first in user buffer
  2905. }
  2906. PQSGRec = ^TQSGRec;
  2907. TQSGRec = record
  2908. cThrds,
  2909. c32SSem,
  2910. cMFTNodes: cardinal;
  2911. end;
  2912. { Thread record
  2913. Holds all per thread information.
  2914. }
  2915. PQSTRec = ^TQSTRec;
  2916. TQSTRec = record
  2917. RecType: cardinal; { Record type }
  2918. TID: word; { Thread ID }
  2919. Slot: word; { "Unique" thread slot number }
  2920. SleepID: cardinal; { Sleep ID thread is sleeping on }
  2921. case boolean of
  2922. false: (
  2923. Priority: cardinal; { Thread priority (class + level) }
  2924. SysTime: cardinal; { Thread system time }
  2925. UserTime: cardinal; { Thread user time }
  2926. State: byte; { Thread state }
  2927. Pad: array [1..3] of byte); { Padding for 32-bit alignment }
  2928. true: (
  2929. PrioLevel: byte; { Thread priority level only }
  2930. PrioClass: byte; { Thread priority class only }
  2931. Pad2: array [1..14] of byte);
  2932. end;
  2933. { Process record
  2934. Holds all per process information.
  2935. ________________________________
  2936. | RecType |
  2937. |-------------------------------|
  2938. | pThrdRec |----|
  2939. |-------------------------------| |
  2940. | pid | |
  2941. |-------------------------------| |
  2942. | ppid | |
  2943. |-------------------------------| |
  2944. | type | |
  2945. |-------------------------------| |
  2946. | stat | |
  2947. |-------------------------------| |
  2948. | sgid | |
  2949. |-------------------------------| |
  2950. | hMte | |
  2951. |-------------------------------| |
  2952. | cTCB | |
  2953. |-------------------------------| |
  2954. | c32PSem | |
  2955. |-------------------------------| |
  2956. | p32SemRec |----|---|
  2957. |-------------------------------| | |
  2958. | c16Sem | | |
  2959. |-------------------------------| | |
  2960. | cLib | | |
  2961. |-------------------------------| | |
  2962. | cShrMem | | |
  2963. |-------------------------------| | |
  2964. | cFS | | |
  2965. |-------------------------------| | |
  2966. | p16SemRec |----|---|----|
  2967. |-------------------------------| | | |
  2968. | pLibRec |----|---|----|------|
  2969. |-------------------------------| | | | |
  2970. | pShrMemRec |----|---|----|------|----|
  2971. |-------------------------------| | | | | |
  2972. | pFSRec |----|---|----|------|----|-----|
  2973. |-------------------------------| | | | | | |
  2974. | 32SemPPRUN[0] |<---|---| | | | |
  2975. | . | | | | | |
  2976. | . | | | | | |
  2977. | . | | | | | |
  2978. | 32SemPPRUN[c32PSem-1] | | | | | |
  2979. |-------------------------------| | | | | |
  2980. | 16SemIndx[0] |<---|--------| | | |
  2981. | . | | | | |
  2982. | . | | | | |
  2983. | . | | | | |
  2984. | 16SemIndx[c16Sem-1] | | | | |
  2985. |-------------------------------| | | | |
  2986. | hmte[0] (or "name str") |<---|---------------| | |
  2987. | . | | | |
  2988. | . | | | |
  2989. | . | | | |
  2990. | hmte[cLib-1] | | | |
  2991. |-------------------------------| | | |
  2992. | hshmem[0] |<---|--------------------| |
  2993. | . | | |
  2994. | . | | |
  2995. | . | | |
  2996. | hshmem[cShrMem-1] | | |
  2997. |-------------------------------| | |
  2998. | fsinfo[0] |<---|--------------------------|
  2999. | . | |
  3000. | . | |
  3001. | . | |
  3002. | fsinfo[cFS-1] | |
  3003. |-------------------------------| |
  3004. <-----
  3005. NOTE that the process name string will be stored in place of hmtes
  3006. if MTE information is NOT being requested.
  3007. NOTE that following this structure in the user buffer is
  3008. an array c32Sems long of PRUN structures for 32 bit sems
  3009. an array c16Sems long of indices for 16 bit sems
  3010. the process name string
  3011. }
  3012. PQSPRec = ^TQSPRec;
  3013. TQSPrec = record
  3014. RecType: cardinal; { Type of record being processed }
  3015. PThrdRec: PQSTRec; { (Far?) pointer to thread records for this process }
  3016. PID: word; { Process ID }
  3017. PPID: word; { Parent process ID }
  3018. ProcType: cardinal; { Process type }
  3019. Stat: cardinal; { Process status }
  3020. SGID: cardinal; { Process screen group }
  3021. hMte: word; { Program module handle for process }
  3022. cTCB: word; { Number of TCBs (Thread Control Blocks) in use }
  3023. c32PSem: cardinal; { Number of private 32-bit semaphores in use }
  3024. p32SemRec: pointer; { (Far?) pointer to head of 32-bit semaphores info }
  3025. c16Sem: word; { Number of 16 bit system semaphores in use }
  3026. cLib: word; { Number of runtime linked libraries }
  3027. cShrMem: word; { Number of shared memory handles }
  3028. cFH: word; { Number of open files }
  3029. { NOTE: cFH is size of active part of }
  3030. { the handle table if QS_FILE specified }
  3031. p16SemRec: word; { Far pointer? to head of 16-bit semaphores info }
  3032. pLibRec: word; { Far pointer? to list of runtime libraries }
  3033. pShrMemRec: word; { Far pointer? to list of shared memory handles }
  3034. pFSRec: word; { Far pointer to list of file handles; }
  3035. { 0xFFFF means it's closed, otherwise }
  3036. { it's an SFN if non-zero }
  3037. end;
  3038. { 16-bit system semaphore record
  3039. ________________________________
  3040. | pNextRec |----|
  3041. |-------------------------------| |
  3042. |SysSemData : | |
  3043. | SysSemOwner | |
  3044. | SysSemFlag | |
  3045. | SysSemRecCnt | |
  3046. | SysSemProcCnt | |
  3047. |-------------------------------| |
  3048. |-------------------------------| |
  3049. |-------------------------------| |
  3050. | SysSemPtr | |
  3051. |-------------------------------| |
  3052. |SysSemName: | |
  3053. | "pathname" | |
  3054. |-------------------------------| |
  3055. <-----
  3056. }
  3057. const
  3058. { Values for SysSemFlag: }
  3059. qs_SysSem_Waiting = 1; { A thread is waiting on the semaphore }
  3060. qs_SysSem_MuxWaiting = 2; { A thread is muxwaiting on the semaphore }
  3061. qs_SysSem_Owner_Died = 4; { The process/thread owning the sem died }
  3062. qs_SysSem_Exclusive = 8; { Indicates an exclusive system semaphore }
  3063. qs_SysSem_Name_Cleanup = 16; { Name table entry needs to be removed }
  3064. qs_SysSem_Thread_Owner_Died = 32; { The thread owning the semaphore died }
  3065. qs_SysSem_ExitList_Owner = 64; { The exitlist thread owns the semaphore }
  3066. type
  3067. PQSS16Rec = ^TQSS16Rec;
  3068. TQSS16Rec = record
  3069. NextRec: cardinal; { Offset to next record in buffer }
  3070. { System Semaphore Table Structure }
  3071. SysSemOwner: word; { Thread owning this semaphore }
  3072. SysSemFlag: byte; { System semaphore flag bit field }
  3073. SysSemRefCnt: byte; { Number of references to this system semaphore }
  3074. SysSemProcCnt: byte; { Number of requests for this owner }
  3075. SysSemPad: byte; { Pad byte to round structure up to word }
  3076. Pad_sh: word; { Padding for 32-bit alignment }
  3077. SemPtr: word; { RMP SysSemPtr field }
  3078. SemName: array [0..0] of AnsiChar; { Start of semaphore name string }
  3079. end;
  3080. PQSS16HeadRec = ^TQSS16HeadRec;
  3081. TQSS16HeadRec = record
  3082. SRecType: cardinal; { Offset of SysSemDataTable }
  3083. SpNextRec:cardinal; { Overlays NextRec of 1st PQSS16Rec }
  3084. S32SemRec: cardinal;
  3085. S16TblOff: cardinal;
  3086. pSem16Rec: cardinal;
  3087. end;
  3088. { System-wide shared memory information
  3089. ________________________________
  3090. | NextRec |
  3091. |-------------------------------|
  3092. | hMem |
  3093. |-------------------------------|
  3094. | Sel |
  3095. |-------------------------------|
  3096. | RefCnt |
  3097. |-------------------------------|
  3098. | Name |
  3099. |_______________________________|
  3100. }
  3101. PQSMRec = ^TQSMRec;
  3102. TQSMRec = record
  3103. MemNextRec: cardinal; { Offset to next record in buffer }
  3104. hMem: word; { Handle for shared memory }
  3105. Sel: word; { Selector }
  3106. RefCnt: word; { Reference count }
  3107. MemName: array [0..0] of AnsiChar; { Start of shared memory name string }
  3108. end;
  3109. { 32-bit system semaphore record
  3110. ________________________________
  3111. | pNextRec |----|
  3112. |-------------------------------| |
  3113. | QSHUN[0] | |
  3114. |-------------------------------| |
  3115. | MuxQ | |
  3116. |-------------------------------| |
  3117. | OpenQ | |
  3118. |-------------------------------| |
  3119. | SemName | |
  3120. |-------------------------------|<---|
  3121. | . |
  3122. | . |
  3123. |-------------------------------|<---|
  3124. | pNextRec |----|
  3125. |-------------------------------| |
  3126. | QSHUN[c32SSem-1] | |
  3127. |-------------------------------| |
  3128. | MuxQ | |
  3129. |-------------------------------| |
  3130. | OpenQ | |
  3131. |-------------------------------| |
  3132. | SemName | |
  3133. |-------------------------------|<---|
  3134. }
  3135. const
  3136. { 32-bit semaphore flags }
  3137. qs_dc_Sem_Shared = 1; { Shared Mutex, Event or MUX semaphore }
  3138. qs_dcmw_Wait_Any = 2; { Wait on any event/mutex to occur }
  3139. qs_dcmw_Wait_All = 4; { Wait on all events/mutexs to occur }
  3140. qs_dcm_Mutex_Sem = 8; { Mutex semaphore }
  3141. qs_dce_Event_Sem = 16; { Event semaphore }
  3142. qs_dcmw_Mux_Sem = 32; { Muxwait semaphore }
  3143. qs_dc_Sem_PM = 64; { PM Shared Event Semphore }
  3144. qs_de_Posted = 64; { Event semaphore is in the posted state }
  3145. qs_dm_Owner_Died = 128; { The owning process died }
  3146. qs_dmw_Mtx_Mux = 256; { MUX contains mutex semaphores }
  3147. qs_dho_Sem_Open = 512; { Device drivers have opened this semaphore }
  3148. qs_de_16Bit_MW = 1024; { Part of a 16-bit MuxWait }
  3149. qs_dce_PostOne = 2048; { Post one flag event semaphore }
  3150. qs_dce_AutoReset = 4096; { Auto-reset event semaphore }
  3151. type
  3152. PQSOpenQ = ^TQSOpenQ;
  3153. TQSOpenQ = record
  3154. PidOpener: word; { Process ID of the opening process }
  3155. OpenCt: word; { Number of opens for this process }
  3156. end;
  3157. PQSEvent = ^TQSEvent;
  3158. TQSEvent = record
  3159. pOpenQ: PQSOpenQ; { Pointer to open Queue entries }
  3160. pName: PAnsiChar; { Pointer to semaphore name }
  3161. pMuxQ: PCardinal; { Pointer to the mux queue }
  3162. Flags: word;
  3163. PostCt: word; { Number of posts }
  3164. end;
  3165. PQSMutex = ^TQSMutex;
  3166. TQSMutex = record
  3167. pOpenQ: PQSOpenQ; { Pointer to open queue entries }
  3168. pName: PAnsiChar; { Pointer to semaphore name }
  3169. pMuxQ: PCardinal; { Pointer to the mux queue }
  3170. Flags: word;
  3171. ReqCt: word; { Number of requests }
  3172. SlotNum: word; { Slot number of the owning thread }
  3173. Padding: word;
  3174. end;
  3175. PQSMux = ^TQSMux;
  3176. TQSMux = record
  3177. pOpenQ: PQSOpenQ; { Pointer to open queue entries }
  3178. pName: PAnsiChar; { Pointer to semaphore name }
  3179. pSemRec: PSemArray; { Array of semaphore record entries }
  3180. Flags: word;
  3181. cSemRec: word; { Count of semaphore records }
  3182. WaitCt: word; { Number of threads waiting on the mux }
  3183. Padding: word;
  3184. end;
  3185. PQSSHUN = ^TQSSHUN;
  3186. TQSSHUN = record
  3187. qsSEvt: PQSEvent; { Shared event semaphore }
  3188. qsSMtx: PQSMutex; { Shared mutex semaphore }
  3189. qsSMux: PQSMux; { Shared mux semaphore }
  3190. end;
  3191. PQSS32Rec = ^TQSS32Rec;
  3192. TQSS32Rec = record
  3193. pNextRec: PQSS32Rec; { Pointer to the next record in buffer }
  3194. qsh: PQSSHUN; { QState version of SHUN record }
  3195. end;
  3196. { System wide MTE information
  3197. ________________________________
  3198. | pNextRec |----|
  3199. |-------------------------------| |
  3200. | hmte | |
  3201. |-------------------------------| |
  3202. | ctImpMod | |
  3203. |-------------------------------| |
  3204. | ctObj | |
  3205. |-------------------------------| |
  3206. | pObjInfo |----|----------|
  3207. |-------------------------------| | |
  3208. | pName |----|----| |
  3209. |-------------------------------| | | |
  3210. | imported module handles | | | |
  3211. | . | | | |
  3212. | . | | | |
  3213. | . | | | |
  3214. |-------------------------------| <--|----| |
  3215. | "pathname" | | |
  3216. |-------------------------------| <--|----------|
  3217. | Object records | |
  3218. | (if requested) | |
  3219. |_______________________________| |
  3220. <-----
  3221. NOTE that if the level bit is set to qs_MTE, the base Lib record
  3222. will be followed by a series of object records (TQSLObjRec); one for each
  3223. object of the module.
  3224. }
  3225. PQSLObjRec = ^TQSLObjRec;
  3226. TQSLObjRec = record
  3227. OAddr: cardinal; { Object address }
  3228. OSize: cardinal; { Object size }
  3229. OFlags: cardinal; { Object flags }
  3230. end;
  3231. PQSLRec = ^TQSLRec;
  3232. TQSLRec = record
  3233. pNextRec: PQSLRec; { (Far?) pointer to the next record in buffer }
  3234. hMTE: word; { Handle for this MTE }
  3235. fFlat: word; { True if 32 bit module }
  3236. ctImpMod: cardinal; { Number of imported modules in table }
  3237. ctObj: cardinal; { Number of objects in module (MTE_ObjCnt) }
  3238. pObjInfo: PQSLObjRec; { (Far?) pointer to per object information if any }
  3239. pName: PAnsiChar; { (Far?) pointer to name string following record }
  3240. end;
  3241. PQSExLRec = ^TQSExLRec;
  3242. TQSExLRec = record { Used for 9th bit (Extended Module Data Summary) }
  3243. Next: PQSExLRec; { Pointer to next Extended Module Data }
  3244. hndMod: word; { Module Handle }
  3245. PID: word; { Process ID }
  3246. ModType: word; { Type of Module }
  3247. RefCnt: cardinal; { Size of reference array }
  3248. SegCnt: cardinal; { Number of segments in module }
  3249. _reserved_: pointer;
  3250. Name: PAnsiChar; { (Far?) pointer to Module Name }
  3251. ModuleVersion: cardinal;{ Module version value }
  3252. ShortModName: PAnsiChar; { (Far?) new pointer to module short name }
  3253. ModRef: cardinal; { Start of array of handles of module }
  3254. end;
  3255. { System wide FILE information
  3256. ________________________________
  3257. | RecType |
  3258. |-------------------------------|
  3259. | pNextRec |-------|
  3260. |-------------------------------| |
  3261. | ctSft | |
  3262. |-------------------------------| |
  3263. | pSft |---| |
  3264. |-------------------------------| | |
  3265. | name | | |
  3266. |-------------------------------|<--| |
  3267. | qsSft[0] | |
  3268. |-------------------------------| |
  3269. | ... | |
  3270. |-------------------------------| |
  3271. | qsSft[ctSft -1] | |
  3272. |_______________________________| |
  3273. | name | |
  3274. |_______________________________| |
  3275. <-------|
  3276. }
  3277. PQSSft = ^TQSSft;
  3278. TQSSft = record
  3279. SFN: word; { SFN sf_fsi.sfi_selfSFN }
  3280. RefCnt: word; { sf_ref_count }
  3281. Flags: word; { sf_flags }
  3282. Flags2: word; { sf_flags2 }
  3283. Mode: word; { sf_fsi.sfi_mode - mode of access }
  3284. Mode2: word; { sf_fsi.sfi_mode2 - mode of access }
  3285. Size: cardinal; { sf_fsi.sfi_size }
  3286. hVPB: word; { sf_fsi.sfi_hVPB handle of volume }
  3287. Attr: word; { sf_attr }
  3288. Padding: word;
  3289. end;
  3290. PQSFRec = ^TQSFRec;
  3291. TQSFRec = record
  3292. RecType: cardinal; { Record Type }
  3293. pNextRec: PQSFRec; { Pointer to the next record in buffer }
  3294. ctSft: cardinal; { Number of SFT entries for this MFT entry }
  3295. pSft: PQSSft; { Pointer to start of SFT entries in buffer }
  3296. end;
  3297. { Pointer record
  3298. This structure is the first in the user buffer.
  3299. It contains pointers to heads of record types that are loaded
  3300. into the buffer.
  3301. }
  3302. PQSPtrRec = ^TQSPtrRec;
  3303. TQSPtrRec = record
  3304. PGlobalRec: PQSGRec;
  3305. PProcRec: PQSPRec; { Pointer to head of process records }
  3306. P16SemRec: PQSS16HeadRec; { Pointer to head of 16-bit semaphore records }
  3307. P32SemRec: PQSS32Rec; { Pointer to head of 32-bit semaphore records }
  3308. PMemRec: PQSMRec; { ???Pointer to head of shared memory records? }
  3309. PLibRec: PQSLRec; { Pointer to head of MTE records }
  3310. PShrMemRec: PQSMRec; { ???Pointer to head of shared memory records? }
  3311. PFSRec: PQSFRec; { Pointer to head of file system records }
  3312. end;
  3313. {DosQuerySysState returns information about various resources in use
  3314. by the system. The EntityList parameter determines which information
  3315. is returned according to the bits set in this parameter.
  3316. Note that this API is fairly low-level and it hasn't been part
  3317. of the official IBM documentation until WSeB (and even then the documentation
  3318. was highly incomplete, so}
  3319. {Parameters:
  3320. EntityList Determines what information is returned. May be a combination
  3321. one or more qs_* flags.
  3322. EntityLevel Determines the extent of information returned for a given
  3323. entity. This applies to qs_MTE entities only. If EntityLevel is
  3324. also set to qs_MTE, then module object information is returned.
  3325. PID Restricts information to a particular process ID. If 0 is
  3326. specified, then entities for all processes are returned.
  3327. TID Restricts information to a particular thread ID. A value of zero
  3328. only is supported, requesting all threads of a process.
  3329. Buffer Buffer allocated by the user into which entity structures are
  3330. returned. If the buffer is of insufficient size, then an
  3331. Error_Buffer_Overflow is returned.
  3332. BufLen Size of the buffer pointed to by Buffer in bytes.
  3333. }
  3334. function DosQuerySysState (EntityList, EntityLevel, PID, TID: cardinal;
  3335. var Buffer; BufLen: cardinal): cardinal; cdecl;
  3336. function DosQuerySysState (EntityList, EntityLevel, PID, TID: cardinal;
  3337. PDataBuf: pointer; cbBuf: cardinal): cardinal; cdecl;
  3338. {
  3339. Creates a private Read/Write alias or an LDT code segment alias to part
  3340. of an existing memory object. The alias object is accessible only to the
  3341. process that created it. The original object must be accessible to the caller
  3342. of DosAliasMem.
  3343. An alias is removed by calling DosFreeMem with the alias address.
  3344. Although it is possible to create a Read/Write alias to a code segment
  3345. to allow code modification, this is not recommended. On Pentium processors,
  3346. and later, pipe-lining techniques used by the processor might allow
  3347. the processor not to be aware of the modified code, if appropriate
  3348. pipe-line serialization is not performed by the programmer. For further
  3349. information see the processor documentation.
  3350. Possible return values:
  3351. 0 No_Error
  3352. 8 Error_Not_Enough_Memory
  3353. 87 Error_Invalid_Parameter
  3354. 95 Error_Interrupt
  3355. 32798 Error_Crosses_Object_Boundary
  3356. pMem = Pointer to the memory to be aliased. It must be on a page boundary
  3357. (i.e. aligned to 4 kB), but may specify an address within a memory
  3358. object.
  3359. Size = Specifies size in bytes for the memory to alias. The entire range
  3360. must lie within a single memory object and must be committed
  3361. if OBJ_SELMAPALL is specified.
  3362. Alias = Pointer where the address of the aliased memory is returned.
  3363. The corresponding LDT selector is not explicitly returned but may be
  3364. calculated by using the Compatibility Mapping Algorithm
  3365. ((Alias shr 13) or 7).
  3366. Flags = Combination of the following values:
  3367. obj_SelMapAll = $800 (Create a Read/Write 32 bit alias
  3368. to the address specified. The entire range
  3369. must be committed, start on page boundary
  3370. and be within the extent of a single memory
  3371. object. An LDT selector is created to map
  3372. the entire range specified. If obj_SelMapAll
  3373. is not specified, then size is rounded up
  3374. to a 4K multiple and the alias created
  3375. inherits the permissions from the pages
  3376. of the original object.)
  3377. obj_Tile = $40 (Obj_Tile may be specified, but currently
  3378. this is enforced whether or not specified.
  3379. This forces LDT selectors to be based
  3380. on 64K boundaries.)
  3381. sel_Code = 1 (Marks the LDT alias selector(s)
  3382. Read-Executable code selectors.)
  3383. sel_Use32 = 2 (Used with obj_SelMapAll, otherwise ignored.
  3384. Marks the first alias LDT selector
  3385. as a 32 bit selector by setting the BIG/C32
  3386. bit.)
  3387. }
  3388. function DosAliasMem (pMem: pointer; Size: cardinal; var Alias: pointer;
  3389. Flags: cardinal): cardinal; cdecl;
  3390. const
  3391. PAG_INVALID = 0; (* Page is invalid. *)
  3392. PAG_NPOUT = 0; (* Page is not present, not in core. *)
  3393. PAG_PRESENT = 1; (* Page is present. *)
  3394. PAG_NPIN = 2; (* Page is not present, in core. *)
  3395. PAG_PRESMASK = 3; (* Present state mask. *)
  3396. PAG_RESIDENT = 16; (* Page is resident. *)
  3397. PAG_SWAPPABLE = 32; (* Page is swappable. *)
  3398. PAG_DISCARDABLE = 48; (* Page is discardable. *)
  3399. PAG_TYPEMASK = 48; (* Typemask *)
  3400. {
  3401. DosQueryMemState gets the status of a range of pages in memory. Its input
  3402. parameters are an address and size. The address is rounded down to page
  3403. boundary and size is rounded up to a whole number of pages. The status
  3404. of the pages in the range is returned in the state parameter, and the size
  3405. of the range queried is returned in the size parameter. If the pages
  3406. in the range have conflicting states, then the state of the first page
  3407. is returned.
  3408. Parameters:
  3409. PMem - Pointer to memory to be queried
  3410. Size - Size of memory to be queried
  3411. State - Flags (PAG_*) indicating state of the memory (or the first memory page
  3412. if the states for the following pages differ):
  3413. Possible return codes:
  3414. 0 - NO_ERROR
  3415. 87 - ERROR_INVALID_PARAMETER
  3416. 487 - ERROR_INVALID_ADDRESS
  3417. }
  3418. function DosQueryMemState (PMem: pointer; var Size: cardinal;
  3419. var State: cardinal): cardinal; cdecl;
  3420. {***************************************************************************}
  3421. implementation
  3422. {***************************************************************************}
  3423. function DosCreateThread(var TID:longint;Address:TThreadEntry;
  3424. aParam:pointer;Flags:longint;
  3425. StackSize:longint):cardinal; cdecl;
  3426. external 'DOSCALLS' index 311;
  3427. function DosCreateThread (var TID: cardinal; Address: TThreadEntry;
  3428. aParam: pointer; Flags: cardinal;
  3429. StackSize: cardinal): cardinal; cdecl;
  3430. external 'DOSCALLS' index 311;
  3431. function DosCreateThread(var TID:longint;Address:pointer;
  3432. AParam:Pointer;Flags,StackSize:longint):cardinal;cdecl;
  3433. external 'DOSCALLS' index 311;
  3434. function DosCreateThread (var TID: cardinal; Address: pointer;
  3435. AParam: Pointer; Flags, StackSize: cardinal): cardinal; cdecl;
  3436. external 'DOSCALLS' index 311;
  3437. function DosSuspendThread (TID:cardinal): cardinal; cdecl;
  3438. external 'DOSCALLS' index 238;
  3439. function DosResumeThread (TID: cardinal): cardinal; cdecl;
  3440. external 'DOSCALLS' index 237;
  3441. function DosKillThread (TID: cardinal): cardinal; cdecl;
  3442. external 'DOSCALLS' index 111;
  3443. function DosWaitThread(var TID:longint;Option:longint):cardinal; cdecl;
  3444. external 'DOSCALLS' index 349;
  3445. function DosWaitThread (var TID: cardinal; Option: cardinal): cardinal; cdecl;
  3446. external 'DOSCALLS' index 349;
  3447. function DosEnterCritSec: cardinal; cdecl;
  3448. external 'DOSCALLS' index 232;
  3449. function DosExitCritSec: cardinal; cdecl;
  3450. external 'DOSCALLS' index 233;
  3451. procedure DosExit (Action, Result: cardinal); cdecl;
  3452. external 'DOSCALLS' index 234;
  3453. procedure DosGetInfoBlocks(var ATIB:PThreadInfoBlock;
  3454. var APIB:PProcessInfoBlock); cdecl;
  3455. external 'DOSCALLS' index 312;
  3456. procedure DosGetInfoBlocks(PATIB:PPThreadInfoBlock;
  3457. PAPIB:PPProcessInfoBlock); cdecl;
  3458. external 'DOSCALLS' index 312;
  3459. procedure DosSleep (MSec: cardinal); cdecl;
  3460. external 'DOSCALLS' index 229;
  3461. function DosBeep (Freq, MS: cardinal): cardinal; cdecl;
  3462. external 'DOSCALLS' index 286;
  3463. function DosDebug (DebugBuf: PDbgBuf): cardinal; cdecl;
  3464. external 'DOSCALLS' index 317;
  3465. function DosDebug (var APDbgBuf: TDbgBuf): cardinal; cdecl;
  3466. external 'DOSCALLS' index 317;
  3467. function DosExitList (OrderCode: cardinal; Proc: TExitProc): cardinal; cdecl;
  3468. external 'DOSCALLS' index 296;
  3469. function DosExecPgm (ObjName: PAnsiChar; ObjLen: longint; ExecFlag: cardinal;
  3470. Args, Env: PByteArray; var Res: TResultCodes;
  3471. FileName:PAnsiChar): cardinal; cdecl;
  3472. external 'DOSCALLS' index 283;
  3473. function DosExecPgm (var ObjName: string; Execflag: cardinal;
  3474. Args, Env: PByteArray; var Res: TResultCodes;
  3475. const FileName: string): cardinal;
  3476. var T,T2:array[0..255] of AnsiChar;
  3477. begin
  3478. StrPCopy(@T,FileName);
  3479. DosExecPgm:=DosExecPgm(@T2,SizeOf(T2),ExecFlag,Args,Env,Res,@T);;
  3480. ObjName:=StrPas(@T2);
  3481. end;
  3482. function DosWaitChild(Action,Option:longint;var Res:TResultCodes;
  3483. var TermPID:longint;PID:longint):cardinal; cdecl;
  3484. external 'DOSCALLS' index 280;
  3485. function DosWaitChild (Action, Option: cardinal; var Res: TResultCodes;
  3486. var TermPID: cardinal; PID: cardinal): cardinal; cdecl;
  3487. external 'DOSCALLS' index 280;
  3488. function DosSetPriority (Scope, TrClass: cardinal; Delta: longint;
  3489. PortID: cardinal): cardinal; cdecl;
  3490. external 'DOSCALLS' index 236;
  3491. function DosKillProcess (Action, PID: cardinal): cardinal; cdecl;
  3492. external 'DOSCALLS' index 235;
  3493. function DosQueryAppType(FileName:PAnsiChar;var Flags:longint):cardinal; cdecl;
  3494. external 'DOSCALLS' index 323;
  3495. function DosQueryAppType (FileName: PAnsiChar; var Flags: cardinal): cardinal;
  3496. cdecl;
  3497. external 'DOSCALLS' index 323;
  3498. function DosDevConfig (var DevInfo: byte; Item: cardinal): cardinal; cdecl;
  3499. external 'DOSCALLS' index 231;
  3500. function DosSetFileLocks (Handle: THandle; var Unlock, Lock: TFileLock;
  3501. Timeout, Flags: cardinal): cardinal; cdecl;
  3502. external 'DOSCALLS' index 428;
  3503. function DosCancelLockRequest (Handle: THandle; var Lock: TFileLock): cardinal;
  3504. cdecl;
  3505. external 'DOSCALLS' index 429;
  3506. function DosOpen(FileName:PAnsiChar;var Handle,Action:longint;
  3507. InitSize,Attrib,OpenFlags,FileMode:longint;
  3508. EA:PEAOp2):cardinal; cdecl;
  3509. external 'DOSCALLS' index 273;
  3510. function DosOpen (FileName: PAnsiChar; var Handle: THandle; var Action: cardinal;
  3511. InitSize, Attrib, OpenFlags, FileMode: cardinal;
  3512. EA: PEAOp2): cardinal; cdecl;
  3513. external 'DOSCALLS' index 273;
  3514. function DosCreate (FileName: PAnsiChar; var Handle: THandle;
  3515. Attrib, OpenMode: cardinal): cardinal;
  3516. var Action: cardinal;
  3517. begin
  3518. DosCreate:=DosOpen(FileName,Handle,Action,0,Attrib,18,OpenMode,nil);
  3519. end;
  3520. function DosOpen (FileName: PAnsiChar; var Handle: THandle;
  3521. Attrib, OpenMode: cardinal): cardinal;
  3522. var Action: cardinal;
  3523. begin
  3524. DosOpen:=DosOpen(FileName,Handle,Action,0,Attrib,1,OpenMode,nil);
  3525. end;
  3526. function DosOpen(const FileName:string;var Handle,Action:longint;
  3527. InitSize,Attrib,OpenFlags,OpenMode:longint;
  3528. EA:PEAOp2):cardinal;
  3529. var T:array[0..255] of AnsiChar;
  3530. begin
  3531. StrPCopy(@T,FileName);
  3532. DosOpen:=DosOpen(@T,Handle,Action,InitSize,Attrib,OpenFlags,OpenMode,EA);
  3533. end;
  3534. function DosOpen (const FileName: string; var Handle: THandle;
  3535. var Action: cardinal; InitSize, Attrib, OpenFlags: cardinal;
  3536. OpenMode: cardinal; EA: PEAOp2): cardinal;
  3537. var T:array[0..255] of AnsiChar;
  3538. begin
  3539. StrPCopy(@T,FileName);
  3540. DosOpen:=DosOpen(@T,Handle,Action,InitSize,Attrib,OpenFlags,OpenMode,EA);
  3541. end;
  3542. function DosCreate (const FileName: string; var Handle: THandle;
  3543. Attrib, OpenMode: cardinal): cardinal;
  3544. var T:array[0..255] of AnsiChar;
  3545. Action:cardinal;
  3546. begin
  3547. StrPCopy(@T,FileName);
  3548. DosCreate:=DosOpen(@T,Handle,Action,0,Attrib,18,OpenMode,nil);
  3549. end;
  3550. function DosOpen (const FileName: string; var Handle: THandle;
  3551. Attrib, OpenMode: cardinal): cardinal;
  3552. var T:array[0..255] of AnsiChar;
  3553. Action:cardinal;
  3554. begin
  3555. StrPCopy(@T,FileName);
  3556. DosOpen:=DosOpen(@T,Handle,Action,0,Attrib,1,OpenMode,nil);
  3557. end;
  3558. function DosClose (Handle: THandle): cardinal; cdecl;
  3559. external 'DOSCALLS' index 257;
  3560. function DosRead(Handle:longint;var Buffer;Count:longint;
  3561. var ActCount:longint):cardinal; cdecl;
  3562. external 'DOSCALLS' index 281;
  3563. function DosRead (Handle: THandle; var Buffer; Count: cardinal;
  3564. var ActCount: cardinal): cardinal; cdecl;
  3565. external 'DOSCALLS' index 281;
  3566. function DosWrite(Handle:longint;const Buffer;Count:longint;
  3567. var ActCount:longint):cardinal; cdecl;
  3568. external 'DOSCALLS' index 282;
  3569. function DosWrite (Handle: THandle; const Buffer; Count: cardinal;
  3570. var ActCount: cardinal): cardinal; cdecl;
  3571. external 'DOSCALLS' index 282;
  3572. function DosSetFilePtr(Handle:longint;Pos:longint;Method:cardinal;
  3573. var PosActual:longint):cardinal; cdecl;
  3574. external 'DOSCALLS' index 256;
  3575. function DosSetFilePtr (Handle: THandle; Pos: longint; Method: cardinal;
  3576. var PosActual: cardinal): cardinal; cdecl;
  3577. external 'DOSCALLS' index 256;
  3578. function DosSetFilePtr (Handle: THandle; Pos: longint): cardinal;
  3579. var PosActual: cardinal;
  3580. begin
  3581. DosSetFilePtr:=DosSetFilePtr(Handle,Pos,0,PosActual);
  3582. end;
  3583. function DosGetFilePtr(Handle:longint;var PosActual:longint):cardinal;
  3584. begin
  3585. DosGetFilePtr:=DosSetFilePtr(Handle,0,1,PosActual);
  3586. end;
  3587. function DosGetFilePtr (Handle: THandle; var PosActual: cardinal): cardinal;
  3588. begin
  3589. DosGetFilePtr:=DosSetFilePtr(Handle,0,1,PosActual);
  3590. end;
  3591. function DosSetFileSize (Handle: THandle; Size: cardinal): cardinal; cdecl;
  3592. external 'DOSCALLS' index 272;
  3593. function DosResetBuffer (Handle: THandle): cardinal; cdecl;
  3594. external 'DOSCALLS' index 254;
  3595. function DosDupHandle (Handle: THandle; var Duplicate: THandle): cardinal;
  3596. cdecl;
  3597. external 'DOSCALLS' index 260;
  3598. function DosQueryFHState(Handle:longint;var FileMode:longint):cardinal; cdecl;
  3599. external 'DOSCALLS' index 276;
  3600. function DosQueryFHState (Handle: THandle; var FileMode: cardinal): cardinal;
  3601. cdecl;
  3602. external 'DOSCALLS' index 276;
  3603. function DosSetFHState (Handle: THandle; FileMode: cardinal): cardinal; cdecl;
  3604. external 'DOSCALLS' index 221;
  3605. function DosQueryHType(Handle:longint;var HandType:longint;
  3606. var Attr:longint):cardinal; cdecl;
  3607. external 'DOSCALLS' index 224;
  3608. function DosQueryHType (Handle: THandle; var HandType: cardinal;
  3609. var Attr: cardinal): cardinal; cdecl;
  3610. external 'DOSCALLS' index 224;
  3611. function DosEditName (MetaLevel: cardinal; Source, Edit: PAnsiChar;
  3612. Target: PAnsiChar; TargetLen: cardinal): cardinal; cdecl;
  3613. external 'DOSCALLS' index 261;
  3614. function DosEditName (MetaLevel: cardinal; const Source, Edit: string;
  3615. var Target: string): cardinal;
  3616. var T,T2,T3:array[0..255] of AnsiChar;
  3617. begin
  3618. StrPCopy(@T,Source);
  3619. StrPCopy(@T2,Edit);
  3620. DosEditName:=DosEditName(MetaLevel,@T,@T2,@T3,SizeOf(T3));
  3621. Target:=StrPas(@T3);
  3622. end;
  3623. function DosMove(OldFile,NewFile:PAnsiChar):cardinal; cdecl;
  3624. external 'DOSCALLS' index 271;
  3625. function DosMove(const OldFile,NewFile:string):cardinal;
  3626. var T,T2:array[0..255] of AnsiChar;
  3627. begin
  3628. StrPCopy(@T,OldFile);
  3629. StrPCopy(@T2,NewFile);
  3630. DosMove:=DosMove(@T,@T2);
  3631. end;
  3632. function DosCopy (OldFile, NewFile: PAnsiChar; Option: cardinal): cardinal; cdecl;
  3633. external 'DOSCALLS' index 258;
  3634. function DosCopy (const OldFile, NewFile: string; Option: cardinal): cardinal;
  3635. var T,T2:array[0..255] of AnsiChar;
  3636. begin
  3637. StrPCopy(@T,OldFile);
  3638. StrPCopy(@T2,NewFile);
  3639. DosCopy:=DosCopy(@T,@T2,Option);
  3640. end;
  3641. function DosDelete(FileName:PAnsiChar):cardinal; cdecl;
  3642. external 'DOSCALLS' index 259;
  3643. function DosDelete(const FileName:string):cardinal;
  3644. var T:array[0..255] of AnsiChar;
  3645. begin
  3646. StrPCopy(@T,FileName);
  3647. DosDelete:=DosDelete(@T);
  3648. end;
  3649. function DosForceDelete(FileName:PAnsiChar):cardinal; cdecl;
  3650. external 'DOSCALLS' index 110;
  3651. function DosForceDelete(const FileName:string):cardinal;
  3652. var T:array[0..255] of AnsiChar;
  3653. begin
  3654. StrPCopy(@T,FileName);
  3655. DosForceDelete:=DosForceDelete(@T);
  3656. end;
  3657. function DosCreateDir(Name:PAnsiChar;EA:PEAOp2):cardinal; cdecl;
  3658. external 'DOSCALLS' index 270;
  3659. function DosCreateDir(Name:PAnsiChar):cardinal;
  3660. begin
  3661. DosCreateDir:=DosCreateDir(Name,nil);
  3662. end;
  3663. function DosCreateDir(const Name:string;EA:PEAOp2):cardinal;
  3664. var T:array[0..255] of AnsiChar;
  3665. begin
  3666. StrPCopy(@T,Name);
  3667. DosCreateDir:=DosCreateDir(@T,EA);
  3668. end;
  3669. function DosCreateDir(const Name:string):cardinal;
  3670. var T:array[0..255] of AnsiChar;
  3671. begin
  3672. StrPCopy(@T,Name);
  3673. DosCreateDir:=DosCreateDir(@T,nil);
  3674. end;
  3675. function DosDeleteDir(Name:PAnsiChar):cardinal; cdecl;
  3676. external 'DOSCALLS' index 226;
  3677. function DosDeleteDir(const Name:string):cardinal;
  3678. var T:array[0..255] of AnsiChar;
  3679. begin
  3680. StrPCopy(@T,Name);
  3681. DosDeleteDir:=DosDeleteDir(@T);
  3682. end;
  3683. function DosSetDefaultDisk(DiskNum:cardinal):cardinal; cdecl;
  3684. external 'DOSCALLS' index 220;
  3685. procedure DosQueryCurrentDisk(var DiskNum:longint;var Logical:longint); cdecl;
  3686. external 'DOSCALLS' index 275;
  3687. procedure DosQueryCurrentDisk (var DiskNum: cardinal; var Logical: cardinal);
  3688. cdecl;
  3689. external 'DOSCALLS' index 275;
  3690. function DosSetCurrentDir(Name:PAnsiChar):cardinal; cdecl;
  3691. external 'DOSCALLS' index 255;
  3692. function DosSetCurrentDir(const Name:string):cardinal;
  3693. var T:array[0..255] of AnsiChar;
  3694. begin
  3695. StrPCopy(@T,Name);
  3696. DosSetCurrentDir:=DosSetCurrentDir(@T);
  3697. end;
  3698. function DosQueryCurrentDir(DiskNum:longint;var Buffer;
  3699. var BufLen:longint):cardinal; cdecl;
  3700. external 'DOSCALLS' index 274;
  3701. function DosQueryCurrentDir (DiskNum: cardinal; var Buffer;
  3702. var BufLen: cardinal): cardinal; cdecl;
  3703. external 'DOSCALLS' index 274;
  3704. function DosQueryCurrentDir (DiskNum: cardinal; var Buffer: string): cardinal;
  3705. var T:array[0..255] of AnsiChar;
  3706. L: cardinal;
  3707. begin
  3708. L:=255;
  3709. DosQueryCurrentDir:=DosQueryCurrentDir(DiskNum,T,L);
  3710. Buffer:=StrPas(@T);
  3711. end;
  3712. function DosDevIOCtl(Handle,Category,Func:longint;var Params;
  3713. ParamLen:longint;var ParamSize:longint;
  3714. var Data;DataLen:longint;var DataSize:longint):cardinal; cdecl;
  3715. external 'DOSCALLS' index 284;
  3716. function DosDevIOCtl (Handle: THandle; Category, Func: cardinal; var Params;
  3717. ParamLen: cardinal; var ParamSize: cardinal;
  3718. var Data; DataLen: cardinal; var DataSize: cardinal):
  3719. cardinal; cdecl;
  3720. external 'DOSCALLS' index 284;
  3721. function DosFindFirst (FileMask: PAnsiChar; var Handle: THandle; Attrib: cardinal;
  3722. AFileStatus: PFileStatus; FileStatusLen: cardinal;
  3723. var Count: cardinal; InfoLevel: cardinal): cardinal;
  3724. cdecl;
  3725. external 'DOSCALLS' index 264;
  3726. function DosFindFirst (const FileMask: string; var Handle: THandle;
  3727. Attrib: cardinal; AFileStatus: PFileStatus;
  3728. FileStatusLen: cardinal; var Count: cardinal;
  3729. InfoLevel: cardinal): cardinal;
  3730. var T:array[0..255] of AnsiChar;
  3731. begin
  3732. StrPCopy(@T,FileMask);
  3733. DosFindFirst:=DosFindFirst(@T,Handle,Attrib,AFileStatus,FileStatusLen,
  3734. Count,InfoLevel);
  3735. end;
  3736. function DosFindNext (Handle: THandle; AFileStatus: PFileStatus;
  3737. FileStatusLen: cardinal; var Count: cardinal): cardinal;
  3738. cdecl;
  3739. external 'DOSCALLS' index 265;
  3740. function DosFindClose (Handle: THandle): cardinal; cdecl;
  3741. external 'DOSCALLS' index 263;
  3742. function DosQueryFileInfo (Handle: THandle; InfoLevel: cardinal;
  3743. AFileStatus: PFileStatus;
  3744. FileStatusLen: cardinal): cardinal; cdecl;
  3745. external 'DOSCALLS' index 279;
  3746. function DosSetFileInfo (Handle: THandle; InfoLevel: cardinal;
  3747. AFileStatus: PFileStatus;
  3748. FileStatusLen: cardinal): cardinal; cdecl;
  3749. external 'DOSCALLS' index 218;
  3750. function DosQueryPathInfo (FileName: PAnsiChar; InfoLevel: cardinal;
  3751. AFileStatus: PFileStatus; FileStatusLen: cardinal): cardinal; cdecl;
  3752. external 'DOSCALLS' index 223;
  3753. function DosQueryPathInfo (const FileName: string; InfoLevel: cardinal;
  3754. AFileStatus: PFileStatus; FileStatusLen: cardinal): cardinal;
  3755. var T:array[0..255] of AnsiChar;
  3756. begin
  3757. StrPCopy(@T,FileName);
  3758. DosQueryPathInfo:=DosQueryPathInfo(@T,InfoLevel,AFileStatus,
  3759. FileStatusLen);
  3760. end;
  3761. function DosSetPathInfo (FileName: PAnsiChar; InfoLevel: cardinal;
  3762. AFileStatus: PFileStatus; FileStatusLen,
  3763. Options: cardinal): cardinal; cdecl;
  3764. external 'DOSCALLS' index 219;
  3765. function DosEnumAttribute(RefType:longint;AFile:pointer;
  3766. Entry:longint;var Buf;BufSize:longint;
  3767. var Count:longint;InfoLevel:longint):cardinal; cdecl;
  3768. external 'DOSCALLS' index 372;
  3769. function DosEnumAttribute (RefType: cardinal; AFile: pointer;
  3770. Entry: cardinal; var Buf; BufSize: cardinal;
  3771. var Count: cardinal; InfoLevel: cardinal): cardinal;
  3772. cdecl;
  3773. external 'DOSCALLS' index 372;
  3774. function DosEnumAttribute (RefType: cardinal; AFile: PAnsiChar;
  3775. Entry: cardinal; var Buf; BufSize: cardinal;
  3776. var Count: cardinal; InfoLevel: cardinal): cardinal;
  3777. cdecl;
  3778. external 'DOSCALLS' index 372;
  3779. function DosEnumAttribute (RefType: cardinal; const AFile: THandle;
  3780. Entry: cardinal; var Buf; BufSize: cardinal;
  3781. var Count: cardinal; InfoLevel: cardinal): cardinal;
  3782. cdecl;
  3783. external 'DOSCALLS' index 372;
  3784. function DosEnumAttribute (Handle: longint; Entry: longint; var Buf;
  3785. BufSize: longint;
  3786. var Count: longint; InfoLevel: longint): cardinal;
  3787. begin
  3788. DosEnumAttribute:=DosEnumAttribute(0,@Handle,Entry,Buf,BufSize,Count,
  3789. InfoLevel);
  3790. end;
  3791. function DosEnumAttribute (Handle: THandle; Entry: cardinal; var Buf;
  3792. BufSize: cardinal;
  3793. var Count: cardinal; InfoLevel: cardinal): cardinal;
  3794. begin
  3795. DosEnumAttribute:=DosEnumAttribute(0,@Handle,Entry,Buf,BufSize,Count,
  3796. InfoLevel);
  3797. end;
  3798. function DosEnumAttribute (const FileName: string;
  3799. Entry: cardinal;var Buf;BufSize: cardinal;
  3800. var Count: cardinal; InfoLevel: cardinal): cardinal;
  3801. var T:array[0..255] of AnsiChar;
  3802. begin
  3803. StrPCopy(@T,FileName);
  3804. DosEnumAttribute:=DosEnumAttribute(1,@T,Entry,Buf,BufSize,Count,
  3805. InfoLevel);
  3806. end;
  3807. function DosScanEnv(Name:PAnsiChar;var Value:PAnsiChar):cardinal; cdecl;
  3808. external 'DOSCALLS' index 227;
  3809. function DosScanEnv(const Name:string;var Value:string):cardinal;
  3810. var T:array[0..255] of AnsiChar;
  3811. P:PAnsiChar;
  3812. begin
  3813. StrPCopy(@T,Name);
  3814. DosScanEnv:=DosScanEnv(@T,P);
  3815. Value:=StrPas(P);
  3816. end;
  3817. function DosSearchPath (Flag: cardinal; DirList, FileName: PAnsiChar;
  3818. FullName: PAnsiChar; FullLen: cardinal): cardinal; cdecl;
  3819. external 'DOSCALLS' index 228;
  3820. function DosSearchPath (Flag: cardinal; const DirList, FileName: string;
  3821. var FullName: string): cardinal;
  3822. var T1,T2,T3:array[0..255] of AnsiChar;
  3823. begin
  3824. StrPCopy(@T1,DirList);
  3825. StrPCopy(@T2,FileName);
  3826. DosSearchPath:=DosSearchPath(Flag,@T1,@T2,@T3,SizeOf(T3));
  3827. FullName:=StrPas(@T3);
  3828. end;
  3829. function DosFSAttach (DevName, FileSystem: PAnsiChar; var Data: TAttachData;
  3830. DataLen, Flag: cardinal):cardinal; cdecl;
  3831. external 'DOSCALLS' index 269;
  3832. function DosFSAttach (const DevName, FileSystem: string; var Data: TAttachData;
  3833. DataLen, Flag: cardinal): cardinal;
  3834. var T1,T2:array[0..255] of AnsiChar;
  3835. begin
  3836. StrPCopy(@T1,DevName);
  3837. StrPCopy(@T2,FileSystem);
  3838. DosFSAttach:=DosFSAttach(@T1,@T2,Data,DataLen,Flag);
  3839. end;
  3840. function DosQueryFSAttach(DevName:PAnsiChar;Ordinal,InfoLevel:longint;
  3841. var Buffer:TFSQBuffer2;var BufLen:longint):cardinal; cdecl;
  3842. external 'DOSCALLS' index 277;
  3843. function DosQueryFSAttach (DevName: PAnsiChar; Ordinal, InfoLevel: cardinal;
  3844. var Buffer: TFSQBuffer2; var BufLen: cardinal): cardinal; cdecl;
  3845. external 'DOSCALLS' index 277;
  3846. function DosQueryFSAttach(const DevName:string;Ordinal,InfoLevel:longint;
  3847. var Buffer:TFSQBuffer2;var BufLen:longint):cardinal;
  3848. var T:array[0..255] of AnsiChar;
  3849. begin
  3850. StrPCopy(@T,DevName);
  3851. DosQueryFSAttach:=DosQueryFSAttach(@T,Ordinal,InfoLevel,Buffer,BufLen);
  3852. end;
  3853. function DosQueryFSAttach (const DevName: string; Ordinal, InfoLevel: cardinal;
  3854. var Buffer: TFSQBuffer2; var BufLen: cardinal): cardinal;
  3855. var T:array[0..255] of AnsiChar;
  3856. begin
  3857. StrPCopy(@T,DevName);
  3858. DosQueryFSAttach:=DosQueryFSAttach(@T,Ordinal,InfoLevel,Buffer,BufLen);
  3859. end;
  3860. function DosFSCtl(Data:pointer;DataLen:longint;var ResDataLen:longint;
  3861. Parms:pointer;ParmsLen:longint;var ResParmsLen:longint;
  3862. _Function:longint;Route:PAnsiChar;
  3863. Handle,Method:longint):cardinal; cdecl;
  3864. external 'DOSCALLS' index 285;
  3865. function DosFSCtl (Data: pointer; DataLen: cardinal; var ResDataLen: cardinal;
  3866. Parms: pointer; ParmsLen: cardinal;
  3867. var ResParmsLen: cardinal; _Function: cardinal;
  3868. Route: PAnsiChar; Handle: THandle; Method: cardinal): cardinal;
  3869. cdecl;
  3870. external 'DOSCALLS' index 285;
  3871. function DosFSCtl(Data:pointer;DataLen:longint;var ResDataLen:longint;
  3872. Parms:pointer;ParmsLen:longint;var ResParmsLen:longint;
  3873. _Function:longint;const Route:string;
  3874. Handle,Method:longint):cardinal;
  3875. var T:array[0..255] of AnsiChar;
  3876. begin
  3877. StrPCopy(@T,Route);
  3878. DosFSCtl:=DosFSCtl(Data,Datalen,ResDataLen,Parms,ParmsLen,ResParmsLen,
  3879. _Function,Route,Handle,Method);
  3880. end;
  3881. function DosFSCtl (Data: pointer; DataLen: cardinal; var ResDataLen: cardinal;
  3882. Parms: pointer; ParmsLen: cardinal;
  3883. var ResParmsLen: cardinal; _Function: cardinal;
  3884. const Route: string; Handle: THandle; Method: cardinal):
  3885. cardinal;
  3886. var T:array[0..255] of AnsiChar;
  3887. begin
  3888. StrPCopy(@T,Route);
  3889. DosFSCtl:=DosFSCtl(Data,Datalen,ResDataLen,Parms,ParmsLen,ResParmsLen,
  3890. _Function,Route,Handle,Method);
  3891. end;
  3892. function DosQueryFSInfo (DiskNum, InfoLevel: cardinal; var Buffer: TFSInfo;
  3893. BufLen: cardinal): cardinal; cdecl;
  3894. external 'DOSCALLS' index 278;
  3895. function DosSetFSInfo (DiskNum, InfoLevel: cardinal; var Buffer: TFSInfo;
  3896. BufLen: cardinal): cardinal; cdecl;
  3897. external 'DOSCALLS' index 222;
  3898. function DosQueryVerify(var Enabled:longint):cardinal; cdecl;
  3899. external 'DOSCALLS' index 225;
  3900. function DosQueryVerify (var Enabled: cardinal): cardinal; cdecl;
  3901. external 'DOSCALLS' index 225;
  3902. function DosQueryVerify (var Enabled: boolean): cardinal;
  3903. var
  3904. En: cardinal;
  3905. RC: cardinal;
  3906. begin
  3907. RC := DosQueryVerify (En);
  3908. Enabled := boolean (En);
  3909. DosQueryVerify := RC;
  3910. end;
  3911. function DosSetVerify (Enable: cardinal): cardinal; cdecl;
  3912. external 'DOSCALLS' index 210;
  3913. function DosSetVerify (Enable: boolean): cardinal;
  3914. begin
  3915. DosSetVerify := DosSetVerify (cardinal (Enable));
  3916. end;
  3917. function DosSetMaxFH (Count: cardinal): cardinal; cdecl;
  3918. external 'DOSCALLS' index 209;
  3919. function DosSetRelMaxFH(var ReqCount,CurMaxFH:longint):cardinal; cdecl;
  3920. external 'DOSCALLS' index 382;
  3921. function DosSetRelMaxFH (var ReqCount: longint; var CurMaxFH: cardinal):
  3922. cardinal; cdecl;
  3923. external 'DOSCALLS' index 382;
  3924. function DosShutDown (Flags: cardinal): cardinal; cdecl;
  3925. external 'DOSCALLS' index 415;
  3926. function DosQuerySysInfo (First, Last: cardinal; var Buf; BufSize: cardinal):
  3927. cardinal; cdecl;
  3928. external 'DOSCALLS' index 348;
  3929. function DosQuerySysInfo(First,Last:cardinal;Buf:PQSVValues;
  3930. BufSize:cardinal):cardinal;cdecl;
  3931. external 'DOSCALLS' index 348;
  3932. function DosPhysicalDisk (Func: cardinal; Buf: pointer; BufSize: cardinal;
  3933. Params: pointer; ParamSize: cardinal): cardinal;
  3934. cdecl;
  3935. external 'DOSCALLS' index 287;
  3936. function DosAllocMem (var P: pointer; Size, Flag: cardinal): cardinal; cdecl;
  3937. external 'DOSCALLS' index 299;
  3938. function DosFreeMem (P: pointer): cardinal; cdecl;
  3939. external 'DOSCALLS' index 304;
  3940. function DosSetMem (P: pointer; Size, Flag: cardinal): cardinal; cdecl;
  3941. external 'DOSCALLS' index 305;
  3942. function DosGiveSharedMem (P: pointer; PID, Flag: cardinal): cardinal; cdecl;
  3943. external 'DOSCALLS' index 303;
  3944. function DosGetSharedMem (P: pointer; Flag: cardinal): cardinal; cdecl;
  3945. external 'DOSCALLS' index 302;
  3946. function DosGetNamedSharedMem (var P: pointer; Name: PAnsiChar; Flag: cardinal):
  3947. cardinal; cdecl;
  3948. external 'DOSCALLS' index 301;
  3949. function DosGetNamedSharedMem (var P: pointer; const Name: string;
  3950. Flag: cardinal): cardinal;
  3951. var T:array[0..255] of AnsiChar;
  3952. begin
  3953. StrPCopy(@T,Name);
  3954. DosGetNamedSharedMem:=DosGetNamedSharedMem(P,@T,Flag);
  3955. end;
  3956. function DosAllocSharedMem (var P: pointer; Name: PAnsiChar;
  3957. Size, Flag: cardinal): cardinal; cdecl;
  3958. external 'DOSCALLS' index 300;
  3959. function DosAllocSharedMem (var P: pointer; const Name: string;
  3960. Size, Flag: cardinal): cardinal;
  3961. var T:array[0..255] of AnsiChar;
  3962. begin
  3963. if Name<>'' then
  3964. begin
  3965. StrPCopy(@T,Name);
  3966. DosAllocSharedMem:=DosAllocSharedMem(P,@T,Size,Flag);
  3967. end
  3968. else
  3969. DosAllocSharedMem:=DosAllocSharedMem(P,nil,Size,Flag);
  3970. end;
  3971. function DosQueryMem(P:pointer;var Size,Flag:longint):cardinal; cdecl;
  3972. external 'DOSCALLS' index 306;
  3973. function DosQueryMem (P: pointer; var Size, Flag: cardinal): cardinal; cdecl;
  3974. external 'DOSCALLS' index 306;
  3975. function DosSubAllocMem (Base: pointer; var P: pointer; Size: cardinal):
  3976. cardinal; cdecl;
  3977. external 'DOSCALLS' index 345;
  3978. function DosSubFreeMem (Base, P: pointer; Size: cardinal): cardinal; cdecl;
  3979. external 'DOSCALLS' index 346;
  3980. function DosSubSetMem (Base: pointer; Flag, Size: cardinal): cardinal; cdecl;
  3981. external 'DOSCALLS' index 344;
  3982. function DosSubUnSetMem (Base: pointer): cardinal; cdecl;
  3983. external 'DOSCALLS' index 347;
  3984. function DosCreateEventSem (Name: PAnsiChar; var Handle: THandle;
  3985. Attr, State: cardinal): cardinal; cdecl;
  3986. external 'DOSCALLS' index 324;
  3987. function DosCreateEventSem (Name: PAnsiChar; var Handle: THandle;
  3988. Attr: cardinal; State: boolean): cardinal;
  3989. begin
  3990. DosCreateEventSem :=
  3991. DosCreateEventSem (Name, Handle, Attr, cardinal (State));
  3992. end;
  3993. function DosCreateEventSem (const Name: string; var Handle: THandle;
  3994. Attr: cardinal; State: boolean): cardinal;
  3995. var T:array[0..255] of AnsiChar;
  3996. begin
  3997. if Name<>'' then
  3998. begin
  3999. StrPCopy(@T,Name);
  4000. DosCreateEventSem :=
  4001. DosCreateEventSem (@T, Handle, Attr, cardinal (State));
  4002. end
  4003. else
  4004. DosCreateEventSem :=
  4005. DosCreateEventSem (nil, Handle, Attr, cardinal (State));
  4006. end;
  4007. function DosCreateEventSem (const Name: string; var Handle: THandle;
  4008. Attr, State: cardinal): cardinal;
  4009. begin
  4010. DosCreateEventSem := DosCreateEventSem (Name, Handle, Attr, boolean (State));
  4011. end;
  4012. function DosOpenEventSem (Name: PAnsiChar; var Handle: THandle): cardinal; cdecl;
  4013. external 'DOSCALLS' index 325;
  4014. function DosOpenEventSem (const Name: string; var Handle: THandle): cardinal;
  4015. var T:array[0..255] of AnsiChar;
  4016. begin
  4017. StrPCopy(@T,Name);
  4018. DosOpenEventSem:=DosOpenEventSem(@T,Handle);
  4019. end;
  4020. function DosCloseEventSem (Handle: THandle): cardinal; cdecl;
  4021. external 'DOSCALLS' index 326;
  4022. function DosResetEventSem(Handle:longint;var PostCount:longint):cardinal; cdecl;
  4023. external 'DOSCALLS' index 327;
  4024. function DosResetEventSem (Handle: THandle; var PostCount: cardinal): cardinal;
  4025. cdecl;
  4026. external 'DOSCALLS' index 327;
  4027. function DosPostEventSem (Handle: THandle): cardinal; cdecl;
  4028. external 'DOSCALLS' index 328;
  4029. function DosWaitEventSem (Handle: THandle; Timeout: cardinal): cardinal; cdecl;
  4030. external 'DOSCALLS' index 329;
  4031. function DosQueryEventSem(Handle:longint;var Posted:longint):cardinal; cdecl;
  4032. external 'DOSCALLS' index 330;
  4033. function DosQueryEventSem (Handle: THandle; var Posted: cardinal): cardinal;
  4034. cdecl;
  4035. external 'DOSCALLS' index 330;
  4036. function DosCreateMutExSem (Name: PAnsiChar; var Handle: THandle;
  4037. Attr, State: cardinal): cardinal; cdecl;
  4038. external 'DOSCALLS' index 331;
  4039. function DosCreateMutExSem (Name: PAnsiChar; var Handle: THandle;
  4040. Attr: cardinal; State: boolean): cardinal;
  4041. begin
  4042. DosCreateMutExSem :=
  4043. DosCreateMutExSem (Name, Handle, Attr, cardinal (State));
  4044. end;
  4045. function DosCreateMutExSem (const Name: string; var Handle: THandle;
  4046. Attr: cardinal; State: boolean): cardinal;
  4047. var T:array[0..255] of AnsiChar;
  4048. begin
  4049. if Name<>'' then
  4050. begin
  4051. StrPCopy(@T,Name);
  4052. DosCreateMutExSem :=
  4053. DosCreateMutExSem (@T, Handle, Attr, cardinal (State));
  4054. end
  4055. else
  4056. DosCreateMutExSem :=
  4057. DosCreateMutExSem (nil, Handle, Attr, cardinal (State));
  4058. end;
  4059. function DosCreateMutExSem (const Name: string; var Handle: THandle;
  4060. Attr, State: cardinal): cardinal;
  4061. begin
  4062. DosCreateMutExSem :=
  4063. DosCreateMutExSem (Name, Handle, Attr, boolean (State));
  4064. end;
  4065. function DosOpenMutExSem (Name: PAnsiChar; var Handle: THandle): cardinal; cdecl;
  4066. external 'DOSCALLS' index 332;
  4067. function DosOpenMutExSem (const Name: string; var Handle: THandle): cardinal;
  4068. var T:array[0..255] of AnsiChar;
  4069. begin
  4070. StrPCopy(@T,Name);
  4071. DosOpenMutExSem:=DosOpenMutExSem(@T,Handle);
  4072. end;
  4073. function DosCloseMutExSem (Handle: THandle): cardinal; cdecl;
  4074. external 'DOSCALLS' index 333;
  4075. function DosRequestMutExSem (Handle: THandle; Timeout: cardinal): cardinal;
  4076. cdecl;
  4077. external 'DOSCALLS' index 334;
  4078. function DosReleaseMutExSem (Handle: THandle): cardinal; cdecl;
  4079. external 'DOSCALLS' index 335;
  4080. function DosQueryMutExSem(Handle:longint;var PID,TID,Count:longint):cardinal;
  4081. cdecl;
  4082. external 'DOSCALLS' index 336;
  4083. function DosQueryMutExSem (Handle: THandle; var PID, TID, Count: cardinal):
  4084. cardinal; cdecl;
  4085. external 'DOSCALLS' index 336;
  4086. function DosCreateMuxWaitSem (Name: PAnsiChar; var Handle: THandle;
  4087. CSemRec: cardinal; var SemArray: TSemArray;
  4088. Attr: cardinal): cardinal; cdecl;
  4089. external 'DOSCALLS' index 337;
  4090. function DosCreateMuxWaitSem (Name: PAnsiChar; var Handle: THandle;
  4091. CSemRec: cardinal; SemArray: PSemArray;
  4092. Attr: cardinal): cardinal; cdecl;
  4093. external 'DOSCALLS' index 337;
  4094. function DosCreateMuxWaitSem (const Name: string; var Handle: THandle;
  4095. CSemRec: cardinal; var SemArray: TSemArray;
  4096. Attr: cardinal): cardinal;
  4097. var T:array[0..255] of AnsiChar;
  4098. begin
  4099. if Name<>'' then
  4100. begin
  4101. StrPCopy(@T,Name);
  4102. DosCreateMuxWaitSem:=DosCreateMuxWaitSem(@T,Handle,CSemRec,
  4103. SemArray,Attr);
  4104. end
  4105. else
  4106. DosCreateMuxWaitSem:=DosCreateMuxWaitSem(nil,Handle,CSemRec,SemArray,
  4107. Attr);
  4108. end;
  4109. function DosOpenMuxWaitSem (Name: PAnsiChar; var Handle: THandle): cardinal; cdecl;
  4110. external 'DOSCALLS' index 338;
  4111. function DosOpenMuxWaitSem (const Name: string; var Handle: THandle): cardinal;
  4112. var T:array[0..255] of AnsiChar;
  4113. begin
  4114. StrPCopy(@T,Name);
  4115. DosOpenMuxWaitSem:=DosOpenMuxWaitSem(@T,Handle);
  4116. end;
  4117. function DosCloseMuxWaitSem (Handle: THandle): cardinal; cdecl;
  4118. external 'DOSCALLS' index 339;
  4119. function DosWaitMuxWaitSem(Handle,Timeout:longint;var User:longint):cardinal;
  4120. cdecl;
  4121. external 'DOSCALLS' index 340;
  4122. function DosWaitMuxWaitSem (Handle: THandle; Timeout: cardinal;
  4123. var User: cardinal): cardinal; cdecl;
  4124. external 'DOSCALLS' index 340;
  4125. function DosAddMuxWaitSem (Handle: THandle; var SemRec: TSemRecord): cardinal;
  4126. cdecl;
  4127. external 'DOSCALLS' index 341;
  4128. function DosDeleteMuxWaitSem (Handle, Sem: THandle): cardinal; cdecl;
  4129. external 'DOSCALLS' index 342;
  4130. function DosQueryMuxWaitSem(Handle:longint;var CSemRec:longint;
  4131. var SemRecs:TSemArray;var Attr:longint):cardinal; cdecl;
  4132. external 'DOSCALLS' index 343;
  4133. function DosQueryMuxWaitSem (Handle: THandle; var CSemRec: cardinal;
  4134. var SemRecs: TSemArray; var Attr: cardinal): cardinal; cdecl;
  4135. external 'DOSCALLS' index 343;
  4136. function DosGetDateTime (var Buf: TDateTime): cardinal; cdecl;
  4137. external 'DOSCALLS' index 230;
  4138. function DosSetDateTime (var Buf: TDateTime): cardinal; cdecl;
  4139. external 'DOSCALLS' index 292;
  4140. function DosAsyncTimer (MSec: cardinal; HSem: THandle;
  4141. var TimHandle: THandle): cardinal; cdecl;
  4142. external 'DOSCALLS' index 350;
  4143. function DosStartTimer (MSec: cardinal; HSem: THandle;
  4144. var TimHandle: THandle): cardinal; cdecl;
  4145. external 'DOSCALLS' index 351;
  4146. function DosStopTimer (TimHandle: THandle): cardinal; cdecl;
  4147. external 'DOSCALLS' index 290;
  4148. function DosTmrQueryFreq(var Freq:longint):cardinal; cdecl;
  4149. external 'DOSCALLS' index 362;
  4150. function DosTmrQueryFreq (var Freq: cardinal): cardinal; cdecl;
  4151. external 'DOSCALLS' index 362;
  4152. function DosTmrQueryTime (var Time: comp): cardinal; cdecl;
  4153. external 'DOSCALLS' index 363;
  4154. function DosTmrQueryTime (var Time: qword): cardinal; cdecl;
  4155. external 'DOSCALLS' index 363;
  4156. function DosLoadModule (ObjName: PAnsiChar; ObjLen: cardinal; DLLName: PAnsiChar;
  4157. var Handle: THandle): cardinal; cdecl;
  4158. external 'DOSCALLS' index 318;
  4159. function DosLoadModule (var ObjName: string; ObjLen: cardinal;
  4160. const DLLName: string; var Handle: THandle): cardinal;
  4161. var T1,T2:array[0..255] of AnsiChar;
  4162. begin
  4163. StrPCopy(@T2,DLLName);
  4164. DosLoadModule:=DosLoadModule(@T1,ObjLen,@T2,Handle);
  4165. ObjName:=StrPas(@T1);
  4166. end;
  4167. function DosFreeModule (Handle: THandle): cardinal; cdecl;
  4168. external 'DOSCALLS' index 322;
  4169. function DosQueryProcAddr (Handle: THandle; Ordinal: cardinal; ProcName: PAnsiChar;
  4170. var Address: pointer): cardinal; cdecl;
  4171. external 'DOSCALLS' index 321;
  4172. function DosQueryProcAddr (Handle: THandle; Ordinal: cardinal;
  4173. const ProcName: string; var Address: pointer): cardinal;
  4174. var T1:array[0..255] of AnsiChar;
  4175. begin
  4176. if ProcName<>'' then
  4177. begin
  4178. StrPCopy(@T1,ProcName);
  4179. DosQueryProcAddr:=DosQueryProcAddr(Handle,Ordinal,@T1,Address);
  4180. end
  4181. else
  4182. DosQueryProcAddr:=DosQueryProcAddr(Handle,Ordinal,nil,Address);
  4183. end;
  4184. function DosQueryModuleHandle (DLLName: PAnsiChar; var Handle: THandle): cardinal;
  4185. cdecl;
  4186. external 'DOSCALLS' index 319;
  4187. function DosQueryModuleHandle (const DLLName: string; var Handle: THandle):
  4188. cardinal;
  4189. var T1:array[0..255] of AnsiChar;
  4190. begin
  4191. StrPCopy(@T1,DLLName);
  4192. DosQueryModuleHandle:=DosQueryModuleHandle(@T1,Handle);
  4193. end;
  4194. function DosQueryModuleName (Handle: THandle; NameLen: cardinal; Name: PAnsiChar):
  4195. cardinal; cdecl;
  4196. external 'DOSCALLS' index 320;
  4197. {function DosQueryModuleName(Handle:longint;var Name:openstring):cardinal;
  4198. var T1:array[0..255] of AnsiChar;
  4199. begin
  4200. DosQueryModuleName:=DosQueryModuleName(Handle,High(Name),@T1);
  4201. Name:=StrPas(@T1);
  4202. end;}
  4203. function DosQueryProcType(Handle,Ordinal:longint;Name:PAnsiChar;
  4204. var ProcType:longint):cardinal; cdecl;
  4205. external 'DOSCALLS' index 586;
  4206. function DosQueryProcType (Handle: THandle; Ordinal: cardinal; Name: PAnsiChar;
  4207. var ProcType: cardinal): cardinal; cdecl;
  4208. external 'DOSCALLS' index 586;
  4209. function DosQueryProcType(Handle,Ordinal:longint;const Name:string;
  4210. var ProcType:longint):cardinal;
  4211. var T1:array[0..255] of AnsiChar;
  4212. begin
  4213. if Name<>'' then
  4214. begin
  4215. StrPCopy(@T1,Name);
  4216. DosQueryProcType:=DosQueryProcType(Handle,Ordinal,@T1,ProcType);
  4217. end
  4218. else
  4219. DosQueryProcType:=DosQueryProcType(Handle,Ordinal,nil,ProcType);
  4220. end;
  4221. function DosQueryProcType (Handle: THandle; Ordinal: cardinal;
  4222. const Name: string; var ProcType: cardinal): cardinal;
  4223. var T1:array[0..255] of AnsiChar;
  4224. begin
  4225. if Name<>'' then
  4226. begin
  4227. StrPCopy(@T1,Name);
  4228. DosQueryProcType:=DosQueryProcType(Handle,Ordinal,@T1,ProcType);
  4229. end
  4230. else
  4231. DosQueryProcType:=DosQueryProcType(Handle,Ordinal,nil,ProcType);
  4232. end;
  4233. function DosGetResource (Handle: THandle; ResType, ResName: cardinal;
  4234. var P: pointer): cardinal; cdecl;
  4235. external 'DOSCALLS' index 352;
  4236. function DosFreeResource (P: pointer): cardinal; cdecl;
  4237. external 'DOSCALLS' index 353;
  4238. function DosQueryResourceSize(Handle,IDT,IDN:longint;var Size:longint):cardinal;
  4239. cdecl;
  4240. external 'DOSCALLS' index 572;
  4241. function DosQueryResourceSize (Handle: THandle; IDT, IDN: cardinal;
  4242. var Size: cardinal): cardinal; cdecl;
  4243. external 'DOSCALLS' index 572;
  4244. function DosQueryCtryInfo(Size:longint;var Country:TCountryCode;
  4245. var Res:TCountryInfo;var ActualSize:longint):cardinal; cdecl;
  4246. external 'NLS' index 5;
  4247. function DosQueryCtryInfo (Size: cardinal; var Country: TCountryCode;
  4248. var Res: TCountryInfo; var ActualSize: cardinal): cardinal; cdecl;
  4249. external 'NLS' index 5;
  4250. function DosQueryDBCSEnv (Size: cardinal; var Country: TCountryCode;
  4251. Buf: PAnsiChar): cardinal; cdecl;
  4252. external 'NLS' index 6;
  4253. function DosMapCase (Size: cardinal; var Country: TCountryCode;
  4254. AString: PAnsiChar): cardinal; cdecl;
  4255. external 'NLS' index 7;
  4256. function DosMapCase (var Country: TCountryCode; var AString: string): cardinal;
  4257. var T1:string;
  4258. begin
  4259. StrPCopy(@T1,AString);
  4260. DosMapCase:=DosMapCase(length(AString),Country,@T1);
  4261. AString:=StrPas(@T1);
  4262. end;
  4263. function DosQueryCollate(Size:longint;var Country:TCountryCode;
  4264. buf:PByteArray;var TableLen:longint):cardinal; cdecl;
  4265. external 'NLS' index 8;
  4266. function DosQueryCollate (Size: cardinal; var Country: TCountryCode;
  4267. Buf: PByteArray; var TableLen: cardinal): cardinal; cdecl;
  4268. external 'NLS' index 8;
  4269. function DosQueryCP(Size:longint; PCodePages:PWordArray;
  4270. var ActSize:longint):cardinal; cdecl;
  4271. external 'DOSCALLS' index 291;
  4272. function DosQueryCP (Size: cardinal; PCodePages: PWordArray;
  4273. var ActSize: cardinal): cardinal; cdecl;
  4274. external 'DOSCALLS' index 291;
  4275. function DosQueryCP (Size: cardinal; var CodePages;
  4276. var ActSize: cardinal): cardinal; cdecl;
  4277. external 'DOSCALLS' index 291;
  4278. function DosSetProcessCP (CP: cardinal): cardinal; cdecl;
  4279. external 'DOSCALLS' index 289;
  4280. function DosSetExceptionHandler (var RegRec: TExceptionRegistrationRecord):
  4281. cardinal; cdecl;
  4282. external 'DOSCALLS' index 354;
  4283. function DosUnsetExceptionHandler (var RegRec: TExceptionRegistrationRecord):
  4284. cardinal; cdecl;
  4285. external 'DOSCALLS' index 355;
  4286. function DosRaiseException (var Excpt: TExceptionReportRecord): cardinal;
  4287. cdecl;
  4288. external 'DOSCALLS' index 356;
  4289. function DosSendSignalException (PID, Exception: cardinal): cardinal; cdecl;
  4290. external 'DOSCALLS' index 379;
  4291. function DosUnwindException (var Handler: TExceptionRegistrationRecord;
  4292. TargetIP: pointer;
  4293. var RepRec: TExceptionReportRecord): cardinal; cdecl;
  4294. external 'DOSCALLS' index 357;
  4295. function DosSetSignalExceptionFocus(Enable:longint;var Times:longint):cardinal;
  4296. cdecl;
  4297. external 'DOSCALLS' index 378;
  4298. function DosSetSignalExceptionFocus (Enable: cardinal;
  4299. var Times: cardinal): cardinal; cdecl;
  4300. external 'DOSCALLS' index 378;
  4301. function DosSetSignalExceptionFocus (Enable: boolean;
  4302. var Times: cardinal): cardinal;
  4303. begin
  4304. DosSetSignalExceptionFocus :=
  4305. DosSetSignalExceptionFocus (cardinal (Enable), Times);
  4306. end;
  4307. function DosEnterMustComplete(var Nesting:longint):cardinal; cdecl;
  4308. external 'DOSCALLS' index 380;
  4309. function DosEnterMustComplete (var Nesting: cardinal): cardinal; cdecl;
  4310. external 'DOSCALLS' index 380;
  4311. function DosExitMustComplete(var Nesting:longint):cardinal; cdecl;
  4312. external 'DOSCALLS' index 381;
  4313. function DosExitMustComplete (var Nesting: cardinal): cardinal; cdecl;
  4314. external 'DOSCALLS' index 381;
  4315. function DosAcknowledgeSignalException (SignalNum: cardinal): cardinal; cdecl;
  4316. external 'DOSCALLS' index 418;
  4317. function DosCloseQueue (Handle: THandle): cardinal; cdecl;
  4318. external 'QUECALLS' index 11;
  4319. function DosCreateQueue (var Handle: THandle; Priority: cardinal;
  4320. Name: PAnsiChar): cardinal; cdecl;
  4321. external 'QUECALLS' index 16;
  4322. function DosCreateQueue (var Handle: THandle; Priority: cardinal;
  4323. const Name: string): cardinal;
  4324. var T1:array[0..255] of AnsiChar;
  4325. begin
  4326. StrPCopy(@T1,Name);
  4327. DosCreateQueue:=DosCreateQueue(Handle,Priority,@T1);
  4328. end;
  4329. function DosOpenQueue(var Parent_PID:longint;var Handle:longint;
  4330. Name:PAnsiChar):cardinal; cdecl;
  4331. external 'QUECALLS' index 15;
  4332. function DosOpenQueue (var Parent_PID: cardinal; var Handle: THandle;
  4333. Name: PAnsiChar): cardinal; cdecl;
  4334. external 'QUECALLS' index 15;
  4335. function DosOpenQueue(var Parent_PID:longint;var Handle:longint;
  4336. const Name:string):cardinal;
  4337. var T1:array[0..255] of AnsiChar;
  4338. begin
  4339. StrPCopy(@T1,Name);
  4340. DosOpenQueue:=DosOpenQueue(Parent_PID,Handle,@T1);
  4341. end;
  4342. function DosOpenQueue (var Parent_PID: cardinal; var Handle: THandle;
  4343. const Name: string): cardinal;
  4344. var T1:array[0..255] of AnsiChar;
  4345. begin
  4346. StrPCopy(@T1,Name);
  4347. DosOpenQueue:=DosOpenQueue(Parent_PID,Handle,@T1);
  4348. end;
  4349. function DosPeekQueue(Handle:longint;var ReqBuffer:TRequestData;
  4350. var DataLen:longint;var DataPtr:pointer;
  4351. var Element:longint;Wait:longint;
  4352. var Priority:byte;ASem:longint):cardinal; cdecl;
  4353. external 'QUECALLS' index 13;
  4354. function DosPeekQueue (Handle: THandle; var ReqBuffer:TRequestData;
  4355. var DataLen: cardinal; var DataPtr: pointer;
  4356. var Element: cardinal; Wait: cardinal;
  4357. var Priority: byte; ASem: THandle): cardinal; cdecl;
  4358. external 'QUECALLS' index 13;
  4359. function DosPeekQueue (Handle: THandle; var ReqBuffer: TRequestData;
  4360. var DataLen: cardinal; var DataPtr: pointer;
  4361. var Element: cardinal; Wait: boolean;
  4362. var Priority: byte; ASem: THandle): cardinal;
  4363. begin
  4364. DosPeekQueue := DosPeekQueue (Handle, ReqBuffer, DataLen, DataPtr, Element,
  4365. cardinal (Wait), Priority, ASem);
  4366. end;
  4367. function DosPurgeQueue (Handle: THandle): cardinal; cdecl;
  4368. external 'QUECALLS' index 10;
  4369. function DosQueryQueue(Handle:longint;var Count:longint):cardinal; cdecl;
  4370. external 'QUECALLS' index 12;
  4371. function DosQueryQueue (Handle: THandle; var Count: cardinal): cardinal; cdecl;
  4372. external 'QUECALLS' index 12;
  4373. function DosReadQueue(Handle:longint;var ReqBuffer:TRequestData;
  4374. var DataLen:longint;var DataPtr:pointer;
  4375. Element,Wait:longint;var Priority:byte;
  4376. ASem:longint):cardinal; cdecl;
  4377. external 'QUECALLS' index 9;
  4378. function DosReadQueue (Handle: THandle; var ReqBuffer: TRequestData;
  4379. var DataLen: cardinal; var DataPtr: pointer;
  4380. Element, Wait: cardinal; var Priority: byte;
  4381. ASem: THandle): cardinal; cdecl;
  4382. external 'QUECALLS' index 9;
  4383. function DosReadQueue (Handle: THandle; var ReqBuffer: TRequestData;
  4384. var DataLen: cardinal; var DataPtr: pointer;
  4385. Element: cardinal; Wait: boolean; var Priority: byte;
  4386. ASem: THandle): cardinal;
  4387. begin
  4388. DosReadQueue := DosReadQueue (Handle, ReqBuffer, DataLen, DataPtr, Element,
  4389. cardinal (Wait), Priority, ASem);
  4390. end;
  4391. function DosWriteQueue (Handle: THandle; Request, DataLen: cardinal;
  4392. var DataBuf; Priority: cardinal): cardinal; cdecl;
  4393. external 'QUECALLS' index 14;
  4394. function DosError (Error: cardinal): cardinal; cdecl;
  4395. external 'DOSCALLS' index 212;
  4396. procedure DosErrClass(Code:longint;var _Class,Action,Locus:longint); cdecl;
  4397. external 'DOSCALLS' index 211;
  4398. procedure DosErrClass (Code: cardinal; var _Class, Action, Locus: cardinal);
  4399. cdecl;
  4400. external 'DOSCALLS' index 211;
  4401. function DosTrueGetMessage (MsgSeg: pointer; Table: PInsertTable;
  4402. TableSize: cardinal; Buf: PAnsiChar;
  4403. BufSize, MsgNumber: cardinal; FileName: PAnsiChar;
  4404. var MsgSize: cardinal): cardinal; cdecl;
  4405. external 'MSG' index 6;
  4406. function DosIQueryMessageCP (var Buf; BufSize: cardinal; FileName: PAnsiChar;
  4407. var InfoSize: cardinal; MesSeg: pointer): cardinal; cdecl;
  4408. external 'MSG' index 8;
  4409. procedure MagicHeaderEnd; assembler; forward;
  4410. {$ASMMODE INTEL}
  4411. {start of _MSGSEG32 segment}
  4412. procedure MagicHeaderStart; assembler;
  4413. asm
  4414. db $0FF
  4415. db $4D,$53,$47,$53,$45,$47,$33,$32, 0 //'MSGSEG32'
  4416. dd $8001
  4417. dd MAGICHEADEREND
  4418. end;
  4419. function DosGetMessage (Table: PInsertTable; TableSize: cardinal; Buf: PAnsiChar;
  4420. BufSize, MsgNumber: cardinal; FileName: PAnsiChar;
  4421. var MsgSize: cardinal): cardinal; cdecl; assembler;
  4422. nostackframe;
  4423. asm
  4424. pop eax
  4425. push offset MagicHeaderStart
  4426. push eax
  4427. jmp DosTrueGetMessage
  4428. end;
  4429. function DosGetMessage (Table: PInsertTable; TableSize:longint;Buf:PAnsiChar;
  4430. BufSize,MsgNumber:longint;FileName:PAnsiChar;
  4431. var MsgSize:longint):cardinal;
  4432. begin
  4433. DosGetMessage := DosGetMessage (Table, cardinal (TableSize), Buf,
  4434. cardinal (BufSize), cardinal (MsgNumber), FileName, cardinal (MsgSize));
  4435. end;
  4436. function DosQueryMessageCP (var Buf; BufSize: cardinal; FileName: PAnsiChar;
  4437. var InfoSize: cardinal): cardinal;
  4438. begin
  4439. DosQueryMessageCP := DosIQueryMessageCP(Buf, BufSize, FileName, InfoSize,
  4440. @MagicHeaderStart);
  4441. end;
  4442. function DosQueryMessageCP(var Buf;BufSize:longint;FileName:PAnsiChar;
  4443. var InfoSize:longint):cardinal;
  4444. begin
  4445. DosQueryMessageCP := DosIQueryMessageCP(Buf, cardinal (BufSize), FileName,
  4446. cardinal (InfoSize), @MagicHeaderStart);
  4447. end;
  4448. procedure MagicHeaderEnd; assembler;
  4449. asm
  4450. dd $0FFFF0000
  4451. end;
  4452. {$ASMMODE DEFAULT}
  4453. (*function DosGetMessage(const Table:array of PString;var Buf:openstring;
  4454. MsgNumber:longint;const FileName:string):cardinal;
  4455. {Hmm. This takes too much stackspace. Let's use the
  4456. heap instead.}
  4457. type TTableBuffer=record
  4458. IT:TinsertTable;
  4459. Strings:TByteArray;
  4460. end;
  4461. PTableBuffer=^TTableBuffer;
  4462. var Buffer:PTableBuffer;
  4463. I,S:word;
  4464. BufPtr:pointer;
  4465. T1,T2:array[0..255] of AnsiChar;
  4466. begin
  4467. {Check if there are more than nine items in the table.}
  4468. if High(Table)>8 then
  4469. DosGetMessage:=87
  4470. else
  4471. begin
  4472. {Step 1: Calculate the space we need on the heap.}
  4473. S:=SizeOf(TInsertTable);
  4474. for I:=Low(Table) to High(Table) do
  4475. S:=S+Length(Table[I])+1;
  4476. {Step 2: Allocate the buffer.}
  4477. GetMem(Buffer,S);
  4478. {Step 3: Fill the buffer.}
  4479. BufPtr:=@(S^.Strings);
  4480. for I:=Low(Table) to High(Table) do
  4481. begin
  4482. S^.IT[I+1]:=bufptr;
  4483. StrPCopy(BufPtr,Table[I]);
  4484. Inc(longint(BufPtr),Length(Table[I])+1);
  4485. end;
  4486. {Step 4: Convert the filename.}
  4487. StrPCopy(@T2,FileName);
  4488. {Step 5: Get the message.}
  4489. DosGetMessage:=DosGetMessage(@(S^.IT),High(Table)+1,@T1,
  4490. High(Buf),MsgNumber,@T2,I);
  4491. {Step 6: Convert the returned message.}
  4492. Buf[0]:=AnsiChar(I);
  4493. Move(T1,Buf[1],I);
  4494. {Step 7: Free the memory.}
  4495. FreeMem(Buffer,S);
  4496. end;
  4497. end;*)
  4498. {function DosGetMessage(const Table:array of PString;Buf:PAnsiChar;
  4499. BufSize,MsgNumber:longint;const FileName:string;
  4500. MsgSize:longint):cardinal;}
  4501. function DosQueryMessageCP(var Buf;BufSize:longint;const FileName:string;
  4502. var InfoSize:longint):cardinal;
  4503. var T:array[0..255] of AnsiChar;
  4504. begin
  4505. StrPCopy(@T,FileName);
  4506. DosQueryMessageCP:=DosQueryMessageCP(Buf,BufSize,@T,InfoSize);
  4507. end;
  4508. function DosQueryMessageCP (var Buf; BufSize: cardinal; const FileName: string;
  4509. var InfoSize: cardinal): cardinal;
  4510. var T:array[0..255] of AnsiChar;
  4511. begin
  4512. StrPCopy(@T,FileName);
  4513. DosQueryMessageCP:=DosQueryMessageCP(Buf,BufSize,@T,InfoSize);
  4514. end;
  4515. function DosInsertMessage(Table:PInsertTable;TableSize:longint;
  4516. Message:PAnsiChar;SrcMessageSize:longint;
  4517. Buf:PAnsiChar;BufSize:longint;
  4518. var DstMessageSize:longint):cardinal; cdecl;
  4519. external 'MSG' index 4;
  4520. function DosInsertMessage (Table: PInsertTable; TableSize: cardinal;
  4521. Message: PAnsiChar; SrcMessageSize: cardinal;
  4522. Buf: PAnsiChar; BufSize: cardinal;
  4523. var DstMessageSize: cardinal): cardinal; cdecl;
  4524. external 'MSG' index 4;
  4525. {function DosInsertMessage(Table:array of PString;
  4526. const Message:string;
  4527. var Buf:openstring):cardinal;
  4528. function DosInsertMessage(Table:array of PString;
  4529. Message:PAnsiChar;SrcMessageSize:longint;
  4530. Buf:PAnsiChar;BufSize:longint;
  4531. var DstMessageSize:longint):cardinal;}
  4532. function DosPutMessage (Handle: THandle; Size: cardinal; Buf: PAnsiChar): cardinal;
  4533. cdecl;
  4534. external 'MSG' index 5;
  4535. function DosPutMessage (Handle: THandle; const Buf: string): cardinal;
  4536. begin
  4537. DosPutMessage:=DosPutMessage(Handle,Length(Buf),@Buf[1]);
  4538. end;
  4539. function DosStartSession (var AStartData:TStartData;
  4540. var SesID,PID:longint):cardinal; cdecl;
  4541. external 'SESMGR' index 37;
  4542. function DosStartSession (var AStartData: TStartData;
  4543. var SesID, PID: cardinal): cardinal; cdecl;
  4544. external 'SESMGR' index 37;
  4545. function DosSetSession (SesID: cardinal; var AStatus: TStatusData): cardinal;
  4546. cdecl;
  4547. external 'SESMGR' index 39;
  4548. function DosSelectSession (SesID: cardinal): cardinal; cdecl;
  4549. external 'SESMGR' index 38;
  4550. function DosStopSession (Scope, SesID: cardinal): cardinal; cdecl;
  4551. external 'SESMGR' index 40;
  4552. function DosCreatePipe (var ReadHandle, WriteHandle: THandle;
  4553. Size: cardinal): cardinal; cdecl;
  4554. external 'DOSCALLS' index 239;
  4555. function DosCreateNPipe (Name: PAnsiChar; var Handle: THandle; OpenMode, PipeMode,
  4556. OutBufSize, InBufSize, MSec: cardinal): cardinal; cdecl;
  4557. external 'DOSCALLS' index 243;
  4558. function DosCreateNPipe (const Name: string; var Handle: THandle; OpenMode,
  4559. PipeMode, OutBufSize, InBufSize, MSec: cardinal): cardinal;
  4560. var T:array[0..255] of AnsiChar;
  4561. begin
  4562. StrPCopy(@T,Name);
  4563. DosCreateNPipe:=DosCreateNPipe(@T,Handle,OpenMode,PipeMode,OutBufSize,
  4564. InBufSize,MSec);
  4565. end;
  4566. function DosCallNPipe(Name:PAnsiChar;var Input;InputSize:longint;
  4567. var Output;OutputSize:longint;var ReadBytes:longint;
  4568. MSec:longint):cardinal; cdecl;
  4569. external 'DOSCALLS' index 240;
  4570. function DosCallNPipe (Name: PAnsiChar; var Input; InputSize: cardinal;
  4571. var Output; OutputSize: cardinal;
  4572. var ReadBytes: cardinal; MSec: cardinal): cardinal;
  4573. cdecl;
  4574. external 'DOSCALLS' index 240;
  4575. function DosCallNPipe(const Name:string;var Input;InputSize:longint;
  4576. var Output;OutputSize:longint;var ReadBytes:longint;
  4577. MSec:longint):cardinal;
  4578. var T:array[0..255] of AnsiChar;
  4579. begin
  4580. StrPCopy(@T,Name);
  4581. DosCallNPipe:=DosCallNPipe(@T,Input,InputSize,Output,OutputSize,
  4582. ReadBytes,MSec);
  4583. end;
  4584. function DosCallNPipe (const Name: string; var Input; InputSize: cardinal;
  4585. var Output; OutputSize: cardinal;
  4586. var ReadBytes: cardinal; MSec: cardinal): cardinal;
  4587. var T:array[0..255] of AnsiChar;
  4588. begin
  4589. StrPCopy(@T,Name);
  4590. DosCallNPipe:=DosCallNPipe(@T,Input,InputSize,Output,OutputSize,
  4591. ReadBytes,MSec);
  4592. end;
  4593. function DosConnectNPipe (Handle: THandle): cardinal; cdecl;
  4594. external 'DOSCALLS' index 241;
  4595. function DosDisconnectNPipe (Handle: THandle): cardinal; cdecl;
  4596. external 'DOSCALLS' index 242;
  4597. function DosPeekNPipe(Handle:longint;var Buffer;BufSize:longint;
  4598. var ReadBytes:longint;var Avail:TAvailData;
  4599. var State:longint):cardinal; cdecl;
  4600. external 'DOSCALLS' index 244;
  4601. function DosPeekNPipe (Handle: THandle; var Buffer; BufSize: cardinal;
  4602. var ReadBytes: cardinal; var Avail: TAvailData;
  4603. var State: cardinal): cardinal; cdecl;
  4604. external 'DOSCALLS' index 244;
  4605. function DosQueryNPHState(Handle:longint;var State:longint):cardinal; cdecl;
  4606. external 'DOSCALLS' index 245;
  4607. function DosQueryNPHState (Handle: THandle; var State: cardinal): cardinal;
  4608. cdecl;
  4609. external 'DOSCALLS' index 245;
  4610. function DosQueryNPipeInfo (Handle: THandle; InfoLevel: cardinal; var Buffer;
  4611. BufSize: cardinal): cardinal; cdecl;
  4612. external 'DOSCALLS' index 248;
  4613. function DosQueryNPipeSemState (SemHandle: THandle; var SemArray;
  4614. BufSize: cardinal): cardinal; cdecl;
  4615. external 'DOSCALLS' index 249;
  4616. function DosQueryNPipeSemState (SemHandle: THandle; SemArray: PPipeSemState;
  4617. BufSize: cardinal): cardinal; cdecl;
  4618. external 'DOSCALLS' index 249;
  4619. function DosSetNPHState (Handle: THandle; State: cardinal):cardinal; cdecl;
  4620. external 'DOSCALLS' index 250;
  4621. function DosSetNPipeSem(PipeHandle,SemHandle: THandle; Key: cardinal):
  4622. cardinal; cdecl;
  4623. external 'DOSCALLS' index 251;
  4624. function DosTransactNPipe(Handle:longint;var OutBuf;OutSize:longint;
  4625. var InBuf;InSize:longint;
  4626. var ReadBytes:longint):cardinal; cdecl;
  4627. external 'DOSCALLS' index 252;
  4628. function DosTransactNPipe (Handle: THandle; var OutBuf; OutSize: cardinal;
  4629. var InBuf; InSize: cardinal;
  4630. var ReadBytes: cardinal): cardinal; cdecl;
  4631. external 'DOSCALLS' index 252;
  4632. function DosWaitNPipe (Name: PAnsiChar; MSec: cardinal): cardinal; cdecl;
  4633. external 'DOSCALLS' index 253;
  4634. function DosWaitNPipe (const Name: string; MSec: cardinal): cardinal;
  4635. var T:array[0..255] of AnsiChar;
  4636. begin
  4637. StrPCopy(@T,Name);
  4638. DosWaitNPipe:=DosWaitNPipe(@T,MSec);
  4639. end;
  4640. function DosOpenVDD (Name: PAnsiChar; var Handle: THandle): cardinal; cdecl;
  4641. external 'DOSCALLS' index 308;
  4642. function DosRequestVDD (Handle: THandle; SGroup, Cmd: cardinal;
  4643. InSize: cardinal; var InBuffer;
  4644. OutSize: cardinal; var OutBuffer): cardinal; cdecl;
  4645. external 'DOSCALLS' index 309;
  4646. function DosCloseVDD (Handle: THandle): cardinal; cdecl;
  4647. external 'DOSCALLS' index 310;
  4648. procedure DosSelToFlat; cdecl;
  4649. external 'DOSCALLS' index 426;
  4650. procedure DosFlatToSel; cdecl;
  4651. external 'DOSCALLS' index 425;
  4652. {$ASMMODE INTEL}
  4653. function SelToFlat (AFarPtr: cardinal): pointer; assembler;
  4654. asm
  4655. push ebx
  4656. push esi
  4657. push edi
  4658. {$IFNDEF REGCALL}
  4659. mov eax, AFarPtr
  4660. {$ENDIF REGCALL}
  4661. call DosSelToFlat
  4662. pop edi
  4663. pop esi
  4664. pop ebx
  4665. end;
  4666. function SelToFlat (AFarPtr: TFarPtr): pointer; assembler;
  4667. asm
  4668. push ebx
  4669. push esi
  4670. push edi
  4671. mov eax, AFarPtr
  4672. call DosSelToFlat
  4673. pop edi
  4674. pop esi
  4675. pop ebx
  4676. end;
  4677. function FlatToSel (APtr: pointer): cardinal; assembler;
  4678. asm
  4679. push ebx
  4680. push esi
  4681. push edi
  4682. {$IFNDEF REGCALL}
  4683. mov eax, APtr
  4684. {$ENDIF REGCALL}
  4685. call DosFlatToSel
  4686. pop edi
  4687. pop esi
  4688. pop ebx
  4689. end;
  4690. function DosAllocThreadLocalMemory (Count: cardinal; var P: pointer): cardinal;
  4691. cdecl;
  4692. external 'DOSCALLS' index 454;
  4693. function DosFreeThreadLocalMemory (P: pointer): cardinal; cdecl;
  4694. external 'DOSCALLS' index 455;
  4695. function DosQueryRASInfo (Index: cardinal; var PBuffer: pointer): cardinal;
  4696. cdecl; external 'DOSCALLS' index 112;
  4697. function LogOpen (var Handle: cardinal): cardinal; cdecl;
  4698. external 'DOSCALLS' index 430;
  4699. function LogClose (Handle: cardinal): cardinal; cdecl;
  4700. external 'DOSCALLS' index 431;
  4701. function LogAddEntries (Handle: cardinal; Service: cardinal;
  4702. LogEntries: PLogEntryRec): cardinal; cdecl; external 'DOSCALLS' index 432;
  4703. function LogAddEntries (Handle: cardinal; Service: cardinal;
  4704. var LogEntries: TLogEntryRec): cardinal; cdecl; external 'DOSCALLS' index 432;
  4705. function DosQueryMemState (PMem: pointer; var Size: cardinal;
  4706. var State: cardinal): cardinal; cdecl;
  4707. external 'DOSCALLS' index 307;
  4708. (* Todo:
  4709. function DosRawReadNPipe (HPIPE hPipe,
  4710. PVOID pBuffer,
  4711. ULONG cbRead,
  4712. PULONG pcbActual); cdecl;
  4713. external 'DOSCALLS' index 246; - no documentation???
  4714. function DosRawWriteNPipe (HPIPE hPipe,
  4715. PVOID pBuffer,
  4716. ULONG cbWrite,
  4717. PULONG pcbActual); cdecl;
  4718. external 'DOSCALLS' index 247; - no documentation???
  4719. function DosSetCP ...; cdecl;
  4720. external 'DOSCALLS' index 288; - no documentation???
  4721. function DosDynamicTrace ...; cdecl;
  4722. external 'DOSCALLS' index 316; - no documentation???
  4723. function DosRegisterPerfCtrs (PBYTE pbDataBlk,
  4724. PBYTE pbTextBlk,
  4725. ULONG flFlags); cdecl;
  4726. external 'DOSCALLS' index 367; - no documentation???
  4727. function DosQueryDOSProperty (SGID sgid,
  4728. PSZ pszName,
  4729. ULONG cb,
  4730. PSZ pch); cdecl;
  4731. external 'DOSCALLS' index 373; - no documentation???
  4732. function DosSetDOSProperty (SGID sgid,
  4733. PSZ pszName,
  4734. ULONG cb,
  4735. PSZ pch); cdecl;
  4736. external 'DOSCALLS' index 374; - no documentation???
  4737. function DosProfile ...; cdecl;
  4738. external 'DOSCALLS' index 377; - no documentation???
  4739. *)
  4740. function DosReplaceModule (OldModule, NewModule, BackupModule: PAnsiChar):
  4741. cardinal; cdecl;
  4742. external 'DOSCALLS' index 417;
  4743. (*
  4744. ??? function DosTIB ...; cdecl;
  4745. external 'DOSCALLS' index 419;
  4746. ??? function DosOpenChangeNotify ...; cdecl;
  4747. external 'DOSCALLS' index 440;
  4748. ??? function DosResetChangeNotify ...; cdecl;
  4749. external 'DOSCALLS' index 441;
  4750. ??? function DosCloseChangeNotify ...; cdecl;
  4751. external 'DOSCALLS' index 442;
  4752. ??? function DosInitializePorthole ...; cdecl;
  4753. external 'DOSCALLS' index 580;
  4754. ??? function DosQueryHeaderInfo ...; cdecl;
  4755. external 'DOSCALLS' index 582;
  4756. DosCreateThread2 2.45
  4757. DosDumpProcess 2.10
  4758. DosForceSystemDump - ???
  4759. ??? function DosQueryPageUsage (...): cardinal; cdecl;
  4760. external 'DOSCALLS' index 358;
  4761. DosPerfSystemCall 2.40
  4762. functionDosGetProcessorStatus (...): cardinal; cdecl;
  4763. external 'DOSCALLS' index 447;
  4764. DosSetProcessorStatus = DOSCALLS.448
  4765. type
  4766. TSpinLock = cardinal;
  4767. HSpinLock = TSpinLock;
  4768. PSpinLock = ^TSpinLock;
  4769. PHSpinLock = PSpinLock;
  4770. function DosCreateSpinLock (var SpinLock: TSpinLock): cardinal; cdecl;
  4771. procedure DosAcquireSpinLock (SpinLock: TSpinLock); cdecl;
  4772. procedure DosReleaseSpinLock (SpinLock: TSpinLock); cdecl;
  4773. function DosFreeSpinLock (SpinLock: TSpinLock): cardinal; cdecl;
  4774. DosCreateSpinLock = DOSCALLS.449
  4775. DosAcquireSpinLock = DOSCALLS.450
  4776. DosReleaseSpinLock = DOSCALLS.451
  4777. DosFreeSpinLock = DOSCALLS.452
  4778. DosListIO 2.45
  4779. DosListIOL 2.45
  4780. DosQueryABIOSSuport 2.10
  4781. ___ functionDos16QueryModFromCS (...): ...
  4782. external 'DOSCALLS' index 359;
  4783. DosQueryModFromEIP 2.10
  4784. *)
  4785. function DosQuerySysState (EntityList, EntityLevel, PID, TID: cardinal;
  4786. var Buffer; BufLen: cardinal): cardinal; cdecl;
  4787. external 'DOSCALLS' index 368;
  4788. function DosQuerySysState (EntityList, EntityLevel, PID, TID: cardinal;
  4789. PDataBuf: pointer; cbBuf: cardinal): cardinal; cdecl;
  4790. external 'DOSCALLS' index 368;
  4791. function DosAliasMem (pMem: pointer; Size: cardinal; var Alias: pointer;
  4792. Flags: cardinal): cardinal; cdecl;
  4793. external 'DOSCALLS' index 298;
  4794. (*
  4795. DosQueryThreadAffinity
  4796. DosSetThreadAffinity
  4797. Dos16SysTrace
  4798. DosVerifyPidTid 2.30
  4799. *)
  4800. end.