【发布时间】:2011-02-10 18:34:05
【问题描述】:
我正在尝试的是在不实际打开数据库的情况下访问 MS Access 属性。
这里有一些代码可以更好地理解:
var processStartInfo = new ProcessStartInfo(args[0])
{
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true
};
Process.Start(processStartInfo);
application = (Access.Application)Marshal.GetActiveObject("Access.Application");
dao.Property allowByPassKeyProperty = null;
foreach (dao.Property property in application.CurrentDb().Properties)
{
if (property.Name == "AllowByPassKey")
{
allowByPassKeyProperty = property;
break;
}
}
我的问题是,在这种情况下,我打开数据库以查找属性 (application.CurrentDb().Properties) 并启动 MS Access 启动内容。
我想避免所有启动的东西,只为属性注入正确的值。
是否可以通过属性,也许像这样使用反射和后期绑定:http://www.codeproject.com/KB/database/mdbcompact_latebind.aspx?
或者还有其他选择可以实现我想要的吗?
【问题讨论】:
-
可以使用 API 来模拟 Shift 键,这会停止启动的东西,但我不知道这将如何适应 c#:mvps.org/access/api/api0068.htm
-
@Remou。是的,这是可能的,但没有任何好处,因为我想要的是一个可以激活和停用旁路键(shift)的程序。一旦我将其停用,模拟将无济于事。
标签: c# ms-access reflection late-binding