Register DLL in code.

E

Erik

Hi.

Is there anyone who knows how to register a dll in code? I got a
application that copy files from a server into the local computer. Some
of the files are dll:s, an if it's already an older file in the target
directiory, the dll shuol be unregistred, and then registred, (and if it
don't replace any old file it just has to registred). Kan I use regasm
or gacutil or something in the code? It got to be proramatically, and
not manually afterwords.
I Use C#, with .net framework 3.5.
 
P

Pavel Minaev

Is there anyone who knows how to register a dll in code? I got a
application that copy files from a server into the local computer. Some
of the files are dll:s, an if it's already an older file in the target
directiory, the dll shuol be unregistred, and then registred, (and if it
don't replace any old file it just has to registred). Kan I use regasm
or gacutil or something in the code?

Please explain

1) What kind of DLLs? COM components, assemblies?
2) What do you mean by "register" (you mention gacutil and regasm, but
they do very different things).
 
P

Pavel Minaev

Is there anyone who knows how to register a dll in code? I got a
application that copy files from a server into the local computer. Some
of the files are dll:s, an if it's already an older file in the target
directiory, the dll shuol be unregistred, and then registred, (and if it
don't replace any old file it just has to registred). Kan I use regasm
or gacutil or something in the code?

Please explain

1) What kind of DLLs? COM components, assemblies?
2) What do you mean by "register" (you mention gacutil and regasm, but
they do very different things).
 
E

Erik

It's a ordinary DLL, that you normally woulld register with sersvr32. I
don't think gacutil is going to be needed here(but i,m not sure).
/Erik



Pavel Minaev skrev:
 
E

Erik

It's a ordinary DLL, that you normally woulld register with sersvr32. I
don't think gacutil is going to be needed here(but i,m not sure).
/Erik



Pavel Minaev skrev:
 
P

Pavel Minaev

It's a ordinary DLL, that you normally woulld register with sersvr32.

Do you mean "regsvr32" (there's no such thing as "sersvr32", at least
on my machine)?

If so, it's not really an "ordinary" DLL, it's a COM DLL (well not
100% necessary, but you very rarely see those that need that that
aren't COM).

It helps to understand what regsvr32 actually does, which really isn't
much. It:

1) Loads the DLL using LoadModule().
2) Finds an exported function in it that's named "DllRegisterServer"
using GetProcAddress(). Its signature is "STDAPI DllRegisterServer()"
- note that this implies stdcall, and HRESULT return type.
3) Invokes that function.

That is all. All actual registration is performed by DllRegisterServer
(). Obviously, you can do the above steps easily with P/Invoke just as
well.
 
P

Pavel Minaev

It's a ordinary DLL, that you normally woulld register with sersvr32.

Do you mean "regsvr32" (there's no such thing as "sersvr32", at least
on my machine)?

If so, it's not really an "ordinary" DLL, it's a COM DLL (well not
100% necessary, but you very rarely see those that need that that
aren't COM).

It helps to understand what regsvr32 actually does, which really isn't
much. It:

1) Loads the DLL using LoadModule().
2) Finds an exported function in it that's named "DllRegisterServer"
using GetProcAddress(). Its signature is "STDAPI DllRegisterServer()"
- note that this implies stdcall, and HRESULT return type.
3) Invokes that function.

That is all. All actual registration is performed by DllRegisterServer
(). Obviously, you can do the above steps easily with P/Invoke just as
well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top