Пример #1
0
        public static string MarshalUtf8String(IntPtr ptr)
        {
            Utf8StringMarshaler marshaler = new Utf8StringMarshaler();
            var obj = marshaler.MarshalNativeToManaged(ptr);

            return(obj as string);
        }
Пример #2
0
        /// <summary>
        ///     计算md5
        /// </summary>
        /// <param name="input">需要计算md5的内容</param>
        /// <returns>返回的md5</returns>
        public static string GetMd5(string input)
        {
            var outStrPtr = nim_tool_get_md5(input);

            NimUtility.Utf8StringMarshaler marshaler = new NimUtility.Utf8StringMarshaler();
            var ret = marshaler.MarshalNativeToManaged(outStrPtr) as string;

            GlobalAPI.FreeStringBuffer(outStrPtr);
            return(ret);
        }
Пример #3
0
        /// <summary>
        ///     获取安装目录(SDK DLL所在的当前目录)
        /// </summary>
        /// <returns>返回的目录路径</returns>
        public static string GetCurModuleDir()
        {
            var outStrPtr = nim_tool_get_cur_module_dir();

            NimUtility.Utf8StringMarshaler marshaler = new NimUtility.Utf8StringMarshaler();
            var ret = marshaler.MarshalNativeToManaged(outStrPtr) as string;

            GlobalAPI.FreeStringBuffer(outStrPtr);
            return(ret);
        }
Пример #4
0
        /// <summary>
        ///     获取本地存储路径
        /// </summary>
        /// <returns>返回的目录路径</returns>
        public static string GetLocalAppDataDir()
        {
            var outStrPtr = nim_tool_get_local_appdata_dir();

            NimUtility.Utf8StringMarshaler marshaler = new NimUtility.Utf8StringMarshaler();
            var ret = marshaler.MarshalNativeToManaged(outStrPtr) as string;

            GlobalAPI.FreeStringBuffer(outStrPtr);
            return(ret);
        }
Пример #5
0
        /// <summary>
        ///     获取SDK里app account对应的具体类型的app data目录(如图片消息文件存放目录,语音消息文件存放目录等)
        /// </summary>
        /// <param name="appAccount">APP account。如果传入空字符串,则返回结果为空</param>
        /// <param name="appdataType">具体类型的app data。见NIMAppDataType定义</param>
        /// <returns>返回的目录路径(目录可能未生成,需要app自行判断是否已生成)</returns>
        public static string GetUserSpecificAppDataDir(string appAccount, NIMAppDataType appdataType)
        {
            var outStrPtr = nim_tool_get_user_specific_appdata_dir(appAccount, appdataType);

            NimUtility.Utf8StringMarshaler marshaler = new NimUtility.Utf8StringMarshaler();
            var ret = marshaler.MarshalNativeToManaged(outStrPtr) as string;

            GlobalAPI.FreeStringBuffer(outStrPtr);
            return(ret);
        }