MarshalManagedToNative() public method

Marshals the given string to a pointer.
public MarshalManagedToNative ( string ManagedObj ) : IntPtr
ManagedObj string The string to marshal.
return System.IntPtr
示例#1
0
        /// <summary>
        /// Sorts the plugins.
        /// </summary>
        /// <param name="p_strPlugins">The plugins list.</param>
        /// <returns>The list of plugins sorted.</returns>
        public string[] SortPlugins(string[] p_strPlugins)
        {
            UInt32 uintStatus = 0;

            string[] strSortedPlugins = p_strPlugins;
            IntPtr   ptrPlugins       = IntPtr.Zero;
            UInt32   numPlugins;

            if (!String.IsNullOrEmpty(MasterlistPath))
            {
                if (!File.Exists(MasterlistPath))
                {
                    UpdateMasterlist();
                }
            }

            uintStatus = m_dlgSortPlugins(m_ptrSorterDb, out ptrPlugins, out numPlugins);

            if (uintStatus == 0)
            {
                UInt32 uintListLength = numPlugins;
                using (StringArrayManualMarshaler ammMarshaler = new StringArrayManualMarshaler("UTF8"))
                    uintStatus = m_dlgApplyLoadOrder(m_ptrSorterDb, ammMarshaler.MarshalManagedToNative(MarshalPluginArray(ptrPlugins, uintListLength, true)), uintListLength);

                if (uintStatus == 0)
                {
                    return(RemoveNonExistentPlugins(MarshalPluginArray(ptrPlugins, uintListLength, false)));
                }
            }

            return(null);
        }
示例#2
0
        /// <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_dlgApplyLoadOrder(m_ptrSorterDb, ammMarshaler.MarshalManagedToNative(StripPluginDirectory(strSortedPlugins)), Convert.ToUInt32(strSortedPlugins.Length));
            HandleStatusCode(uintStatus);
        }
		/// <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_dlgApplyLoadOrder(m_ptrSorterDb, ammMarshaler.MarshalManagedToNative(StripPluginDirectory(strSortedPlugins)), Convert.ToUInt32(strSortedPlugins.Length));
			HandleStatusCode(uintStatus);
		}
		/// <summary>
		/// Sorts the plugins.
		/// </summary>
		/// <param name="p_strPlugins">The plugins list.</param>
		/// <returns>The list of plugins sorted.</returns>
		public string[] SortPlugins(string[] p_strPlugins)
		{
			UInt32 uintStatus = 0;
			string[] strSortedPlugins = p_strPlugins;
			IntPtr ptrPlugins = IntPtr.Zero;
			UInt32 numPlugins;

			if (!String.IsNullOrEmpty(MasterlistPath))
				if (!File.Exists(MasterlistPath))
					UpdateMasterlist();

			uintStatus = m_dlgSortPlugins(m_ptrSorterDb, out ptrPlugins, out numPlugins);

			if (uintStatus == 0)
			{
				UInt32 uintListLength = numPlugins;
				using (StringArrayManualMarshaler ammMarshaler = new StringArrayManualMarshaler("UTF8"))
					uintStatus = m_dlgApplyLoadOrder(m_ptrSorterDb, ammMarshaler.MarshalManagedToNative(MarshalPluginArray(ptrPlugins, uintListLength, true)), uintListLength);

				if (uintStatus == 0)
					return RemoveNonExistentPlugins(MarshalPluginArray(ptrPlugins, uintListLength, false));
			}

			return null;
		}