You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
I have a DOS program that shells to 32-bit programs.
Is there a way to see if it is running in MS/DOS mode
so it won't attempt to shell to any 32-bit apps.
Very close, but need to know if in MS/DOS mode so
program doesn't attempt to shell. May have to resort
to something funky like shelling to a 32-bit app and
setting a flag in the 32-bit app if it completes.
Don't really want to do this. Thought maybe an
environment variable would be different.
Is this program for your own use only? Or for use on PCs that you configure? If so, you could set an environment variable yourself, in the AUTOEXEC.BAT that is used when the system is booted in the MS-DOS mode.
It is a demo of a DOS program that might be run
from either DOS or Windows on many machines.
I'm going to try shelling to a 1 line PB/DLL program
that opens whatever is passed in COMMAND$. Then
the DOS program can delete the file if it exists and
know 32-bit Windows created it. Seems funky, but
all I need to know is if DOS is running.
I use this simple approach, and I've never had a report of a problem:
Code:
IF (ISTRUE LEN(ENVIRON$("winbootdir")) AND ISTRUE BIT(pbvHost,8)) OR _
UCASE$(ENVIRON$("OS")) = "WINDOWS_NT" THEN ' Only if 32-bit Windows is running
...
END IF
'Exactly what I needed.
'Note: "winbootdir" appears in MS/DOS mode in Win98.
'Made a slight modification and added the NT test.
'This will hopefully work in either basic.
IF LEN(ENVIRON$("windir")) > 0 OR UCASE$(ENVIRON$("OS")) = "WINDOWS_NT" THEN
Win32& = 1
END IF
Thanks much!
------------------
[This message has been edited by Mike Doty (edited October 11, 2001).]
Seems to work ok, Mike. Compiler shouldn't make any difference
to it anyway. Works in ME as well (mind you, it would, would'nt
it?)
Just checked a W95 machine. Typed SET in various locations.
As far as I can see, W95/98 only has "windir" in the environment
when Windows is actually running. It certainly isn't
there if you boot into DOS (BootGUI=0 in MSDOS.SYS),nor is it
there after restarting in DOS mode out of Windows. Incidentally,
if you also set Logo=0 in MSDOS.SYS then you get faster boot, and
an obscure M$ document for W95 stated that this improved
stability with aftermarket memory managers. I consider it
improves it even more with M$'s!
However, "winbootdir" is there in all of these cases. So it seems
that checking the environment for windir is safe for 95/ME.
I'll check 98 tomorrow, also NT4 & W2K just out of interest!
------------------
[This message has been edited by David J Walker (edited October 16, 2001).]
Ok, I remember where I originally derived winbootdir from:
In some of my older DOS app's I need to launch EDIT.COM, and in Win95+ machines, this is found in the \WINDOWS\COMMAND folder. Therefore, by using
Code:
IF LEN(ENVIRON$("winbootdir")) THEN _
SHELL ENVIRON$("winbootdir") + "\COMMAND\EDIT.COM"
So, if you just need to detect the Win9x GUI, then "windir" is the solution. If you need access to the Windows directory regardless of whether the GUI is active, use "winbootdir".
PS: You'll also note that I combined the PBVHOST check with "winbootdir" so the result of that combined AND test will produce the correct result since "winbootdir" is not present on Win16 systems.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment