Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们的软件需要能够在运行时注册一个 ocx。OCX 位于应用程序的程序文件目录中。我发现如果我以管理员身份手动启动 cmd 行并运行命令一切正常,但是如果我以管理员身份启动我们的应用程序并让应用程序尝试注册 ocx,它会失败。我还注意到,当我从构建目录运行该应用程序时,它能够成功运行 regsvr32,大概是因为我拥有构建目录。我仍然必须以管理员身份运行。任何人都有任何想法可能会出现什么问题?
谢谢,布赖恩
答案是首先,我很草率,其次,传递给 regsvr32 的命令行参数需要用双引号引起来。我从来没有想过,因为我是这样编写代码的:
string args = "/s " + Path.Combine(MP_xxxx_DIR.FullName, MAP_POINT_OCX) ;
什么时候应该看起来像:
string args = "/s " + "\"" + Path.Combine(MP_xxxx_DIR.FullName, MAP_POINT_OCX) + "\"";
希望这对其他人有帮助:)