From e6af406ab2ff9836d8fc2175024204e5f5b1b50b Mon Sep 17 00:00:00 2001 From: kichik Date: Tue, 3 Dec 2002 20:33:17 +0000 Subject: [PATCH] RegDLL now sets the current directory to the DLL directory (Patch #646306 ) git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1872 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/exehead/exec.c | 5 +++++ Source/exehead/util.c | 42 +++++++++++++++--------------------------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/Source/exehead/exec.c b/Source/exehead/exec.c index 3f2885f6..bfae6e2e 100644 --- a/Source/exehead/exec.c +++ b/Source/exehead/exec.c @@ -937,6 +937,11 @@ static int NSISCALL ExecuteEntry(entry *entry_) char *buf0=process_string_fromparm_tobuf(0x00); char *buf1=process_string_fromparm_tobuf(0x11); + // suggested by Kevin Gadd (janusfury) + lstrcpy(buf3, buf0); + trimslashtoend(buf3); + SetCurrentDirectory(buf3); + h=LoadLibrary(buf0); if (h) { diff --git a/Source/exehead/util.c b/Source/exehead/util.c index 1607f54d..31e8adfe 100644 --- a/Source/exehead/util.c +++ b/Source/exehead/util.c @@ -1,5 +1,6 @@ #include #include +#include #include "util.h" #include "state.h" #include "config.h" @@ -72,38 +73,25 @@ void * NSISCALL my_GlobalAlloc(DWORD dwBytes) { #ifdef NSIS_SUPPORT_RMDIR void NSISCALL doRMDir(char *buf, int recurse) { - if (recurse && is_valid_instpath(buf)) + if (is_valid_instpath(buf)) { - int i=mystrlen(buf); - HANDLE h; - WIN32_FIND_DATA fd; - lstrcat(buf,"\\*.*"); - h = FindFirstFile(buf,&fd); - if (h != INVALID_HANDLE_VALUE) - { - do - { - if (fd.cFileName[0] != '.' || - (fd.cFileName[1] != '.' && fd.cFileName[1])) - { - mystrcpy(buf+i+1,fd.cFileName); - if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) doRMDir(buf,recurse); - else - { - update_status_text_from_lang(LANG_DELETEFILE,buf); - if (fd.dwFileAttributes & FILE_ATTRIBUTE_READONLY) - SetFileAttributes(buf,fd.dwFileAttributes^FILE_ATTRIBUTE_READONLY); - DeleteFile(buf); - } - } - } while (FindNextFile(h,&fd)); - FindClose(h); + if (recurse) { + SHFILEOPSTRUCT op; + + op.hwnd=0; + op.wFunc=FO_DELETE; + buf[mystrlen(buf)+1]=0; + op.pFrom=buf; + op.pTo=0; + + op.fFlags=FOF_NOERRORUI|FOF_SILENT|FOF_NOCONFIRMATION; + + SHFileOperation(&op); } - buf[i]=0; // fix buffer + else RemoveDirectory(buf); } log_printf2("RMDir: RemoveDirectory(\"%s\")",buf); update_status_text_from_lang(LANG_REMOVEDIR,buf); - RemoveDirectory(buf); } #endif//NSIS_SUPPORT_RMDIR