KeyboardIncantationMonitor.KeysIncantation tInc = m_KeyBackDoor.NewIncantation() as KeyboardIncantationMonitor.KeysIncantation; //KeyboardIncantationMonitor.KeysIncantation t = m_KeyBackDoor.NewIncantation() as KeyboardIncantationMonitor.KeysIncantation;
Keys是个什么?
//如果是个枚举
Enum.GetName(typeof(Keys), 1);//根据枚举值获得枚举名称
Enum.ToObject(typeof(Keys),1)//把一个枚举值转换为对应的枚举类型
Enum.Parse(typeof(Keys), "第一");//把字符串转换为对应的枚举类型
//如果只个类
typeof(Keys).GetField("FieldName")//根据字段名字获得字段值
//KeyboardIncantationMonitor.KeysIncantation t = m_KeyBackDoor.NewIncantation() as KeyboardIncantationMonitor.KeysIncantation;
//! 初始化这个暗号为:依次按下 <Esc>Bye<Enter>
tInc.AddKey(Keys.Escape);
tInc.AddKey(Keys.H);
tInc.AddKey(Keys.Y);
tInc.AddKey(Keys.E);
tInc.AddKey(Keys.Enter);
Keys k = (Keys)Enum.ToObject(typeof(Keys), (int)char[0]);
我这样写:
Keys keydown1 = (Keys)Enum.Parse(typeof(Keys), anwen[0]);编译无错,运行报错:未将对象引用设置到对象的实例
我这样写:
Keys keydown1 = (Keys)Enum.Parse(typeof(Keys), anwen[0].tostring());编译无错,运行报错:未将对象引用设置到对象的实例
我这样写:
Keys keydown1 = (Keys)Enum.Parse(typeof(Keys), anwen[0].tostring());编译无错,运行报错:未将对象引用设置到对象的实例
Keys keydown1 = (Keys)Enum.Parse(typeof(Keys), (int)anwen[0]);
Keys key=(Keys)'A'
就行