Archive: Beginner question


Beginner question
  Hi,
I am a Unix guy! I have written packages for Solaris and HP.
I am new to Windows development. Have been studying VB and
finally developed an application using VB.
I am in the process of writting an installer for the application.
Studied VB Installer, Windows Installer, InstallShield, ... and
came across NSIS a week ago. I found NSIS easy to learn and
implement, but I am stuck at one place.

Here is what needs to be done,
1) Findout if the target machine has Microsoft Word Installed.
2) If Word is NOT installed, print an error message and
abort the installation.
3) If Word is installed,
a) Copy a file from $INSTDIR to MS Word installed directory,
default c:\Program Files\Microsoft Office\Office
b) Write an entry into the registry name/value
WordInstall "<WORD INSTALL DIR>"

One of the ways to resolve the problems is, I can write an
ActiveX DLL file with functions,
a) GetWordPath ==> Returns the InstallDir of MS Word or empty str

1) I created the DLL and copied it to NSIS directory
When I call myDLL::GetWordPath in the .nsi script, I am getting

Invalid command: myDLL::GetWordPath

2) Say, If the above command is successful, where is the
return value from ActiveX function stored?

Can someone help me with the nsi script to get the results.


Is it possible to get the Word Install Path in NSIS, without
even bothering to create VB ActiveX DLL?


Many Thanks.


being an open office user myself, i cant really find the correct registry-entries for word.

i only found this on google:

In the example, the path to WinWord.Exe should be stored in the registry as:

HKEY_CLASSES_ROOT\Word.Document.6\shell\open\command =

"C:\Program Files\My Accessories\Winword.Exe" /n

which does causes FindExecutable to return the expected string.


in your case i'd double-check this, by searching your own registry for the location of the word executable (it also might appear that it has a different name in newer versions).

assuming that registry-entry is correct, you'd proceed like this:


ReadRegStr $0 <INSERT THE REGISTRY-ENTRY TO THE WINWORD.EXE>

>StrCmp $0 "" NoWordInstalled CopyFiles
>
NoWordInstalled and CopyFiles are GOTO-commands.

hope this helps you!

i think you could check the HKEY_CLASSES_ROOT for the .doc extension and check if it contains *word.exe* before you proceed (if there's no more specific entry for the executable).


try this

ReadRegStr $0 HKLM \
"Applications/Winword.exe/shell/new/command" \
"(Default)"


i'm not sure if (Default) is the correct name for the entry. just try this ;)

Getting Word's path from the association of .doc is not a good idea because one can associate .doc to OpenOffice for example and still have Word installed.

You can get winword.exe's path from:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe

I have tested this for Word 97, 2000, and XP and it works for all of them. It should work for earlier versions too AFAIK.

I have attached a sample script that should help you get started.

BTW, you can't create NSIS plug-in DLLs using VB. Only VC++ or Delphi using the templates in Contrib\ExDLL, unless you know how to create DLLs in VB that will work with VC.


Not only I found NSIS install to be great, the forum response
is excelent. Thanks to everyone for the reply.

I tried the solution given by "kichik" and it works great
on my machine Windows XP!
Only doubt I have is, What if the user has more than one application
on Windows with the name "Winword.exe"?
Say, I rename the notepad.exe to Winword.exe and installs it on my
machine. It gets installed fine and an entry is added into
the registry. Now there will be multiple entries for Winword.exe.
SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe

ReadRegStr returns the first available entry for Winword.exe.
How do I make sure whether I got the path for the MS Winword and not
my Winword.exe app(Notepad.exe)?


Here is the Visual Basic code that returns the path to Microsoft
Word Application and I feel confident about the results returned
by the below function (never tested on Window98 & Windows95!).

Please attach large scripts/source codes. Attached below.

Thanks Again.
Andy


This VB code can be easily converted to a NSIS script. Just use ReadRegStr and one call to GetNextParm. The first call to GetNextParm, if you push the entire command line, will give you just the exe without its parameters.