Search code examples
visual-c++nsis

how to add a include path to visual studio using nsis?


does anyone knows how can I make my nsis installer update visual studio include path with my sdk paths?


Solution

  • In next text I assume you use Visual Studio 2008.

    If you want to directly change the paths you must modify file %LOCALAPPDATA%\Microsoft\VisualStudio\9.0\VCComponents.dat.

    There is no need to write keys into registry, because directories are saved here.

    Use this NSIS code to add directory C:\YOUR DIRECTORY HERE into it:

    Function Write
    SetShellvarContext current
    ReadIniStr $0 "$LOCALAPPDATA\Microsoft\VisualStudio\9.0\VCComponents.dat" "VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories" "Include Dirs"
    WriteIniStr "$LOCALAPPDATA\Microsoft\VisualStudio\9.0\VCComponents.dat" "VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories" "Include Dirs" "$0;C:\YOUR DIRECTORY HERE"
    IfErrors Error NoError
    Error:
      MessageBox MB_OK "Cound not write!"
    NoError:
    FunctionEnd
    

    Be carefull with this because there are many options. Ini typically looks like this:

    [PLATFORM]

    Directories=Dir1;Dir2;$(VSVariable)path

    Above example writes directory into Win32 and Include files. See the picture to understand it.

    enter image description here

    For Visual Studio 2010 the format has been changed (to XML): http://blogs.msdn.com/b/vsproject/archive/2009/07/07/vc-directories.aspx