Skip to content
⌘ NSIS Forum Archive

LockedList plug-in

320 posts

Afrow UK#

LockedList plug-in

An NSIS plugin to display or get a list of programs that are locking a selection of files that have to be uninstalled or overwritten.

http://nsis.sf.net/File:LockedList.zip

Stu
daisywheel#
Hi Afrow UK,

Even simple script

LockedList::AddFile /NOUNLOAD $SYSDIR\kernel32.dll"
LockedList:😁ialog

doesn't work for me.

I get messages "Going to compile test program and then run it"
then "The file '$TEMP\nsz1325.tmp\Lock' is now locked. It will appear on the LockedList dialog page soon..." some dialog blinks and that's all.

The same result I've got with example provided with plugin.
Afrow UK#
Firstly, you're missing a quote and secondly that's a module not a file.

How about this script:
Name "LockedList Test"
OutFile "LockedListTest.exe"

!include MUI.nsh

!insertmacro MUI_PAGE_WELCOME
Page Custom LockedListShow

!insertmacro MUI_LANGUAGE English

Function LockedListShow
LockedList::AddModule /NOUNLOAD "$SYSDIR\kernel32.dll"
LockedList:😁ialog
FunctionEnd

Section
SectionEnd
You'll get some garbage for the first program captions. I might be able to fix this.

Stu
daisywheel#
Thank you for sample but it also doen't work for me.
It seems that the problem is exactly in LockedList:😁ialog

I modified your sample adding three message boxes


Name "LockedList Test"
OutFile "LockedListTest.exe"

!include MUI.nsh

!insertmacro MUI_PAGE_WELCOME
Page Custom LockedListShow

!insertmacro MUI_LANGUAGE English

Function LockedListShow
MessageBox MB_OK "test1"
LockedList::AddModule /NOUNLOAD "$SYSDIR\kernel32.dll"
MessageBox MB_OK "test2"
LockedList:😁ialog
FunctionEnd

Section
MessageBox MB_OK "test3"
SectionEnd
and I can see only two of them.
Afrow UK#
You're not going to see the 3rd one because the dialog stops execution of the installer until it is closed.
What exactly happens? Does the dialog not display?

Edit: Also, what OS are you on?

Stu
daisywheel#
dialog doesn't appear. installer is closed after message box "test2" closed.

OS: WinXP SP2
Afrow UK#
That's interesting. I'm running Win XP SP2 also.

What happens if you don't use any AddFile/AddModules.

Stu
daisywheel#edited
ok, sorry for delay with answer. I had to deal with something.
now I'm sure that the problem is in LockedList:😁ialog

I have two vesions of script

Name "LockedList Test"
OutFile "LockedListTest.exe"

!include MUI.nsh

!insertmacro MUI_PAGE_WELCOME

!insertmacro MUI_PAGE_INSTFILES

Page Custom LockedListShow

!insertmacro MUI_LANGUAGE English

Function LockedListShow
MessageBox MB_OK "test1"
LockedList::AddModule /NOUNLOAD "$SYSDIR\kernel32.dll"
MessageBox MB_OK "test2"
LockedList:😁ialog
FunctionEnd


Section "Install"
MessageBox MB_OK "test3"
SectionEnd
and


Name "LockedList Test"
OutFile "LockedListTest.exe"

!include MUI.nsh

!insertmacro MUI_PAGE_WELCOME

Page Custom LockedListShow

!insertmacro MUI_PAGE_INSTFILES


!insertmacro MUI_LANGUAGE English

Function LockedListShow
MessageBox MB_OK "test1"
LockedList::AddModule /NOUNLOAD "$SYSDIR\kernel32.dll"
MessageBox MB_OK "test2"
LockedList:😁ialog
FunctionEnd


Section "Install"
MessageBox MB_OK "test3"
SectionEnd
the first one shows message boxes
"test3"
"test1"
"test2"

the second one
"test1"
"test2"

diff:
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
Page Custom LockedListShow

!insertmacro MUI_PAGE_WELCOME
Page Custom LockedListShow
!insertmacro MUI_PAGE_INSTFILES

we contact directly so I can help you debug plugin
Afrow UK#
Located the problem thanks to daisywheel 🙂
Please be patient while we make sure everything is ok then I shall upload the updated version.

Stu
daisywheel#
LockedList::AddModule /NOUNLOAD "$SYSDIR\module.dll"
LockedList::AddModule /NOUNLOAD "$SYSDIR\kernel32.dll"

