[comp.windows.ms] How to start up Windows with an application ?

heath@ncrcae.Columbia.NCR.COM (Robert Heath) (12/05/89)

I recently got a copy of Excel. I noticed that when one starts Excel from
DOS, it automatically starts up Windows.  Any of the Win Apps I generate with
the SDK always complain that they need to run under Windows when started up
from DOS, then they exit.  How does one make a Win App that automatically 
kicks off Windows ?

	Thanks.
	Robert Heath

rogerson@PEDEV.Columbia.NCR.COM (Dale Rogerson) (12/06/89)

In article <5443@ncrcae.Columbia.NCR.COM> heath@ncrcae.Columbia.NCR.COM (Robert Heath) writes:
>I recently got a copy of Excel. I noticed that when one starts Excel from
>DOS, it automatically starts up Windows.  Any of the Win Apps I generate with
>the SDK always complain that they need to run under Windows when started up
>from DOS, then they exit.  How does one make a Win App that automatically 
>kicks off Windows ?

If you examine the DEF file for most Windows programs you will see a line like:
	STUB 'WINSTUB.EXE'.
This line tells the linker to add the program WINSTUB.EXE to the beginning of
the old-EXE file header.  Since DOS only knows about the old style EXE header
this program will be run.  In the case of WINSTUB.EXE it just displays the
message telling you that you must load Windows first.  If you want to have
Windows automatically started you will need to replace WINSTUB.EXE with your
own stub program which would start Windows for you.

For those you might be interested, programs which run under both OS/2 and DOS
use the same idea with the STUB program being the DOS version.

Hope this helps.

-----Dale
	Rogerson----

patrickd@chinet.chi.il.us (Patrick Deupree) (12/06/89)

In article <5443@ncrcae.Columbia.NCR.COM> heath@ncrcae.Columbia.NCR.COM (Robert Heath) writes:
>I recently got a copy of Excel. I noticed that when one starts Excel from
>DOS, it automatically starts up Windows.  Any of the Win Apps I generate with
>the SDK always complain that they need to run under Windows when started up
>from DOS, then they exit.  How does one make a Win App that automatically 
>kicks off Windows ?

Again, I insert my disclaimer that says I know nothing about how the Microsoft
guys do these things.  I'm guessing at all of this with my somewhat limited
knowledge of low level Windows.

Seeing as the part of your program that says "You need Windows to run this app"
is the winstub file that is linked in with Windows programs when you create
them, I'd imagine they modified theirs.  If Windows is in the path (which it
always should be) they probably just called a dos interrupt that runs Windows
automatically instead of printing out the line that says "You need Windows to
run this" (I'm ad libbing this line since I forget what it was at this moment).

Overall it's probably pretty simple to implement.  Just a little dangerous
since, if you don't have Windows, the only message you'll probably get is
a dos "file not found" error.
-- 
"I place my faith in fools.  Self confidence, my friends call it."
					-Edgar Allen Poe

Patrick Deupree -> patrickd@chinet.chi.il.us

bturner@hpcvlx.cv.hp.com (Bill Turner) (12/07/89)

> If you examine the DEF file for most Windows programs you will see a line like:
> 	STUB 'WINSTUB.EXE'.
> This line tells the linker to add the program WINSTUB.EXE to the beginning of
> the old-EXE file header.  Since DOS only knows about the old style EXE header
> this program will be run.  In the case of WINSTUB.EXE it just displays the
> message telling you that you must load Windows first.  If you want to have
> Windows automatically started you will need to replace WINSTUB.EXE with your
> own stub program which would start Windows for you.

I have written such a critter, and am willing to share it.  Unfortunately, I
can't seem to find the source for it, but I have the executable.  If there's
enough interest, I can post it; otherwise drop me a line.

(The program was simply a call to exec with argv[0] as the program name.  At
least that's what my memory seems to recall....)

--Bill Turner (bturner@hp-pcd.hp.com)
HP Corvallis Information Systems