You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by TO...@aol.com on 2000/06/28 09:42:40 UTC

Complete source for Apache MSVC/Borland IconBar APP

In a message dated 00-06-27 09:54:00 EDT, William Rowe writes...

> Actually looked at three things... the third being the IconBar app
>  issue... since I have some nearly pure code for it.  It was coded
>  for ATL 2.0, but that's a pretty 'simple' windowing system (compared
>  to MFC, which has always put more roadblocks in my way than actually
>  accelerating development :(

It gets even simpler than that. You don't need to bother with either
ATL or MFC to have a great IconBar App. In fact, there are many
reasons to definitely STAY AWAY from that stuff when it comes
to TRAY ICON apps.

See attached code. ( APTRAY1.ZIP only 46k )

It is a complete working IconBar App that is about as simple
and as flexible as it gets and it uses pure Win32 API only.

It is also a perfect example of how to code such an application
to compile with either MSVC or Borland, which gets real weird
if it started out as ATL or MSVC.

The attached IconBar APP is already coded to 'look' like an
Apache TRAY ICON program that can Start/Stop the Apache
Service and even has the right APACHE.ICO icon already.

It is only 53k including the Win32 Registry update code to
make it a permanent 'persistent' TRAY ICON.

It compiles/runs/installs as a persistent TRAY ICON using
all of the following ( Build files for all included... )
MSVC 5.x
MSVC 6.x
Borland 5.0
Borland 5.5 ( Free version of compiler that uses ilink32.exe ).

The info from the top of the attached TRAY1.C code also
reprinted at the bottom of this message.

>My concept of a taskbar is some simple way to enumerate all services
>installed vs. all services running.  Services installed is pretty
>straightforward, simply parsing strstr of the services key for all
>the Apache.exe string (don't care which directory, of course.)  And
>enumerating the Win9x running servers is easy as well, simply use
>FindWindow() with the service class and collect window names.  But
>enumerating running NT services will always be trouble.

No sweat ( See source code.. )

Just WinExec( "NET START > Services_running" )
and read the list.
NET START with no parms always list ALL Services 
that are currently running.

If the NET START command isn't available you can be sure
the Service probably isn't running due to an incomplete MS
Network support install.

I've never seen a Network enabled Win32 station that didn't
have the NET commands available anytime, anywhere, from
either command line or 'callable' with output 'redirectable'.

NET.EXE was DESIGNED to be used in this way
and even includes 'secret' commands to help reformat
and/or parse the data when called via WinExec().

It even works fine with a simple 'system()' call.

Yours...
Kevin Kiley
CTO, Remote Communications, Inc.
http://www.RemoteCommunications.cm
http://www.rctp.com - Online Internet Compression Server

Here is the info from the top of attached TRAY1.C...

// TRAY1 - Simple Win32 Tray ICON application

// This 'simple' program can act as a front-end for any Win32
// Service related application.

// It does NOT use ATL, MFC, or any of that other bloat.
// It is a clean-and-simple .C program that used the Win32 API
// to establish and maintain a Win9x/2000 or NT TRAY ICON.

// The final TOTAL size of the .EXE is only around 53k.
// If MFC or ATL were used the .EXE would be MUCH, MUCH larger
// and more complicated.

// This particular instance of the code has been made to 'look'
// like a demo front-end for the Win32 version of the Apache
// Web Server 'Service'. The TRAY ICON itself will appear as a
// small 'feather' which is simply the standard APACHE.ICON icon
// from ..\SRC\OS\WIN32\APACHE.ICO

// The menu options simply say...

// 1. Show  the Apache Web Server Control Panel
// 2. Start the Apache Web Server
// 3. Stop  the Apache Web Server

// The TRAY related calls and globals are all prefixed with
// 'ap_tray1_xxxxx()' so they don't conflict with any
// non-Apache routines.

// To BUILD this demo just use the .BAT files.
// There are no makefiles or project files.
// They are not necessary for such a simple program.

// MKMSVC5.BAT <- Rebuild TRAY1.EXE manually using MSVC 5.x
// MKMSVC6.BAT <- Rebuild TRAY1.EXE manually using MSVC 6.x
// MKBOR50.BAT <- Rebuild TRAY1.EXE manually using Borland 5.0 (tlink32)
// MKBOR55.BAT <- Rebuild TRAY1.EXE manually using Borland 5.5 (ilink32)

// The program also shows the proper way to use _argc and _argv[]
// command line argument info in WinMain() and make it generic to
// both MSVC and Borland.

// MSVC adds extra underscores to command line arguments
// visible to WinMain() so just re-map to Borland equivalents
// like this...

// #ifndef __BORLANDC__
// #define _argc __argc
// #define _argv __argv
// #endif

// See the start of WinMain() for more details...

// There is no copyright of any kind. It's just a demo.

// Original author: Kevin Kiley, 1998

RE: Complete source for Apache MSVC/Borland IconBar APP

Posted by "William A. Rowe, Jr." <wr...@lnd.com>.
Kevin,

Ok... I didn't even crack it open yet, but I'm -1 on just one point.
The call to EnumServicesStatus is too simple to ignore, I'm 100% against 
spawning a proc from the taskbar every n seconds.  I do promise to crack 
it open and give the app a proper review (probably not till Friday a.m.)
If that's the only weakness, then I can be easily converted :)

Speaking of it being borland-ready, take a look at my patch for NT event
logging of this evening... that one bit of stdio crud is probably MSVC
specific, if you care to pass on a fix for Borland (or simply make it
generic, but I don't think you can do so and keep it as immediate-commit
at the same time.)  The MS clib looks at stdxxx and decides they are not
a tty, you are then screwed.  I needed the fdopen to force the mode back
to unbuffered.

My point to the new arg to EnumServicesStatusEx is that we can enumerate
only the 5 installed or 2 running apache servers instead of the 50 total
installed or 29 running services in the system.  Since NET START is simply
an app around that call, it's still a Win2000 optimization, and one that
could easily wait till 2.0 releases.

(oh, the ATL app I described was recoded in raw API, my point was that it
is easier to do that from ATL than from MFC :)  I mentioned pure code,
but that's for my scripting widget.  If you've gone to the trouble, I have
plenty of other things at hand.

b.t.w., note from Ozgar -finally- helped me see the light, should have
the def files all set as well.  And I'm not against distributing the
.mak files with a .bcc.mak suffix or some such, so we should be able to
stay away from extra biniaries in the build.

> -----Original Message-----
> From: TOKILEY@aol.com [mailto:TOKILEY@aol.com]
> Sent: Wednesday, June 28, 2000 2:43 AM
> To: new-httpd@apache.org
> Subject: Complete source for Apache MSVC/Borland IconBar APP
> 
> 
> 
> In a message dated 00-06-27 09:54:00 EDT, William Rowe writes...
> 
> > Actually looked at three things... the third being the IconBar app
> >  issue... since I have some nearly pure code for it.  It was coded
> >  for ATL 2.0, but that's a pretty 'simple' windowing system 
> (compared
> >  to MFC, which has always put more roadblocks in my way 
> than actually
> >  accelerating development :(
> 
> It gets even simpler than that. You don't need to bother with either
> ATL or MFC to have a great IconBar App. In fact, there are many
> reasons to definitely STAY AWAY from that stuff when it comes
> to TRAY ICON apps.
> 
> See attached code. ( APTRAY1.ZIP only 46k )
> 
> It is a complete working IconBar App that is about as simple
> and as flexible as it gets and it uses pure Win32 API only.
> 
> It is also a perfect example of how to code such an application
> to compile with either MSVC or Borland, which gets real weird
> if it started out as ATL or MSVC.
> 
> The attached IconBar APP is already coded to 'look' like an
> Apache TRAY ICON program that can Start/Stop the Apache
> Service and even has the right APACHE.ICO icon already.
> 
> It is only 53k including the Win32 Registry update code to
> make it a permanent 'persistent' TRAY ICON.
> 
> It compiles/runs/installs as a persistent TRAY ICON using
> all of the following ( Build files for all included... )
> MSVC 5.x
> MSVC 6.x
> Borland 5.0
> Borland 5.5 ( Free version of compiler that uses ilink32.exe ).
> 
> The info from the top of the attached TRAY1.C code also
> reprinted at the bottom of this message.
> 
> >My concept of a taskbar is some simple way to enumerate all services
> >installed vs. all services running.  Services installed is pretty
> >straightforward, simply parsing strstr of the services key for all
> >the Apache.exe string (don't care which directory, of course.)  And
> >enumerating the Win9x running servers is easy as well, simply use
> >FindWindow() with the service class and collect window names.  But
> >enumerating running NT services will always be trouble.
> 
> No sweat ( See source code.. )
> 
> Just WinExec( "NET START > Services_running" )
> and read the list.
> NET START with no parms always list ALL Services 
> that are currently running.
> 
> If the NET START command isn't available you can be sure
> the Service probably isn't running due to an incomplete MS
> Network support install.
> 
> I've never seen a Network enabled Win32 station that didn't
> have the NET commands available anytime, anywhere, from
> either command line or 'callable' with output 'redirectable'.
> 
> NET.EXE was DESIGNED to be used in this way
> and even includes 'secret' commands to help reformat
> and/or parse the data when called via WinExec().
> 
> It even works fine with a simple 'system()' call.
> 
> Yours...
> Kevin Kiley
> CTO, Remote Communications, Inc.
> http://www.RemoteCommunications.cm
> http://www.rctp.com - Online Internet Compression Server
> 
> Here is the info from the top of attached TRAY1.C...
> 
> // TRAY1 - Simple Win32 Tray ICON application
> 
> // This 'simple' program can act as a front-end for any Win32
> // Service related application.
> 
> // It does NOT use ATL, MFC, or any of that other bloat.
> // It is a clean-and-simple .C program that used the Win32 API
> // to establish and maintain a Win9x/2000 or NT TRAY ICON.
> 
> // The final TOTAL size of the .EXE is only around 53k.
> // If MFC or ATL were used the .EXE would be MUCH, MUCH larger
> // and more complicated.
> 
> // This particular instance of the code has been made to 'look'
> // like a demo front-end for the Win32 version of the Apache
> // Web Server 'Service'. The TRAY ICON itself will appear as a
> // small 'feather' which is simply the standard APACHE.ICON icon
> // from ..\SRC\OS\WIN32\APACHE.ICO
> 
> // The menu options simply say...
> 
> // 1. Show  the Apache Web Server Control Panel
> // 2. Start the Apache Web Server
> // 3. Stop  the Apache Web Server
> 
> // The TRAY related calls and globals are all prefixed with
> // 'ap_tray1_xxxxx()' so they don't conflict with any
> // non-Apache routines.
> 
> // To BUILD this demo just use the .BAT files.
> // There are no makefiles or project files.
> // They are not necessary for such a simple program.
> 
> // MKMSVC5.BAT <- Rebuild TRAY1.EXE manually using MSVC 5.x
> // MKMSVC6.BAT <- Rebuild TRAY1.EXE manually using MSVC 6.x
> // MKBOR50.BAT <- Rebuild TRAY1.EXE manually using Borland 
> 5.0 (tlink32)
> // MKBOR55.BAT <- Rebuild TRAY1.EXE manually using Borland 
> 5.5 (ilink32)
> 
> // The program also shows the proper way to use _argc and _argv[]
> // command line argument info in WinMain() and make it generic to
> // both MSVC and Borland.
> 
> // MSVC adds extra underscores to command line arguments
> // visible to WinMain() so just re-map to Borland equivalents
> // like this...
> 
> // #ifndef __BORLANDC__
> // #define _argc __argc
> // #define _argv __argv
> // #endif
> 
> // See the start of WinMain() for more details...
> 
> // There is no copyright of any kind. It's just a demo.
> 
> // Original author: Kevin Kiley, 1998
>