in case file module.dll doesn't exist will result error in functionality - there will no dependencies found

in case we change order
LockedList::AddModule /NOUNLOAD "$SYSDIR\kernel32.dll"
LockedList::AddModule /NOUNLOAD "$SYSDIR\module.dll"

plugin will work in another manner. I don't think this is expected behaviour.
Afrow UK#
Found the problem. It was a bad array pointer. It wasn't the fact of the file not being there it was simply only taking the first file or module added with AddFile/AddModule.

I was also able to fix the captions problem. I noticed captions were being repeated over multiple processes aside from the garbage caption for the first few processes. Just needed a ZeroMemory in there.

Uploaded v0.2 RC3.


Thanks again 🙂

Stu
daisywheel#
One more suggestion. I'm not compeltely happy with results.
For example, I have two browser application run: Internet Explorer and Moxilla Firefox both on page http://nsis.sourceforge.net/File:LockedList.zip

also I use following code in a script

LockedList::AddModule /NOUNLOAD "$SYSDIR\kernel32.dll"
LockedList:😁ialog
and as results I've got
WINAMP.COM | Forums - LockedList plug-in - Moxilla Firefox (firefox.exe)
for Moxilla Firefox
and
AutoSuggest Drop-Down (iexplore.exe)
for IE
Afrow UK#
Currently it grabs the first window caption for that process id by using EnumWindows. I'll look into it. Maybe I can check if the window is a child or not and if it is then skip it.

Stu
Afrow UK#
Realised that EnumWindows does not enumerate child windows anyway (that's what EnumChildWindows is for) so instead I'm checking to see if a window has the WS_SYSMENU style set (title bar). Now get the correct caption for Internet Explorer among others.

Uploaded v0.3:


I also documented the ::Unload function which has to be used to unload the plugin after calling SilentWait /NOUNLOAD /time #. Few other changes in the change log too.

Stu
daisywheel#
Another suggestion.

Add horizontal scroll when long name is displayed.

For now horizontal scroll is added only together with vertical one (in some cases even when it's not necessary)

Roman
Afrow UK#
This isn't possible because the list box is actually a list view with a single hidden column set to the width of the box. The NSIS InstFiles page has the same thing. Another option would be to have a tool-tip like the InstFiles page...

Stu
kichik#
You can use ListView_SetColumnWidth with LVSCW_AUTOSIZE, but I think the triple dot looks better. If someone wants to see the entire line, he could just hover over it instead of scrolling and then seeing just the end.
Afrow UK#
Yeh I agree.
How does NSIS work out how long the text being displayed is?
I'm guessing it's not just down to the number of characters...

Stu
Afrow UK#
Yeh I've got that already... sorry meant the dots, but now I'm guessing that the list view control adds those itself anyway!!

Stu
kichik#
The list view automatically shows the dots, but you need LVS_EX_LABELTIP for it to show the tool tip.
Afrow UK#
Thanks found that in Ui.c too. Very neat that it's all provided 🙂

Uploaded v0.3 RC2:


Edit: Uploaded again as it had the test executable in the Zip (+50000 bytes or so)

Stu
kalverson#
During testing of various locked items, I found a minor quirk. The locking process was detected going away for the exe's, but when I exited explore (brought up inside the target install directory), that was not detected going away. I had to navigate back and then next again to repeat the locked file search to get past it to the install. Also during testing, I ran into an "out of memory" message that appeared in the dialog just before the process name. That only happened once and did not repeat itself during futher testing.
RobertStrong#
Paths

It appears that the plugin doesn't try both short and long paths so both need to be added for files / modules that may be in use with either a long or short path. Might be a nice addition for the plugin to check both behind the scenes.

Better still would be the ability to match files / modules in use by file name and then compare the paths to verify they are the same. This would also cover the unlikely scenario where the path is a combination of both long and short. Also, files / modules names can be short.

Besides that all I can say is wow... this is an extremely useful plugin.

Thanks,
Robert
Afrow UK#
Ah right good find. I'll see what I can do about that when I've got some time.

I plan on adding a 'file name only' lookup for the plug-in as well, and also the ability to simply show windows that have the task bar style set.

Thanks

Stu
RobertStrong#
SilentSearch

I just noticed that SilentSearch isn't working when the module is in use by another user. This is on Vista with fast user switching. Interestingly enough, LockedList:😁ialog is able to find it.

Thanks again,
Robert