Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   LockedList plug-in (http://forums.winamp.com/showthread.php?t=274168)

jpderuiter 27th April 2010 13:18

http://forums.winamp.com/showthread.php?threadid=274495

Afrow UK 27th April 2010 13:44

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

Alfaromeo 27th April 2010 18:11

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?

Afrow UK 27th April 2010 18:15

You mean IsFileLocked always returns false? Does FileOpen work (follow jpderuiter's link)?

Stu

Alfaromeo 27th April 2010 18:18

Yes that is what is happening.
BTW, this being a binary file will FileOpen work?

Afrow UK 27th April 2010 18:21

FileOpen (CreateFile) works on any file. Try it.

Stu

Alfaromeo 28th April 2010 10:03

Yes FileOpen code snippet from the other forum worked as expected.
What is the issue here

Afrow UK 28th April 2010 16:04

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

Animaether 28th April 2010 17:51

Quote:

Originally Posted by Afrow UK (Post 2658012)
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 (Post 2649264)
confirming the IsFileLocked bugfix. Unfortunately it doesn't recognize the locked DLL as being locked

Quote:

Originally Posted by Afrow UK (Post 2649538)
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 (Post 2657709)
This is a codec filter binary with extension ".ax"

...wouldn't it be subject to the same difference?

Quote:

Originally Posted by Afrow UK (Post 2658012)
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 


Afrow UK 28th April 2010 20:56

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

Animaether 28th April 2010 22:18

yay :)

Any thoughts on that Ignore button bit? (custom Ignore text not getting cleared once list is empty)

Alfaromeo 29th April 2010 09:08

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.

Afrow UK 29th April 2010 09:11

@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

Alfaromeo 29th April 2010 11:49

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

Afrow UK 29th April 2010 13:19

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

Animaether 29th April 2010 13:20

Quote:

Originally Posted by Afrow UK (Post 2658201)
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 (Post 2658253)
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.

Afrow UK 29th April 2010 13:39

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

Alfaromeo 2nd May 2010 15:30

@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.

Animaether 2nd May 2010 18:14

'AddFolder' true, fair enough for self-contained areas :)

Afrow UK 4th June 2010 11:49

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

Pawel 4th June 2010 11:55

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)

Afrow UK 8th July 2010 12:53

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

Pawel 13th July 2010 18:22

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

jiake 23rd July 2010 05:06

3 Attachment(s)
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:
http://forums.winamp.com/attachment....chmentid=47353
After:
http://forums.winamp.com/attachment....chmentid=47354

Attachment is the modified source LockedList.cpp.

Afrow UK 23rd July 2010 09:18

Nice one. I will update the plug-in.

Stu

jiake 23rd July 2010 10:19

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.

Afrow UK 23rd July 2010 14:52

I have uploaded v1.9. I had a look at your code - there is no need for a global variable.

Stu

jiake 23rd July 2010 15:02

Yes, I am so folly, the variable is exactly unnecessary.
I have downloaded the new version, it is very good!

Afrow UK 23rd July 2010 15:53

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 23rd July 2010 16:36

Done. Unicode build was indeed faulty.

Stu

ukreator 23rd August 2010 02:47

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

Afrow UK 23rd August 2010 09:23

Thanks I'll put in those mods :)

Stu

Afrow UK 23rd August 2010 13:55

v2.0 uploaded.

Stu

TheGrudge 5th October 2010 14:20

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?

Animaether 5th October 2010 16:51

Quote:

Originally Posted by TheGrudge (Post 2704666)
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 :)

mj_blue 6th October 2010 13:54

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

Animaether 6th October 2010 15:48

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.

mj_blue 6th October 2010 15:58

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

Animaether 6th October 2010 17:17

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 :)

mj_blue 6th October 2010 20:28

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


All times are GMT. The time now is 17:39.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.