//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// NativeLib DLL (for DotNetHelpers) | C+- (SysRoutine) | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace CommonHelpers {

//**************************************************************************************************
/// <summary>
/// Special properties for "HShellLinkProperties" class implementation
/// </summary>
[StructLayout(LayoutKind.Sequential)]
partial struct NLShellLinkSpecialPropsStruct
{
   public bool RunAsAdministrator;
} // NLShellLinkSpecialPropsStruct
//**************************************************************************************************


//**************************************************************************************************
/// <summary>
/// "ShellLinkProperties" class native support for SysUtils-code-package (NativeLib.dll)
/// </summary>
static class SHLPropsNL {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[DllImport( "NativeLib.dll", EntryPoint="SHLProps_CreateInstance", ExactSpelling=true )]
[HNLibLastError]
public static extern IntPtr CreateInstance( string ciTag );

[DllImport( "NativeLib.dll", EntryPoint="SHLProps_Release", ExactSpelling=true )]
public static extern void Release( string ciTag,
   [HOptional] IntPtr instancePtr );

//==================================================================================================

[DllImport( "NativeLib.dll", EntryPoint="SHLProps_Load",
            ExactSpelling=true, CharSet=CharSet.Unicode )]
[HNLibLastError]
public static extern bool Load( string ciTag,
   IntPtr instancePtr,
   string filePath,
   out NLShellLinkSpecialPropsStruct specialProps );

//--------------------------------------------------------------------------------------------------

[DllImport( "NativeLib.dll", EntryPoint="SHLProps_Save",
            ExactSpelling=true, CharSet=CharSet.Unicode )]
[HNLibLastError]
public static extern bool Save( string ciTag,
   IntPtr instancePtr,
   string filePath );

[DllImport( "NativeLib.dll", EntryPoint="SHLProps_SaveEx",
            ExactSpelling=true, CharSet=CharSet.Unicode )]
[HNLibLastError]
public static extern bool SaveEx( string ciTag,
   IntPtr instancePtr,
   string filePath,
   [HRO] ref NLShellLinkSpecialPropsStruct specialProps );

//==================================================================================================

[DllImport( "NativeLib.dll", EntryPoint="SHLProps_GetPath",
            ExactSpelling=true, CharSet=CharSet.Unicode )]
[HNLibLastError][HNeedsFree]
public static extern IntPtr GetPath( string ciTag,
   IntPtr instancePtr );

[DllImport( "NativeLib.dll", EntryPoint="SHLProps_SetPath",
            ExactSpelling=true, CharSet=CharSet.Unicode )]
[HNLibLastError]
public static extern bool SetPath( string ciTag,
   IntPtr instancePtr,
   string value );

//--------------------------------------------------------------------------------------------------

[DllImport( "NativeLib.dll", EntryPoint="SHLProps_GetArguments",
            ExactSpelling=true, CharSet=CharSet.Unicode )]
[HNLibLastError][HNeedsFree]
public static extern IntPtr GetArguments( string ciTag,
   IntPtr instancePtr );

[DllImport( "NativeLib.dll", EntryPoint="SHLProps_SetArguments",
            ExactSpelling=true, CharSet=CharSet.Unicode )]
[HNLibLastError]
public static extern bool SetArguments( string ciTag,
   IntPtr instancePtr,
   string value );

//--------------------------------------------------------------------------------------------------

[DllImport( "NativeLib.dll", EntryPoint="SHLProps_GetDescription",
            ExactSpelling=true, CharSet=CharSet.Unicode )]
[HNLibLastError][HNeedsFree]
public static extern IntPtr GetDescription( string ciTag,
   IntPtr instancePtr );

[DllImport( "NativeLib.dll", EntryPoint="SHLProps_SetDescription",
            ExactSpelling=true, CharSet=CharSet.Unicode )]
[HNLibLastError]
public static extern bool SetDescription( string ciTag,
   IntPtr instancePtr,
   string value );

//--------------------------------------------------------------------------------------------------

[DllImport( "NativeLib.dll", EntryPoint="SHLProps_GetHotkey",
            ExactSpelling=true, CharSet=CharSet.Unicode )]
[HNLibLastError]
public static extern bool GetHotkey( string ciTag,
   IntPtr instancePtr,
   out UInt16 value );

[DllImport( "NativeLib.dll", EntryPoint="SHLProps_SetHotkey",
            ExactSpelling=true, CharSet=CharSet.Unicode )]
[HNLibLastError]
public static extern bool SetHotkey( string ciTag,
   IntPtr instancePtr,
   UInt16 value );

//--------------------------------------------------------------------------------------------------

[DllImport( "NativeLib.dll", EntryPoint="SHLProps_GetDisplayName",
            ExactSpelling=true, CharSet=CharSet.Unicode )]
[HNLibLastError][HNeedsFree]
public static extern IntPtr GetDisplayName( string ciTag,
   IntPtr instancePtr );

[DllImport( "NativeLib.dll", EntryPoint="SHLProps_SetDisplayName",
            ExactSpelling=true, CharSet=CharSet.Unicode )]
[HNLibLastError]
public static extern bool SetDisplayName( string ciTag,
   IntPtr instancePtr,
   string value );

//--------------------------------------------------------------------------------------------------

[DllImport( "NativeLib.dll", EntryPoint="SHLProps_GetShowCmd",
            ExactSpelling=true, CharSet=CharSet.Unicode )]
[HNLibLastError]
public static extern bool GetShowCmd( string ciTag,
   IntPtr instancePtr,
   out Int32 value );

[DllImport( "NativeLib.dll", EntryPoint="SHLProps_SetShowCmd",
            ExactSpelling=true, CharSet=CharSet.Unicode )]
[HNLibLastError]
public static extern bool SetShowCmd( string ciTag,
   IntPtr instancePtr,
   Int32 value );

//--------------------------------------------------------------------------------------------------

[DllImport( "NativeLib.dll", EntryPoint="SHLProps_GetWorkingDirectory",
            ExactSpelling=true, CharSet=CharSet.Unicode )]
[HNLibLastError][HNeedsFree]
public static extern IntPtr GetWorkingDirectory( string ciTag,
   IntPtr instancePtr );

[DllImport( "NativeLib.dll", EntryPoint="SHLProps_SetWorkingDirectory",
            ExactSpelling=true, CharSet=CharSet.Unicode )]
[HNLibLastError]
public static extern bool SetWorkingDirectory( string ciTag,
   IntPtr instancePtr,
   string value );

//--------------------------------------------------------------------------------------------------

[DllImport( "NativeLib.dll", EntryPoint="SHLProps_GetIconLocation",
            ExactSpelling=true, CharSet=CharSet.Unicode )]
[HNLibLastError][HNeedsFree]
public static extern IntPtr GetIconLocation( string ciTag,
   IntPtr instancePtr,
   out Int32 index );

[DllImport( "NativeLib.dll", EntryPoint="SHLProps_SetIconLocation",
            ExactSpelling=true, CharSet=CharSet.Unicode )]
[HNLibLastError]
public static extern bool SetIconLocation( string ciTag,
   IntPtr instancePtr,
   string path,
   int index );

//==================================================================================================
/*
[DllImport( "NativeLib.dll", EntryPoint="NLib_",
            ExactSpelling=true, CharSet=CharSet.Unicode )]
[HNLibLastError]
public static extern ( string ciTag,
);
*/
//==================================================================================================

static SHLPropsNL()
{
   HNativeLib.VerifyInitialized();
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // SHLPropsNL
//**************************************************************************************************

} // CommonHelpers
