来自设计环境的AppConfig

时间:2018-05-19 00:11:42

标签: c# app-config

尝试从组件的调试环境中获取appconfig路径,但是当我构建解决方案时,我仍然从这里得到nulls错误是vs2017。任何帮助表示感谢。

/// <summary>
/// Sends Unicode (UTF16) string to foreground window.
/// </summary>
/// <param name="inputString">String to be sent to foreground window.</param>
internal static void Send(string inputString)
{
    if (string.IsNullOrEmpty(inputString))
    { return; }

    char[] chars = inputString.ToCharArray();
    int len = chars.Length;
    INPUT[] pInputs = new INPUT[len * 2];

    UInt32 ExtraInfo = GetMessageExtraInfo();

    int i = 0, idx = 0;
    while (i < len)
    {
        UInt16 ch = chars[i++];

        if ((ch < 0xD800) || (ch > 0xDFFF))
        {
            pInputs[idx] = new INPUT();
            pInputs[idx].type = INPUT_KEYBOARD;
            pInputs[idx].ki.wVk = 0;
            pInputs[idx].ki.wScan = ch;
            pInputs[idx].ki.dwFlags = KEYEVENTF_UNICODE;
            pInputs[idx].ki.time = 0;
            pInputs[idx].ki.dwExtraInfo = ExtraInfo;
            ++idx;

            pInputs[idx] = new INPUT();
            pInputs[idx].type = INPUT_KEYBOARD;
            pInputs[idx].ki.wVk = 0;
            pInputs[idx].ki.wScan = ch;
            pInputs[idx].ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP;
            pInputs[idx].ki.time = 0;
            pInputs[idx].ki.dwExtraInfo = ExtraInfo;
            ++idx;
        }
        else
        {
            UInt16 ch2 = chars[i++];

            pInputs[idx] = new INPUT();
            pInputs[idx].type = INPUT_KEYBOARD;
            pInputs[idx].ki.wVk = 0;
            pInputs[idx].ki.wScan = ch;
            pInputs[idx].ki.dwFlags = KEYEVENTF_UNICODE;
            pInputs[idx].ki.time = 0;
            pInputs[idx].ki.dwExtraInfo = ExtraInfo;
            ++idx;

            pInputs[idx] = new INPUT();
            pInputs[idx].type = INPUT_KEYBOARD;
            pInputs[idx].ki.wVk = 0;
            pInputs[idx].ki.wScan = ch2;
            pInputs[idx].ki.dwFlags = KEYEVENTF_UNICODE;
            pInputs[idx].ki.time = 0;
            pInputs[idx].ki.dwExtraInfo = ExtraInfo;
            ++idx;

            pInputs[idx] = new INPUT();
            pInputs[idx].type = INPUT_KEYBOARD;
            pInputs[idx].ki.wVk = 0;
            pInputs[idx].ki.wScan = ch;
            pInputs[idx].ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP;
            pInputs[idx].ki.time = 0;
            pInputs[idx].ki.dwExtraInfo = ExtraInfo;
            ++idx;

            pInputs[idx] = new INPUT();
            pInputs[idx].type = INPUT_KEYBOARD;
            pInputs[idx].ki.wVk = 0;
            pInputs[idx].ki.wScan = ch2;
            pInputs[idx].ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP;
            pInputs[idx].ki.time = 0;
            pInputs[idx].ki.dwExtraInfo = ExtraInfo;
            ++idx;
        }
    }

    uint nSent = SendInput((uint)pInputs.Length, pInputs, Marshal.SizeOf(typeof(INPUT)));
    if (nSent == 0)
    {
        Debug.WriteLine("SendInput error " + GetLastError().ToString());
    }
}

0 个答案:

没有答案