다음을 통해 공유


디바이스 설치 애플리케이션이 진행 중인 디바이스 설치를 확인하는 방법

디바이스 설치 애플리케이션은 설치를 수행하기 전에 다른 디바이스 설치 작업이 진행 중인지 여부를 결정해야 합니다. 이 결정을 내리기 위해 디바이스 설치 애플리케이션은 일반적으로 시간 제한 값이 0인 CMP_WaitNoPendingInstallEvents 호출해야 합니다. 이 함수의 반환 값이 다른 설치 작업이 보류 중임을 나타내는 경우(예: 새 하드웨어 발견 마법사가 활성 상태일 수 있음) 디바이스 설치 애플리케이션이 종료되어야 합니다.

디바이스 설치 애플리케이션CMP_WaitNoPendingInstallEvents 지원하지 않는 플랫폼과 호환되도록 하려면 애플리케이션에 다음 코드가 포함되어야 합니다.

BOOL
IsDeviceInstallInProgress (VOID)
{
    HMODULE hModule;
    CMP_WAITNOPENDINGINSTALLEVENTS_PROC pCMP_WaitNoPendingInstallEvents;

    hModule = GetModuleHandle(TEXT("setupapi.dll"));
    if(!hModule)
    {
        // Should never happen since we're linked to SetupAPI, but...
        return FALSE;
    }

    pCMP_WaitNoPendingInstallEvents =
        (CMP_WAITNOPENDINGINSTALLEVENTS_PROC)GetProcAddress(hModule,
                                             "CMP_WaitNoPendingInstallEvents");
    if(!pCMP_WaitNoPendingInstallEvents)
    {
        // We're running on a release of the operating system that doesn't supply this function.
        // Trust the operating system to suppress AutoRun when appropriate.
        return FALSE;
    }
    return (pCMP_WaitNoPendingInstallEvents(0) == WAIT_TIMEOUT);
}

int
__cdecl
_tmain(IN int argc, IN PTCHAR argv[])
{
    if(IsDeviceInstallInProgress()) {
        //
        // We don't want to start right now.  Instead, our
        // device co-installer will invoke this application
        // (if necessary) during finish-install processing.
        //
        return -1;
    }
    .
    .
}

이 코드의 사용은 플랫폼이 CMP_WaitNoPendingInstallEvents 지원하지 않는 경우 설치 작업이 진행 중인 경우 플랫폼이 AutoRun을 시작하지 않는다는 전제를 기반으로 합니다.

이 코드의 샘플 사용법은 WDK(Windows 드라이버 키트) 의 src\general\toaster 하위 디렉터리에서 토스터 설치 패키지를 참조하세요.