Esempio n. 1
0
        /// <summary>
        /// Returns a string containing the name of the selected stylus.
        /// </summary>
        /// <param name="index_I">indicates stylus type</param>
        /// <returns></returns>
        public static string GetStylusName(EWTICursorNameIndex index_I)
        {
            string stylusName = null;
            IntPtr buf        = WMemUtils.AllocUnmanagedBuf(MAX_STRING_SIZE);

            try {
                int size = (int)WNativeMethods.WTInfo(
                    (uint)index_I,
                    (uint)EWTICursorsIndex.CSR_NAME, buf);

                if (size < 1)
                {
                    throw new Exception("GetStylusName returned empty string.");
                }

                // Strip off final null character before marshalling.
                stylusName = WMemUtils.MarshalUnmanagedString(buf, size - 1);
            } catch (Exception ex) {
                throw new Exception("FAILED GetDeviceInfo: " + ex.ToString());
            }

            WMemUtils.FreeUnmanagedBuf(buf);

            return(stylusName);
        }
Esempio n. 2
0
        /// <summary>
        /// Returns a string containing device name.
        /// </summary>
        /// <returns></returns>
        public static String GetDeviceInfo()
        {
            string devInfo = null;
            IntPtr buf     = WMemUtils.AllocUnmanagedBuf(MAX_STRING_SIZE);

            try {
                int size = (int)WNativeMethods.WTInfo(
                    (uint)EWTICategoryIndex.WTI_DEVICES,
                    (uint)EWTIDevicesIndex.DVC_NAME, buf);

                if (size < 1)
                {
                    throw new Exception("GetDeviceInfo returned empty string.");
                }

                // Strip off final null character before marshalling.
                devInfo = WMemUtils.MarshalUnmanagedString(buf, size - 1);
            } catch (Exception ex) {
                throw new Exception("FAILED GetDeviceInfo: " + ex.ToString());
            }

            WMemUtils.FreeUnmanagedBuf(buf);
            return(devInfo);
        }