MarshalNativeToManaged() public method

Marshals the given pointer to a string.
public MarshalNativeToManaged ( IntPtr pNativeData, Int32 p_intSize ) : string[]
pNativeData System.IntPtr The pointer to the data to marshal to a string.
p_intSize System.Int32 The length of the array to marshal.
return string[]
示例#1
0
        /// <summary>
        /// Marshal the given pointer to an array of plugins.
        /// </summary>
        /// <remarks>
        /// This adjusts the plugin paths to be in the format expected by the  mod manager.
        /// </remarks>
        /// <param name="p_ptrPluginArray">The pointer to the array of plugin names to marshal.</param>
        /// <param name="p_uintLength">the length of the array to marshal.</param>
        /// <returns>The array of plugins names pointed to by the given pointer.</returns>
        protected string[] MarshalPluginArray(IntPtr p_ptrPluginArray, UInt32 p_uintLength, bool p_booKeepRelativePath)
        {
            if (p_ptrPluginArray == IntPtr.Zero)
            {
                return(null);
            }
            string[] strPlugins = null;
            using (StringArrayManualMarshaler ammMarshaler = new StringArrayManualMarshaler("UTF8"))
                strPlugins = ammMarshaler.MarshalNativeToManaged(p_ptrPluginArray, Convert.ToInt32(p_uintLength));

            if (!p_booKeepRelativePath)
            {
                for (Int32 i = strPlugins.Length - 1; i >= 0; i--)
                {
                    strPlugins[i] = Path.Combine(GameMode.PluginDirectory, strPlugins[i]);
                }
            }
            return(strPlugins);
        }
		/// <summary>
		/// Marshal the given pointer to an array of plugins.
		/// </summary>
		/// <remarks>
		/// This adjusts the plugin paths to be in the format expected by the  mod manager.
		/// </remarks>
		/// <param name="p_ptrPluginArray">The pointer to the array of plugin names to marshal.</param>
		/// <param name="p_uintLength">the length of the array to marshal.</param>
		/// <returns>The array of plugins names pointed to by the given pointer.</returns>
		protected string[] MarshalPluginArray(IntPtr p_ptrPluginArray, UInt32 p_uintLength, bool p_booKeepRelativePath)
		{
			if (p_ptrPluginArray == IntPtr.Zero)
				return null;
			string[] strPlugins = null;
			using (StringArrayManualMarshaler ammMarshaler = new StringArrayManualMarshaler("UTF8"))
				strPlugins = ammMarshaler.MarshalNativeToManaged(p_ptrPluginArray, Convert.ToInt32(p_uintLength));

			if (!p_booKeepRelativePath)
				for (Int32 i = strPlugins.Length - 1; i >= 0; i--)
					strPlugins[i] = Path.Combine(GameMode.PluginDirectory, strPlugins[i]);
			return strPlugins;
		}