列举到后,怎样卸载(或禁止运行等操作)相应的应用程序呢?如果应用程序没有在系统中注册怎样用程序禁止它运行呢?请大家给出实现方法~~谢谢了``:)

解决方案 »

  1.   


    int _tmain(int argc, _TCHAR* argv[])
    {
    HKEY hRoot;
    if ( ERROR_SUCCESS != RegOpenKey( HKEY_LOCAL_MACHINE,
    _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion")
    _T("\\App Management\\ARPCache"), &hRoot ) )
    {
    cout << "Can not load registry!" << endl;
    return -1;
    }
    DWORD dwIndex = 0;
    DWORD dwBufLen = MAX_PATH;
    LPTSTR lpName = (LPTSTR)malloc( dwBufLen );
    while( true )
    {
    DWORD dwNameLen = dwBufLen;
    LONG lr = RegEnumKeyEx( hRoot, dwIndex, lpName,
    &dwNameLen, NULL, NULL, NULL, NULL );
    if ( lr == ERROR_MORE_DATA )
    {
    dwBufLen *= 2;
    realloc( lpName, dwBufLen );
    }
    else if ( lr == ERROR_NO_MORE_ITEMS )
    {
    break;
    }
    else if ( lr == ERROR_SUCCESS )
    {
    cout << dwIndex + 1 << ". ";
    #ifdef _UNICODE
    int nOutLen = WideCharToMultiByte( CP_ACP, 0, lpName,
    (int)dwNameLen, NULL, 0, NULL, NULL );
    if ( nOutLen != 0 )
    {
    LPSTR lpOut = (LPSTR)malloc( nOutLen + 1 );
    nOutLen = WideCharToMultiByte( CP_ACP, 0, lpName,
    (int)dwNameLen, lpOut, nOutLen + 1, NULL, NULL );
    lpOut[nOutLen] = '\0';
    if ( nOutLen != 0 )
    {
    cout << lpOut << endl;
    }
    }
    #else
    cout << lpName << endl;
    #endif
    dwIndex++;
    }
    else
    {
    cout << "Enum faild!" << endl;
    }
    }
    free( lpName );
    RegCloseKey( hRoot ); system( "pause" );
    return 0;
    }