I want to write a program which runs regasm.exe to create a tlb file programatically.
How can I do this??
Ur help is greatly appreciated...
Thanks in advance.
I want to write a program which runs regasm.exe to create a tlb file programatically.
How can I do this??
Ur help is greatly appreciated...
Thanks in advance.
You have to use the CreateProcess() function to run the command line like "fullPathToRegasm /somekeys filename".
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.
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.
Since NET is a side-by-side installation you might have multiple versions of
regasm.exe
in your system, and similarly some version are just updates so you might have it missing from some locations you would expect finding.I have spent hours searching for the best way to do this, since there are also several atempts to get to the right point (registry, unmanaged code, Environment, etc) which greatly varies on the NET version. And each Windows also version brings his own NET version.
None of those above were stable enough across systems for my taste, so I found my own way: just searching all available
regasm.exe
files and check which is the newest version. As simple as that.It might be a matter of opinion, but if you felt my answer could have higher success, thumbs up!!