如何从 C++ 程序运行 regasm.exe? [英] How to run regasm.exe from a C++ program?

查看:32
本文介绍了如何从 C++ 程序运行 regasm.exe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个运行 regasm.exe 的程序,以编程方式创建 tlb 文件.

I want to write a program which runs regasm.exe to create a tlb file programatically.

我该怎么做??

非常感谢您的帮助...

Ur help is greatly appreciated...

提前致谢.

推荐答案

您必须使用 CreateProcess() 函数来运行命令行,例如fullPathToRegasm/somekeys filename".

You have to use the CreateProcess() function to run the command line like "fullPathToRegasm /somekeys filename".

主要问题是检测 regasm 位置 - 为此使用 GetCORSystemDirectory() 函数.先用LoadLibrary()加载mscoree.dll,然后调用GetProcAddress()定位GetCORSystemDirectory()函数,再调用该函数.

The main problem is to detect the regasm location - use GetCORSystemDirectory() function for that. First use first LoadLibrary() to load the mscoree.dll, then call GetProcAddress() to locate the GetCORSystemDirectory() function, then call the function.

这将使您获得 .NET 安装的根目录.regasm 通常位于任何给定机器上安装根目录的同一子路径中,因此您可以安全地将检测到的根目录与子路径组合在一起,这将是一个有效的 regasm 位置.

This will get you the root of .NET installation. regasm is usually located in the same subpath of the installation root on any given machine so you can safely combine the detected root with the subpath and this will be a valid regasm location.

这篇关于如何从 C++ 程序运行 regasm.exe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