コード例 #1
0
        /// <summary>
        /// This function is used to read the value of MHL feature functions of String type.
        /// </summary>
        /// <param name="name">Name of the requested feature</param>
        /// <exception cref="System.ArgumentException">If exceptions are enabled, on failure exception is thrown with valid error message.</exception>
        /// <returns>String value for requested feature. Empty string on failure, if exceptions are not enabled.</returns>
        /// <remarks>On failure, use GetLastError() ot GetLastErrorMessage() for more information.</remarks>
        public string GetString(string name)
        {
            int length = MHLSRV._MHL_GetStringLen(loadedDrvHandle, name) + 1;

            if (throwsException && this.GetLastError() != 0)
            {
                throw new System.ArgumentException("Get STRING Failed " + name, "Error " + this.GetLastError().ToString() + "; " + this.GetLastErrorMessage());
            }
            if (length == 0)
            {
                return("");
            }

            string str = new string(' ', length);

            MHLSRV._MHL_GetString(loadedDrvHandle, name, str, length);
            if (throwsException && this.GetLastError() != 0)
            {
                throw new System.ArgumentException("Get STRING Failed " + name, "Error " + this.GetLastError().ToString() + "; " + this.GetLastErrorMessage());
            }

            // Remove NULL character, if present
            if (str[str.Length - 1] == '\0')
            {
                return(str.Remove(str.Length - 1, 1));
            }
            return(str);
        }
コード例 #2
0
        /// <summary>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new HotkeyHelper class.</summary>
        /// <remarks>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new MHLDriver class.</remarks>
        public String GetString(int handle, String name)
        {
            int length = MHLSRV._MHL_GetStringLen(handle, name) + 1;

            if (length == 0)
            {
                return("");
            }

            String str = new String(' ', length);

            MHLSRV._MHL_GetString(handle, name, str, length);

            // Remove NULL character, if present
            if (str[str.Length - 1] == '\0')
            {
                return(str.Remove(str.Length - 1, 1));
            }
            return(str);
        }