The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
November 2001



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Windows Tasks, Trays, and Boots

Posted by Matt Gerrans on November 19, 2001 at 11:16 PM

Okay, I finally dredged up my old source code. Rather than send to an email with a big attachement, I put it all here:

I'll just leave it there for a day or two, so let me know when you've got it. Two of the three projects are built with Borland C++ Builder, so if you don't have it, you have a couple options: 1) Buy it (I think you can get a pretty good student discount and it is a great tool, well worth having), 2) just extract the relevevant code snippets and put it into whatever framework you are using.

You asked earlier in the thread about the API for rebooting machine; it is ExitWindowsEx(). A VB app that reboots, will just call the same thing in the VB way. It has options to control wether it is a reboot, shutdown, restart, etc. Under Windows 9x/Me, you can simply call it. Under NT/2k/XP, you have to jump through a bunch of hoops with security tokens and then you can call it. You'll see in the Rebooter code in MainForm.cpp that I've made a function that will handle both cases, so it should work on all flavors of Windows (or your money back!). You can either leave these programs intact and run them with exec(), or you can take the code and make a dll that can be accessed with JNI. By the way, run them with the parameter "/?" to see what command line options they support and be alert when you run ProcessKiller or Rebooter -- if you have programs with open, modified documents, you may regret it -- but don't panic, they both default to giving you plenty of time to cancel and show you a progress bar, so you can tell when they will do their thing.

I've seen the posts about making an exe for a Java program, but I haven't tried it. Since I am working on Linux and Windows, I like the platform indepence -- an exe only runs on Windows, so while I was mildly interested, looking into it is low priority. I haven't tried LimeWire, but I like that idea of a smart installer. I installed something (jikes, ant? I forget what it was) that came in a big class file which was a self-installer, but of course, I had to already have the JVM installed. Assuming you already have a JVM, it is pretty nice though. An installer that automatically goes and gets the JVM is even better, but then you have to make the stub for every platform. Maybe we can ask the LimeWire guys whether they came up with that themselves, or if someone (like maybe Wise installer) already packages that feature with their installer. Does LimeWire also do that same trick for Linux, Mac and other platforms?

- mfg

> Matt, would you mind sending me the C++ code for terminating non-essential program (and the utility you wrote) as well as TrayBien (see Windows System Tray) plse? The reason I want TrayBien is because I want to have my app sitting on the system tray and running in the background. Also, do you know how I can make my apps exe files? I know that there was a discussion about this and Chin provided some links, but they were all dealing with NT. I don't know if you've used LimeWire (a P2P sharing program), but that's built on Java, and yet it's an exe file (in fact, the setup program checks to see if Java is installed and if not, downloads it and installs it). Thnx!
> Hiran


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us