From 77cc5a52a81fa8a7914419dcda1e019ee5281b8e Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Fri, 10 Apr 2020 17:51:15 +0200 Subject: [PATCH] file association on windows installer --- .github/issue_template.md | 19 +- install/windows/resources/ExecWaitJob.nsh | 54 +++++ install/windows/resources/FileAssociation.nsh | 190 ++++++++++++++++++ install/windows/resources/meshlab.nsi | Bin 14526 -> 12806 bytes 4 files changed, 252 insertions(+), 11 deletions(-) create mode 100644 install/windows/resources/ExecWaitJob.nsh create mode 100644 install/windows/resources/FileAssociation.nsh diff --git a/.github/issue_template.md b/.github/issue_template.md index 6e26fbbc7..e67d3919e 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -5,9 +5,9 @@ - [ ] Every platform #### What type of issue is? -- [ ] bug or unexpected behavior; -- [ ] crash; -- [ ] feature request; +- [ ] bug or unexpected behavior +- [ ] crash +- [ ] feature request - [ ] other (specify...) #### Describe your issue @@ -16,11 +16,8 @@ ####Guidelines for a good issue -Please before submitting an issue, check if your issue has been already reported by someone else. In this case, do not open another issue: just add your experience in the existing issue. - -#####Subject -If the issue is specific of a platform, please specify it on the subject in square brackets (example: `[MacOS] crash when opening obj`). -Please specify also if the issue concerns a bug, crash, or it is a feature request. - -#####Description -Please be as detailed as possible. If the issue is related to a specific mesh or file, please attach it. Delete these guidelines before submitting :) \ No newline at end of file +Before submitting an issue: +- check if your issue has been already reported by someone else. In this case, do not open another issue: just add your experience in the existing issue; +- If the issue is specific of a platform, please specify it on the subject in square brackets (example: `[MacOS] crash when opening obj`); +- be as detailed as possible. If the issue is related to a specific mesh or file, please attach it. Make sure that the problem is reproducible; +- delete these guidelines before submitting :) \ No newline at end of file diff --git a/install/windows/resources/ExecWaitJob.nsh b/install/windows/resources/ExecWaitJob.nsh new file mode 100644 index 000000000..4371a7fcb --- /dev/null +++ b/install/windows/resources/ExecWaitJob.nsh @@ -0,0 +1,54 @@ +!ifndef ExecWaitJob_INCLUDED +!define ExecWaitJob_INCLUDED + +; this macro executes a process and waits until has finished +; example call: +; StrCpy $8 '"uninstall.exe"' +; !insertmacro ExecWaitJob r8 +; +!macro ExecWaitJob _exec +/* +0=ErrChk+JOBOBJECTASSOCIATE*+PROCESS_INFO +1=hPort +2=hJob +3=ErrChk+hProcess+ioX +4=STARTINFO+hThread+ioOLAP +9="Stage" +*/ +StrCpy $9 0 +System::Call 'kernel32::CreateIoCompletionPort(i -1,i0,i0,i0)i.r1' +${IfThen} $1 != 0 ${|} IntOp $9 $9 + 1 ${|} +System::Call 'kernel32::CreateJobObject(i0,i0)i.r2' +${IfThen} $2 != 0 ${|} IntOp $9 $9 + 1 ${|} +System::Call '*(i 0,i $1)i.r0' +System::Call 'kernel32::SetInformationJobObject(i $2,i 7,i $0,i 8)i.r3' +${IfThen} $3 != 0 ${|} IntOp $9 $9 + 1 ${|} +System::Free $0 +System::Call '*(i,i,i,i)i.r0' +System::Alloc 72 +pop $4 +System::Call "*$4(i 72)" +System::Call 'kernel32::CreateProcess(i0,t ${_exec},i0,i0,i0,i 0x01000004,i0,i0,i $4,i $0)i.r3' +${IfThen} $3 != 0 ${|} IntOp $9 $9 + 1 ${|} +System::Free $4 +System::Call "*$0(i.r3,i.r4,i,i)" +System::Free $0 +System::Call 'kernel32::AssignProcessToJobObject(i $2,i $3)i.r0' +${IfThen} $0 != 0 ${|} IntOp $9 $9 + 1 ${|} +System::Call 'kernel32::ResumeThread(i $4)i.r0' +${IfThen} $0 != -1 ${|} IntOp $9 $9 + 1 ${|} +System::Call 'kernel32::CloseHandle(i $3)' +System::Call 'kernel32::CloseHandle(i $4)' +!define __ExecWaitJob__ ExecWaitJob${__LINE__} +${__ExecWaitJob__}ioportwait: +System::Call 'kernel32::GetQueuedCompletionStatus(i $1,*i.r3,*i,*i.r4,i -1)i.r0' +${IfThen} $0 = 0 ${|} StrCpy $9 0 ${|} +${IfThen} $3 != 4 ${|} goto ${__ExecWaitJob__}ioportwait ${|} +System::Call 'kernel32::CloseHandle(i $2)' +System::Call 'kernel32::CloseHandle(i $1)' +!undef __ExecWaitJob__ +${IfThen} $9 < 6 ${|} MessageBox mb_iconstop `ExecWaitJob "${_exec}" failed!` ${|} +!macroend + +!endif # !ExecWaitJob_INCLUDED + diff --git a/install/windows/resources/FileAssociation.nsh b/install/windows/resources/FileAssociation.nsh new file mode 100644 index 000000000..157257f1b --- /dev/null +++ b/install/windows/resources/FileAssociation.nsh @@ -0,0 +1,190 @@ +/* +_____________________________________________________________________________ + + File Association +_____________________________________________________________________________ + + Based on code taken from http://nsis.sourceforge.net/File_Association + + Usage in script: + 1. !include "FileAssociation.nsh" + 2. [Section|Function] + ${FileAssociationFunction} "Param1" "Param2" "..." $var + [SectionEnd|FunctionEnd] + + FileAssociationFunction=[RegisterExtension|UnRegisterExtension] + +_____________________________________________________________________________ + + ${RegisterExtension} "[executable]" "[extension]" "[description]" + +"[executable]" ; executable which opens the file format + ; +"[extension]" ; extension, which represents the file format to open + ; +"[description]" ; description for the extension. This will be display in Windows Explorer. + ; + + + ${UnRegisterExtension} "[extension]" "[description]" + +"[extension]" ; extension, which represents the file format to open + ; +"[description]" ; description for the extension. This will be display in Windows Explorer. + ; + +_____________________________________________________________________________ + + Macros +_____________________________________________________________________________ + + Change log window verbosity (default: 3=no script) + + Example: + !include "FileAssociation.nsh" + !insertmacro RegisterExtension + ${FileAssociation_VERBOSE} 4 # all verbosity + !insertmacro UnRegisterExtension + ${FileAssociation_VERBOSE} 3 # no script +*/ + + +!ifndef FileAssociation_INCLUDED +!define FileAssociation_INCLUDED + +!include Util.nsh + +!verbose push +!verbose 3 +!ifndef _FileAssociation_VERBOSE + !define _FileAssociation_VERBOSE 3 +!endif +!verbose ${_FileAssociation_VERBOSE} +!define FileAssociation_VERBOSE `!insertmacro FileAssociation_VERBOSE` +!verbose pop + +!macro FileAssociation_VERBOSE _VERBOSE + !verbose push + !verbose 3 + !undef _FileAssociation_VERBOSE + !define _FileAssociation_VERBOSE ${_VERBOSE} + !verbose pop +!macroend + + + +!macro RegisterExtensionCall _EXECUTABLE _EXTENSION _DESCRIPTION + !verbose push + !verbose ${_FileAssociation_VERBOSE} + Push `${_DESCRIPTION}` + Push `${_EXTENSION}` + Push `${_EXECUTABLE}` + ${CallArtificialFunction} RegisterExtension_ + !verbose pop +!macroend + +!macro UnRegisterExtensionCall _EXTENSION _DESCRIPTION + !verbose push + !verbose ${_FileAssociation_VERBOSE} + Push `${_EXTENSION}` + Push `${_DESCRIPTION}` + ${CallArtificialFunction} UnRegisterExtension_ + !verbose pop +!macroend + + + +!define RegisterExtension `!insertmacro RegisterExtensionCall` +!define un.RegisterExtension `!insertmacro RegisterExtensionCall` + +!macro RegisterExtension +!macroend + +!macro un.RegisterExtension +!macroend + +!macro RegisterExtension_ + !verbose push + !verbose ${_FileAssociation_VERBOSE} + + Exch $R2 ;exe + Exch + Exch $R1 ;ext + Exch + Exch 2 + Exch $R0 ;desc + Exch 2 + Push $0 + Push $1 + + ReadRegStr $1 HKCR $R1 "" ; read current file association + StrCmp "$1" "" NoBackup ; is it empty + StrCmp "$1" "$R0" NoBackup ; is it our own + WriteRegStr HKCR $R1 "backup_val" "$1" ; backup current value +NoBackup: + WriteRegStr HKCR $R1 "" "$R0" ; set our file association + + ReadRegStr $0 HKCR $R0 "" + StrCmp $0 "" 0 Skip + WriteRegStr HKCR "$R0" "" "$R0" + WriteRegStr HKCR "$R0\shell" "" "open" + WriteRegStr HKCR "$R0\DefaultIcon" "" "$R2,0" +Skip: + WriteRegStr HKCR "$R0\shell\open\command" "" '"$R2" "%1"' + WriteRegStr HKCR "$R0\shell\edit" "" "Edit $R0" + WriteRegStr HKCR "$R0\shell\edit\command" "" '"$R2" "%1"' + + Pop $1 + Pop $0 + Pop $R2 + Pop $R1 + Pop $R0 + + !verbose pop +!macroend + + + +!define UnRegisterExtension `!insertmacro UnRegisterExtensionCall` +!define un.UnRegisterExtension `!insertmacro UnRegisterExtensionCall` + +!macro UnRegisterExtension +!macroend + +!macro un.UnRegisterExtension +!macroend + +!macro UnRegisterExtension_ + !verbose push + !verbose ${_FileAssociation_VERBOSE} + + Exch $R1 ;desc + Exch + Exch $R0 ;ext + Exch + Push $0 + Push $1 + + ReadRegStr $1 HKCR $R0 "" + StrCmp $1 $R1 0 NoOwn ; only do this if we own it + ReadRegStr $1 HKCR $R0 "backup_val" + StrCmp $1 "" 0 Restore ; if backup="" then delete the whole key + DeleteRegKey HKCR $R0 + Goto NoOwn + +Restore: + WriteRegStr HKCR $R0 "" $1 + DeleteRegValue HKCR $R0 "backup_val" + DeleteRegKey HKCR $R1 ;Delete key with association name settings + +NoOwn: + + Pop $1 + Pop $0 + Pop $R1 + Pop $R0 + + !verbose pop +!macroend + +!endif # !FileAssociation_INCLUDED \ No newline at end of file diff --git a/install/windows/resources/meshlab.nsi b/install/windows/resources/meshlab.nsi index 87519f1df55f5084042a758d2faf94590eca88c6..4038a3901155dc3237c9abf902e31ac285c9ce56 100644 GIT binary patch delta 1686 zcmdm2*p{+Ef_3r@Zh_6uSZ}dU7GV>be27nsU5_D;p_n0KGC!NRsvAQlLk>eKgCkI+ zm?57b8OTp$C;^iBKvhtcn+v6d87Ill+H5AfiE)#>A4k0cg8~CD0~e4~V6euaSpjHF zK2ScDp#sQC1zQR+wwS>Ru3LqnnxP0Nn+~+H7_6>{!4*SCEzle#1{DTR20w;ihLFj3 zbrpj_B6>g@k{GgpED+D1!HK~O$bxxFiBwxApV!rgnp*%2mP)9(0SrD2kyJ7l%)O{UPj;gE1BLyiWn1+}e01S%=Dw$ixkPA#r z5Oc#Ae1WNkLicJz!Z;0>)?n^+1Ew{s?w$Nl-*|J4x($ClB7=ki6F+()&jgC4109wI zbSfwZDgg5xwmb+k1(Z=rv6zD^v*^{MqzL?ZgCv6)h|3%GB)b?~01%fsh;VQ{Ft8xy zh8_cHxq}G9k<7-GJL*BPidqDbW^e(psDLFm{MiGmx%D_oQ9TCY^9NRgahi*oKX_3x N$Yg(I$;JE3m;jBEDmefE literal 14526 zcmeI3`A=I{7RT?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