mark.shepard.org
>
code
>
Win32.CreateShellLink() example source-code in C
Name Last modified Size Description
files.md5 23-Oct-1999 17:58 1k
makefile 23-Oct-1999 03:40 1k
setenv.bat 23-Oct-1999 16:35 1k
setup.bat 23-Oct-1999 16:40 1k
shlink.c 23-Oct-1999 03:38 5k
README for shlink.
LICENSE:
shlink is hereby placed in the public domain.
This program comes with ABSOLUTELY NO WARRANTY, EXPRESSED OR IMPLIED.
USE AT YOUR OWN RISK.
----------------------------------------------------------------------------
Documentation:
> These raises two issues someone here might be able to help with:
>
> 1) What does it take to make a .pif work on NT? If the answer is
> "nothing", why might these pifs not be working.
I haven't seen this documented anywhere, but it appears that when
NT sees a .pif file it assumes it's dealing with a 16-bit DOS
program and hands it off to the ntvdm DOS emulator. On my NT
system, launching e.pif results in the emulated DOS reporting "Out
of environment space" a few times and exiting before invoking JRE.
Can it be made to work? Probably, by tweaking the config.sys for
the emulated DOS environment to increase the (16-bit) environment size...
but it turns out, on Win32 systems, you can create "Shortcuts"
(which is really what you want) via an API call and bypass the
.pif files completely. Downside: you'll need a small .exe to
call the IShellLink() API, but I've written one :-) And I think
I can answer your last question about creating .pif's. While the
IShellLink() API normally creates Shortcut files ending in ".LNK",
in a fine example of Microsoft consistency, when IShellLink() is
used on Win9x (but not on NT) to create a shortcut pointing to a
.bat file, it actually ends up creating a .pif file even though
the name you specified ended in .lnk! I assume this behavior
applies to 16-bit .com and .exe's also.
You can find the utility to create Shortcuts at
http://mark.shepard.org/shlink/shlink.{c,exe}
It's statically linked with libc.lib to not require msvcrt.dll.
I've tested shlink on win95/8 and NT.
Also in this directory you'll find a modified version of E's
setup.bat which calls shlink.exe instead of copying .pif's. In
addition to creating the Shortcut, IShellLink() allows
specifying command line args, setting a working directory, choosing
an icon and setting the initial window state (iconified, maximized,
...) shlink.exe supports only a few of these features but it'd be
trivial to add more.
Watch out for the ~127 character command-line limit of
Win9x... I got around this in setup.bat by using environment
variables on the shlink command line rather than full paths. Ug.
Actually I'm surprised this worked. I can only assume env. variable
expansion is being done in a larger buffer. Yet another reason to have
a real Installer.
> 2) What should I "if" on in my .bat files so I can use Dan's logic on WinNT
> but the older logic on Win9x?. Which should work in Win2000? Is there a
> better way to handle this?
On NT (4, at least), %OS% is set to "Windows_NT".
Also, %SystemRoot% points to the root of the NT install (c:\winnt by
default). On Win9x, %windir% points to the root of the Windows install.
> Closely related to #1: Is there any known way to generate a .pif from a
> program? This would be necessary to write a real
> installer. Alternatively, what are the Mozilla-compatible open-source
> install programs, whether or not they're Java specific, as long as they
> generate working .pifs?
Well, hopefully this is useful.
Regards,
Mark Shepard
pobox.com! mns