
HOWTO: Install/copy COM file, and register it.
Hi,
I'm having difficulty trying to register a COM object. Basically what
I'm doing is writing a psuedo installer, that copies new/updated files
to a previous installation, then registers any of those files that
support self-registration.
Everything works fine, except that I get a sharing violation when I try
to call LoadLibrary() on the COM file in question. I used CopyFile() to
copy the file, does it only queue the file for copying? If so is there
a way to flush the queue.
My registration code is correct, I snagged it straight from the regsvr32
example in MSDN. If I register a file that my program has not touched,
it works fine. I even tried spawning off regsvr32, and got the same
result. And, if I run regsvr32 on the file while my program is still
active but after the copy, it fails. But as soon as my program exits,
it will succeed. So basically I've got it narrowed down to the copy.
Suggestions? Insights? Examples?
Here are (basically) the steps I'm taking.
.
.
.
CopyFile(source, destination, false); // most likely the culprit
if (destinationIsSelfRegistering)
{
if (! FAILED( OleInitialize(NULL) ) )
{
HINSTANCE hLib = LoadLibrary(destination);
if (hLib != NULL)
{
HRESULT (STDAPICALLTYPE * lpDllEntryPoint)(void);
(FARPROC&)lpDllEntryPoint = GetProcAddress(hLib,
"DllRegisterServer");
if (lpDllEntryPoint != NULL)
{
(*lpDllEntryPoint)();
}
FreeLibrary(hLib);
}
OleUninitialize();
}
Quote:
}
.
.
.
Help.
Matt