From: Perro Flaco on
Hi!

I've read that you can use
"CMP_WaitNoPendingInstallEvents" to wait until all drivers are loading
and initializing. I've tried to use it in my C++ program, but without
any success.

Sometime ago, a guy called "No Never" told me this:

-------------------------------------------------------------------------------------------------------------------------------------------
Hello Perro,

In your namespace include:
++++++++++++++++++++++++++
[DllImport("cfgmgr32.dll", EntryPoint =
"CMP_WaitNoPendingInstallEvents",
CharSet = Unicode)]
DWORD CM_WaitNoPendingInstallEvents(DWORD);
public __gc __interface IProcessInitializer;
++++++++++++++++++++++++++
somewhere in your Program (e.g. a timer) you can call:
++++++++++++++++++++++++++
switch (FirstReboot::CM_WaitNoPendingInstallEvents(dwTimeout))
{
case WAIT_OBJECT_0:
//Form1::Text = S"There are no pending installation activities";
break;
case WAIT_TIMEOUT :
//Form1::Text = S"The time-out interval elapsed, and installation
activities
are still pending";
break;
case WAIT_FAILED :
//Form1::Text = S"The function failed. Call GetLastError for additional
error information.";
break;
++++++++++++++++++++++++++

Don't forget that the function can return true for a short duration
despite
pending installation processes.
Best to test the function with an uninstalled USB-Stick.

Regards, Wolfgang

P.S. EntryPoint= CMP_... Function is CM_...
-------------------------------------------------------------------------------------------------------------------------------------------


But I'm not so good with C++, so I've got a couple of questions. What
is "dllimport"? And "public __gc __interface IProcessInitializer"?
Isn't there any other "easy" way to do this? I've tried to do the
following, but without any success:

typedef DWORD (*myfunc)(DWORD);

int _tmain(int argc, _TCHAR* argv[])
{
myfunc _myfunc;
HINSTANCE hInstLibrary = LoadLibrary(L"cfgmgr32.dll");

if ( hInstLibrary==NULL )
FreeLibrary(hInstLibrary);

_myfunc = (myfunc)GetProcAddress(hInstLibrary,
"CMP_WaitNoPendingInstallEvents");

if ( _myfunc=NULL )
FreeLibrary(hInstLibrary);

switch (_myfunc(INFINITE)) {
....
}

FreeLibrary(hInstLibrary);
}

It fails when it tries to execute "_myfunc".

Any help would be great!
Thanks very much!