Old 27th April 2010, 13:18   #121
jpderuiter
Major Dude
 
Join Date: Feb 2007
Posts: 672
http://forums.winamp.com/showthread.php?threadid=274495
jpderuiter is offline   Reply With Quote
Old 27th April 2010, 13:44   #122
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
LockedList::IsFileLocked doesn't show the UI. It is purely a utility function to avoid having to use FileOpen (it does that internally).

Edit: I will sort that bug/typo later

Stu
Afrow UK is offline   Reply With Quote
Old 27th April 2010, 18:11   #123
Alfaromeo
Member
 
Join Date: Mar 2008
Posts: 73
This is a codec filter binary with extension ".ax" . This codec filter is installed by my application as well as ,it will be shared by some third party applications. Hence the need , to detect whether this is locked or not when I reinstall or upgrade my application .
I tried the IsFIleLocked function , but it did not appear to sense it was locked.
Is this a bug as Stu pointed out?
Alfaromeo is offline   Reply With Quote
Old 27th April 2010, 18:15   #124
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
You mean IsFileLocked always returns false? Does FileOpen work (follow jpderuiter's link)?

Stu
Afrow UK is offline   Reply With Quote
Old 27th April 2010, 18:18   #125
Alfaromeo
Member
 
Join Date: Mar 2008
Posts: 73
Yes that is what is happening.
BTW, this being a binary file will FileOpen work?
Alfaromeo is offline   Reply With Quote
Old 27th April 2010, 18:21   #126
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
FileOpen (CreateFile) works on any file. Try it.

Stu
Afrow UK is offline   Reply With Quote
Old 28th April 2010, 10:03   #127
Alfaromeo
Member
 
Join Date: Mar 2008
Posts: 73
Yes FileOpen code snippet from the other forum worked as expected.
What is the issue here
Alfaromeo is offline   Reply With Quote
Old 28th April 2010, 16:04   #128
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
Show me the LockedList plug-in code you are using. As I said, my plug-in code is the same as using FileOpen so you must be doing something wrong.

Stu
Afrow UK is offline   Reply With Quote
Old 28th April 2010, 17:51   #129
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
Quote:
Originally Posted by Afrow UK View Post
My plug-in code is the same as using FileOpen
I don't think it does, though?

From an earlier discussion (same thread):
Quote:
Originally Posted by Animaether View Post
confirming the IsFileLocked bugfix. Unfortunately it doesn't recognize the locked DLL as being locked
Quote:
Originally Posted by Afrow UK View Post
Yep it will only work on files that have a handle open on them (DLL's do not when they are locked)
So given that...
Quote:
Originally Posted by Alfaromeo View Post
This is a codec filter binary with extension ".ax"
...wouldn't it be subject to the same difference?

Quote:
Originally Posted by Afrow UK View Post
Show me the LockedList plug-in code you are using.
Just in case there -shouldn't- be a difference after all, the following example should work to demonstrate:

PHP Code:
!addplugindir "."
!include "nsDialogs.nsh"
OutFile LockedListTest.exe

Section
SectionEnd

Var dialog
Var hwnd

Page Custom test

Function .onInit
  InitPluginsDir
FunctionEnd

Function test
  nsDialogs
::Create 1018
  Pop $dialog

  
${NSD_CreateButton0 0 10010"Use LockedList"
    
Pop $hwnd
    
${NSD_OnClick$hwnd button.lockedlist.onclick

  
${NSD_CreateButton0 20 10010"Use FileOpen"
    
Pop $hwnd
    
${NSD_OnClick$hwnd button.fileopen.onclick
    
  nsDialogs
::Show
FunctionEnd

Function button.lockedlist.onclick
  Pop $hwnd
  LockedList
::IsFileLocked "$PLUGINSDIR\nsDialogs.dll"
  
Pop $0
  MessageBox MB_OK 
"$PLUGINSDIR\nsDialogs.dll$\r$\nLocked: $0"
FunctionEnd

Function button.fileopen.onclick
  Pop $hwnd
  ClearErrors
  FileOpen $R0 
"$PLUGINSDIR\nsDialogs.dll" "a"
  
IfErrors _errors _noerrors

  _errors
:
      
StrCpy $"true"
      
goto _done

  _noerrors
:
      
StrCpy $"false"
      
FileClose $R0
      
goto _done

  _done
:

  
MessageBox MB_OK "$PLUGINSDIR\nsDialogs.dll$\r$\nLocked: $0"
FunctionEnd 

Last edited by Animaether; 28th April 2010 at 17:52. Reason: typo
Animaether is offline   Reply With Quote
Old 28th April 2010, 20:56   #130
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
Thanks, both issues should be fixed. For some reason I had omitted GENERIC_WRITE on CreateFile (in IsFileLocked) so I am suprised IsFileLocked ever worked at all.

Stu
Afrow UK is offline   Reply With Quote
Old 28th April 2010, 22:18   #131
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
yay

Any thoughts on that Ignore button bit? (custom Ignore text not getting cleared once list is empty)
Animaether is offline   Reply With Quote
Old 29th April 2010, 09:08   #132
Alfaromeo
Member
 
Join Date: Mar 2008
Posts: 73
It works now. Possible to get a array of processes that is being used by the concerned file if locked. Will be helpful for me to display the same in the MessageBox and take user action.
Alfaromeo is offline   Reply With Quote
Old 29th April 2010, 09:11   #133
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
@Animaether
Ah didn't see that one sorry. There's no code in there to set it back so I will add it when I have time.

Stu
Afrow UK is offline   Reply With Quote
Old 29th April 2010, 11:49   #134
Alfaromeo
Member
 
Join Date: Mar 2008
Posts: 73
Stu,

I acheived my option , by using the SilentSearch option from the examples listed.

Although I have listed another query sometime back in this forum , was not answered. Is their any option to give search path , instead of individual files. This will ease listing files one by one
Alfaromeo is offline   Reply With Quote
Old 29th April 2010, 13:19   #135
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
Currently only files are supported but I will add this when I have time (AddFolder). Got exams coming up so I can't promise anything soon!

Stu
Afrow UK is offline   Reply With Quote
Old 29th April 2010, 13:20   #136
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
Quote:
Originally Posted by Afrow UK View Post
There's no code in there to set it back so I will add it when I have time.
Cool - thanks

Quote:
Originally Posted by Alfaromeo View Post
Is their any option to give search path , instead of individual files. This will ease listing files one by one
Nope - I wouldn't recommend this, either.

Let's say you need to overwrite a few files in 'c:\windows\'... would you honestly want to feed LockedList 'c:\windows\*.*' and have it throw up pretty much every locked file.. even though you might only want to overwrite two of them?

I think your best bet is to create a list of the files you want to overwrite - either by A. hardcoding this in the installer by hand or by a pre-installer build-installer or B. extracting your files to a temporary location and use any of the FindFirst / FindNext / bits and pieces - and feed that to LockedList

The 'B' method could be combined with lockedlist directly.
i.e.
code:

for each destination path (
extract the files that go to a certain path to a temporary location
loop over the extacted files, and for each file (
add the 'destination path\filename' to LockedList
)
)



The temporary location can be re-used with e.g. CopyFiles to get the files to the destination path without having to re-extract them from the installer.
Animaether is offline   Reply With Quote
Old 29th April 2010, 13:39   #137
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
You're better of generating the LockedList AddFile/AddModule code at compile time using Locate in a specially built NSIS executable that you execute with !system (see http://nsis.sourceforge.net/Invoking...n_compile-time). However, I think AddFolder would be fine when used properly (i.e. your application's path that you may wish to completely remove).

Stu
Afrow UK is offline   Reply With Quote
Old 2nd May 2010, 15:30   #138
Alfaromeo
Member
 
Join Date: Mar 2008
Posts: 73
@Animather

I understand the complexity involved if AddFolder ( proposed function by Stu) is not used properly. As rightly said , using it on C:\Windows or any system related folders can be an issue. If we know what folders or files that are going to be targeted , this is not an cause of worry .

@Stu

This function if developed can ease my application's perfomance, because the application can cause any of the files in the instalation directory to be locked. Hence looping over and using AddFile is an existing option, but an overhead.
Alfaromeo is offline   Reply With Quote
Old 2nd May 2010, 18:14   #139
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
'AddFolder' true, fair enough for self-contained areas
Animaether is offline   Reply With Quote
Old 4th June 2010, 11:49   #140
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
Uploaded v1.6.

v1.6 - 4th June 2010
* Fixed processes getting repeated in the list.
* Fixed list not auto scrolling to absolute bottom.
* Next button text restored when using /ignore and no processes are found.
* Added AddFolder plug-in function.
* File description displayed for processes without a window caption.
* Process Id displayed for processes without a window caption or file description.

Stu
Afrow UK is offline   Reply With Quote
Old 4th June 2010, 11:55   #141
Pawel
Moderator
 
Pawel's Avatar
 
Join Date: Aug 2004
Location: Poland
Posts: 499
Send a message via ICQ to Pawel
Thanks Stu,
Indeed, processes were repeated in the list. Nice, that this is fixed now.
I will test new build as soon as possible.
-Pawel

[Edit]
Stu, Please add version information to dll, in next build (for Embeddedlists.dll too)
Pawel is offline   Reply With Quote
Old 8th July 2010, 12:53   #142
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
v1.7 - 8th July 2010
* Process file description now retreived by SystemEnum if no process caption found.
* Added EnumProcesses plug-in function.
* SilentSearch now uses a callback function instead of the stack.
* SilentSearch /thread changed to /async.
* Previously added processes now stored in an array for look up to prevent repetitions rather than looked up in the list view control.
* Added FindProcess plug-in function.
* Now gets 64-bit processes (but not modules).
* RC2: Added version information resource.

Stu
Afrow UK is offline   Reply With Quote
Old 13th July 2010, 18:22   #143
Pawel
Moderator
 
Pawel's Avatar
 
Join Date: Aug 2004
Location: Poland
Posts: 499
Send a message via ICQ to Pawel
Stu,
New version 1.7 doeasn't close finded applications (searching is OK, but when I clik Next button, I got message, "Cant close applications...".)
v1.6 did it correctly.
-Pawel
Pawel is offline   Reply With Quote
Old 23rd July 2010, 05:06   #144
jiake
Senior Member
 
jiake's Avatar
 
Join Date: Oct 2007
Location: Xi'an, China
Posts: 206
It is really a good plugin. But I found that the icons in the listview is not the small one of a executable file but a zoomed one of the big icon (32x32). The zoomed icon doesn't look as good as the original small icon of the executable file. So I modified the source code, using ExtractIconEx function replace with ExtractIcon.

Before:

After:


Attachment is the modified source LockedList.cpp.
Attached Thumbnails
Click image for larger version

Name:	before.png
Views:	630
Size:	11.6 KB
ID:	47353   Click image for larger version

Name:	after.png
Views:	653
Size:	11.5 KB
ID:	47354  
Attached Files
File Type: zip LockedList.zip (14.9 KB, 346 views)
jiake is offline   Reply With Quote
Old 23rd July 2010, 09:18   #145
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
Nice one. I will update the plug-in.

Stu
Afrow UK is offline   Reply With Quote
Old 23rd July 2010, 10:19   #146
jiake
Senior Member
 
jiake's Avatar
 
Join Date: Oct 2007
Location: Xi'an, China
Posts: 206
Sorry for my poor English, I should say "using ExtractIconEx function to replace ExtractIcon".

Besides, line 1660 was incorrect, I typed a blank in the word "image" by accident when modifying:
hIma geList = ImageList_Create ...

Expecting your next version.
jiake is offline   Reply With Quote
Old 23rd July 2010, 14:52   #147
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
I have uploaded v1.9. I had a look at your code - there is no need for a global variable.

Stu
Afrow UK is offline   Reply With Quote
Old 23rd July 2010, 15:02   #148
jiake
Senior Member
 
jiake's Avatar
 
Join Date: Oct 2007
Location: Xi'an, China
Posts: 206
Yes, I am so folly, the variable is exactly unnecessary.
I have downloaded the new version, it is very good!
jiake is offline   Reply With Quote
Old 23rd July 2010, 15:53   #149
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
I have found some unicode build issues while building GetVersion which will likely apply to LockedList (partly due to migrating to VS2010). Will fix and reupload soon.

Stu
Afrow UK is offline   Reply With Quote
Old 23rd July 2010, 16:36   #150
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
Done. Unicode build was indeed faulty.

Stu
Afrow UK is offline   Reply With Quote
Old 23rd August 2010, 02:47   #151
ukreator
Junior Member
 
Join Date: Aug 2010
Location: Omsk, Russia
Posts: 1
IsFileLocked issue

Hi Stu

Thanks for the plugin, it is very good and helpful.

Anyway, while testing it in my installer I've found one bug. It treat file as blocked in the case when this file has non-existent directories within the full path. This can be easily fixed by replacing this piece of code at line 2050 in LockedList.cpp

code:

if (GetLastError() != ERROR_FILE_NOT_FOUND)
fLocked = TRUE;



with

code:

if ((err != ERROR_FILE_NOT_FOUND) && (err != ERROR_PATH_NOT_FOUND))
fLocked = TRUE;



Also it would be great to replace

code:

#include "afxres.h"



to

code:

#include <windows.h>



in LockedList.rc to be able to compile with MSVC Express edition.

Dmitry
ukreator is offline   Reply With Quote
Old 23rd August 2010, 09:23   #152
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
Thanks I'll put in those mods

Stu
Afrow UK is offline   Reply With Quote
Old 23rd August 2010, 13:55   #153
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
v2.0 uploaded.

Stu
Afrow UK is offline   Reply With Quote
Old 5th October 2010, 14:20   #154
TheGrudge
Junior Member
 
Join Date: Jul 2010
Posts: 9
LockedList plugin doesn't seem to work with x64?
I added this line in the installer script:

LockedList::AddModule "$INSTDIR\some.dll"

When compiled with w32, the dll is detected and the running program is shown. But when compiled on x64 and running it on the x64-Version of the program that is locking the dll, the file is not shown in the locked list.

Is this a known issue?
TheGrudge is offline   Reply With Quote
Old 5th October 2010, 16:51   #155
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
Quote:
Originally Posted by TheGrudge View Post
LockedList plugin doesn't seem to work with x64? [...] Is this a known issue?
Yes. Because NSIS itself is not 64bit, and thus the LockedList plugin isn't 64bit, it also can't really access 64bit process information that would be required for this.

One thing you can try is testing if the file is locked, rather than the module. For this you might have to use a manual testing method, like trying to open the file for appending. If that fails - the file is locked. There's a few downsides to that method (you touch the file, and you won't know -what- is locking the file), but it's possibly all you've got
Animaether is offline   Reply With Quote
Old 6th October 2010, 13:54   #156
mj_blue
Junior Member
 
Join Date: Sep 2007
Posts: 13
Add Custom not working?

Hi, I am making an enhancement to our installer to change the horrible "MCI-Command Handling Window" holding open an activex control to be a more sensible message but I can't get the AddCustom work.

I have tried using the example LockedListCustom.nsi and this builds but when I say 'Yes' to the question is myapp running it never show sin the lockedlist window. I get the same behaviour in my own installer.

Details:

lockedlist V2.0
OS: XP SP3
NSIS: 2.46


code:

Function Isocxlocked
LockedList::IsFileLocked $INSTDIR\axagp.ocx
Pop $R1
${If} $R1 == true
MessageBox MB_OK|MB_ICONINFORMATION `$INSTDIR\axagp.ocx IS locked!!??`
${Else}
MessageBox MB_OK|MB_ICONINFORMATION `$INSTDIR\axagp.ocx is not locked.`
${EndIf}
Push true

FunctionEnd

Function MyAppCallback
Pop $R0

; Message box instead of actual logical test...
${If} ${Cmd} `MessageBox MB_YESNO|MB_ICONQUESTION 'Is $R0 running?' IDYES`
Push true
${Else}
Push false
${EndIf}

FunctionEnd

Function LockedListShow
!insertmacro MUI_HEADER_TEXT `List of open Browsers with myapp in Use` ``
GetFunctionAddress $R1 Isocxlocked
LockedList::AddCustom /icon $INSTDIR\antixgpb.exe 'Internet Explorer' iexplore.exe $R1
GetFunctionAddress $R0 MyAppCallback
LockedList::AddCustom /icon $PLUGINSDIR\myapp.ico `My App v1.0` myapp.exe $R0
LockedList::Dialog /searching "Searching for Browsers in use" /noprograms "No Browsers have Game Player in use" /autoclose
FunctionEnd



I have this running twice in the code above, once detecting if the file is in use (and currently forcing a true return) and once is extracted straight from the demo app.

Any help with how to get this working appreciated.

Thanks

Mark Jones

Last edited by mj_blue; 6th October 2010 at 13:57. Reason: no smiley
mj_blue is offline   Reply With Quote
Old 6th October 2010, 15:48   #157
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
uh oh... looks like a bug - an older version of LockedList (which we use, haven't done the round of plugin updates yet) does work correctly with the example.
Animaether is offline   Reply With Quote
Old 6th October 2010, 15:58   #158
mj_blue
Junior Member
 
Join Date: Sep 2007
Posts: 13
Hi Animaether,

what version of the plugin are you using? I'll downgrade on my test setup and check that this code does actually work in principle.

Thanks

Mark
mj_blue is offline   Reply With Quote
Old 6th October 2010, 17:17   #159
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
My version is not versioned, so I can't say... but the date on the file inside the archive is 2010/Apr/28 - which would make it version 1.5 . Actually, I should have 1.6 in the actual current build as that fixes the Next button text. There's quite a few changes since 1.5/1.6, so I'd wait and see if Afrow knows what the problem might be (I didn't spot anything standing out in the source code, but I'm not a C/C++ programmer) so it can be fixed
Animaether is offline   Reply With Quote
Old 6th October 2010, 20:28   #160
mj_blue
Junior Member
 
Join Date: Sep 2007
Posts: 13
Yes, it looks like this bug was introduced in V1.7, this works in V1.6 but when I upgrade to V1.7 then myapp never gets shown using the custom example.

A lot changed between the versions so I can't even see anything obvious to try and help sorry

I could only see that it changed from using uiFunctionAddress to iFunctionAddress

Mark
mj_blue is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Tags
handle, plug-in

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