Hi all! I have just discovered this very nice website... Thank you all for all the "tips and tricks" posted! I just wanted to ask a little question... I'm writing a program in DOS, it's like a protocol sniffer for the serial port.. But i have a problem, since DOS can open up to 15 files at a time, and it always show an error, but there shouldn't be errors because I know what opens and what closes... Well, it's a bit tricky to explain... Basically, I need to write another external program that shows me all the files actually open in the system, and what program is accessing them... Is it possible to do this in C? I searched everywhere, but I only found some strange ASM code, and it doesn't work.... Can someone help me please?
Thank you very much!!
Gip

Dani AI

Generated

— first question is environment. As pointed out, true MS‑DOS is not a multitasking OS, so there are no independent processes to query the way a modern OS provides. That does not mean it is impossible to track opens on a real DOS machine, but the available techniques and the semantics of “which program opened it” are different.

On a bare MS‑DOS system the usual approach is a small TSR that intercepts DOS file I/O (hook INT 21h) and logs create/open/close calls into a resident table. The TSR records the filename and the handle returned by DOS and removes the entry on close. Important cautions: chain to the original handler, guard against reentrancy and stack corruption, keep the resident image very small, and remember that identifying the owner program is only approximate — DOS has a single active PSP, so ownership must be inferred by recording the PSP or return context at the time of open.

If the DOS program runs under Windows (NTVDM / 9x DOS box) then the DOS session is just a Windows process. In that case use OS tools that enumerate kernel handles and show owning processes — for modern systems, Process Explorer or Handle from Sysinternals are the practical choice.

Diagnostic tips: distinguish a C‑library limit from a DOS/kernel limit by making minimal low‑level DOS opens and comparing failure points; check DOS configuration (many DOS versions expose a FILES= setting to raise the handle table) and read the C runtime docs for per‑process FILE* limits. For serial sniffing on real hardware, a TSR or a device/driver approach (hooking the serial ISR/BIOS int 14h) is generally more robust than opening lots of FILE streams.

If you are talking about true MS-DOS than it is not possible because MS-DOS is not a multi-tasking operating system. When your program runs there will be no other programs running on the computer.

If your computer is running any version of MS-Windows then you will not be running MS-DOS, but just an emulator which is itself just another MS-Windows program.

>>Basically, I need to write another external program that shows me all the files actually open in the system, and what program is accessing them...

As far as I know it is not possible to do that. The number of files that can be open at any one time is somewhere in the thousands under MS-Windows. The old MS-DOS limit of 15 files has been tossed to the wind several years ago.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.