Skip to content
⌘ NSIS Forum Archive

Alternative data streams

6 posts

Anders#
There is a documented API to manipulate the internet zone:

!include Win\COM.nsh
Section
!ifndef CLSID_PersistentZoneIdentifier
!define CLSID_PersistentZoneIdentifier {0968e258-16c7-4dba-aa86-462dd61e31a3}
!endif
!ifndef IID_IZoneIdentifier
!define IID_IZoneIdentifier {cd45f185-1b21-48e2-967b-ead743a8914e}
${NSISCOMIFACEDECL}IZoneIdentifier GetId 3 (*i)i
${NSISCOMIFACEDECL}IZoneIdentifier SetId 4 (i)i
${NSISCOMIFACEDECL}IZoneIdentifier Remove 5 ()i
!endif
!insertmacro ComHlpr_CreateInProcInstance ${CLSID_PersistentZoneIdentifier} ${IID_IZoneIdentifier} r0 ""
${If} $0 P<> 0
    ${IZoneIdentifier::Remove} $0 '()'
    ${IUnknown::QueryInterface} $0 '("${IID_IPersistFile}",.r1)'
        ${If} $1 P<> 0
            ${IPersistFile::Save} $1 '("C:\mypath\myfile.txt",1)'
            ${IUnknown::Release} $1 ""
        ${EndIf}
    ${IUnknown::Release} $0 ""
${EndIf}
SectionEnd 
As a hack you can use the .ini function directly to just remove the zone:

System::Call 'KERNEL32::WritePrivateProfileString(t "ZoneTransfer", t "ZoneId", p 0, t "C:\test.txt:Zone.Identifier")' 
or the entire zone section:

System::Call 'KERNEL32::WritePrivateProfileString(t "ZoneTransfer", p 0, p 0, t "C:\test.txt:Zone.Identifier")' 
(Does NOT delete the stream unlike IZoneIdentifier::Remove)

or to delete any stream:

System::Call 'KERNEL32::DeleteFile(t"C:\test.txt:secret")' 
You cannot use the NSIS native instructions because they don't allow the stream suffix in paths.
mnga#
thanks, it works.

Originally Posted by Anders View Post
There is a documented API
where do you find this?
Anders#
Originally Posted by mnga View Post



where do you find this?
It is documented on MSDN. I just made the NSIS definitions for you.