void _test(CIMClient & client) { try { // empty property list Array<CIMInstance> x= client.enumerateInstances(PROVIDERNAMESPACE,CLASSNAME); _checkResult(x); // property list leaving "Name" key out... Array<CIMName> n; n.append("Number"); n.append("Flag"); CIMPropertyList pl(n); Array<CIMInstance> y= client.enumerateInstances( PROVIDERNAMESPACE, CLASSNAME, true, // deepInheritance true, // localOnly false, // includeQualifiers false, // includeClassOrigin pl); // property list _checkResult(y); } catch (Exception & e) { cerr << "test failed: " << e.getMessage () << endl; exit(-1); } cout << "+++++ test completed successfully" << endl; }
DIKeyboard::DIKeyboard( HINSTANCE hInstance, HWND hWnd ) { HRESULT hr = DirectInput8Create( hInstance, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&mLpdi, NULL ) ; if( !_checkResult(hr) ) return ; hr = mLpdi->CreateDevice( GUID_SysKeyboard, &mKeyboard, NULL ) ; if( !_checkResult(hr) ) return ; hr = mKeyboard->SetDataFormat( &c_dfDIKeyboard ) ; if( !_checkResult(hr) ) return ; hr = mKeyboard->SetCooperativeLevel( hWnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE ) ; if( !_checkResult(hr) ) return ; }
bool QtCesterConnection::copyFileToDevice(const QString &localSource, const QString &deviceDest, bool failIfExists) { debugOutput( qPrintable(QString::fromLatin1("Copy File: %1 -> %2").arg(localSource).arg(deviceDest)),0); QFile localFile(localSource); QFileInfo info(localSource); if (!localFile.exists() || !localFile.open(QIODevice::ReadOnly)) { qDebug() << "Could not open File!"; return false; } QTcpSocket* socket = 0; if (!_initCommand(socket, COMMAND_CREATE_FILE)) { END_ERROR(socket, "Could not initialized command"); } CreateFileOptions option; strcpy(option.fileName, qPrintable(deviceDest)); #ifdef Q_OS_WIN // Copy FileTime for update verification FILETIME creationTime, accessTime, writeTime; HANDLE localHandle = CreateFile(localSource.utf16(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); if (localHandle != INVALID_HANDLE_VALUE) { if (GetFileTime(localHandle, &creationTime, &accessTime, &writeTime)) { LocalFileTimeToFileTime(&writeTime, &writeTime); option.fileTime = writeTime; } CloseHandle(localHandle); } DWORD attributes = GetFileAttributes(localSource.utf16()); if (attributes != -1 ) option.fileAttributes = attributes; #endif option.fileSize = info.size(); option.overwriteExisting = !failIfExists; if (!_sendData(socket, (char*) &option, sizeof(option))) { END_ERROR(socket, "Could not send options..."); } if (!_checkResult(socket)) { END_ERROR(socket, "Server did not accept configuration"); } int bytesWritten = 0; const int bufferSize = 1024; QByteArray data; while (bytesWritten < option.fileSize) { data = localFile.read(bufferSize); bytesWritten += data.size(); #ifdef Q_OS_WIN wprintf( L"%s -> %s (%d / %d) %d %%\r", localSource.utf16() , deviceDest.utf16(), bytesWritten , option.fileSize, (100*bytesWritten)/option.fileSize ); #endif if (!_sendData(socket, data.constData(), data.size())) { END_ERROR(socket, "Error during file transfer"); } if (!_checkResult(socket)) { END_ERROR(socket, "Got some strange result"); } } #ifdef Q_OS_WIN wprintf( L"\n"); // We should jump to next line... #endif if (bytesWritten != option.fileSize) { END_ERROR(socket, "Did not send sufficient data"); } _freeSocket(socket); return true; }