Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 18th October 2002, 07:19   #1
aj0000009
Junior Member
 
Join Date: Oct 2002
Location: San Jose, California.
Posts: 4
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.
aj0000009 is offline   Reply With Quote
Old 18th October 2002, 10:28   #2
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,164
Send a message via ICQ to Yathosho
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:

PHP Code:
ReadRegStr $<INSERT THE REGISTRY-ENTRY TO THE WINWORD.EXE>
StrCmp $"" NoWordInstalled CopyFiles 
NoWordInstalled and CopyFiles are GOTO-commands.

hope this helps you!
Yathosho is online now   Reply With Quote
Old 18th October 2002, 10:31   #3
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,164
Send a message via ICQ to Yathosho
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).
Yathosho is online now   Reply With Quote
Old 18th October 2002, 10:43   #4
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,164
Send a message via ICQ to Yathosho
try this
code:
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
Yathosho is online now   Reply With Quote
Old 18th October 2002, 12:34   #5
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
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.
Attached Files
File Type: txt word.txt (838 Bytes, 68 views)

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 18th October 2002, 20:28   #6
aj0000009
Junior Member
 
Join Date: Oct 2002
Location: San Jose, California.
Posts: 4
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
aj0000009 is offline   Reply With Quote
Old 19th October 2002, 10:59   #7
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
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.
Attached Files
File Type: txt source.txt (1.4 KB, 77 views)

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump