Nexus.Client.Games.Morrowind.PluginManagement.Boss.StringArrayManualMarshaler.MarshalManagedToNative C# (CSharp) Method

MarshalManagedToNative() public method

Marshals the given string to a pointer.
public MarshalManagedToNative ( string ManagedObj ) : IntPtr
ManagedObj string The string to marshal.
return System.IntPtr
		public IntPtr MarshalManagedToNative(string[] ManagedObj)
		{
			string[] strStrings = (string[])ManagedObj;
			if (strStrings == null)
				m_ptrStringArray = IntPtr.Zero;
			else
			{
				m_intArraySize = strStrings.Length;
				IntPtr[] ptrStrings = new IntPtr[m_intArraySize];
				for (Int32 i = 0; i < m_intArraySize; i++)
					ptrStrings[i] = StringMarshaler.GetNullTerminatedStringPointer(strStrings[i], m_encEncoding);
				m_ptrStringArray = Marshal.AllocHGlobal(m_intArraySize * IntPtr.Size);
				Marshal.Copy(ptrStrings, 0, m_ptrStringArray, m_intArraySize);
			}
			return m_ptrStringArray;
		}

Usage Example

        /// <summary>
        /// Sets the load order of the plugins.
        /// </summary>
        /// <remarks>
        /// The returned list of sorted plugins will include plugins that were not
        /// included in the specified order list, if plugins exist that weren't included.
        /// The extra plugins will be apeended to the end of the given order.
        /// </remarks>
        /// <param name="p_strPlugins">The list of plugins in the desired order.</param>
        public void SetLoadOrder(string[] p_strPlugins)
        {
            string[] strSortedPlugins = p_strPlugins;
            UInt32   uintStatus       = 0;

            using (StringArrayManualMarshaler ammMarshaler = new StringArrayManualMarshaler("UTF8"))
                uintStatus = m_dlgSetLoadOrder(m_ptrBossDb, ammMarshaler.MarshalManagedToNative(StripPluginDirectory(strSortedPlugins)), Convert.ToUInt32(strSortedPlugins.Length));
            HandleStatusCode(uintStatus);
        }
All Usage Examples Of Nexus.Client.Games.Morrowind.PluginManagement.Boss.StringArrayManualMarshaler::MarshalManagedToNative