CString PropVariantToString(const PROPVARIANT& propVar) { USES_CONVERSION; CString sPropValue; variant_t varPropValue; CStdString val; if (SUCCEEDED(VariantChangeType(&varPropValue, (VARIANTARG*)&propVar, VARIANT_LOCALBOOL, VT_BSTR))) sPropValue = varPropValue.bstrVal; else { //VT_BLOB and VT_LPSTR are uncommon co-ercions switch(propVar.vt) { case VT_BLOB: sPropValue.Format(_T("%s"), CW2T((LPCWSTR)propVar.blob.pBlobData).operator LPWSTR()); break; case VT_LPSTR: val = MultiByteSupport::ACPToWide(propVar.pszVal); sPropValue = val; break; case VT_LPWSTR: sPropValue.Format(_T("%s"), CW2T(propVar.pwszVal).operator LPWSTR()); break; case VT_FILETIME: sPropValue = FiletimeAsString(propVar.filetime); break; } } return sPropValue; }
VARIANT CBoxEncoding::StrToBin(VARIANT& var, VARIANT &varCP) { CBoxBinPtr varString(var, VT_BSTR); UINT nCodePage; if(varCP.vt == VT_ERROR) nCodePage = _AtlGetConversionACP(); else { CComVariant varTemp; varTemp.ChangeType(VT_I4, &varCP); if(varTemp.vt == VT_I4) nCodePage = varTemp.lVal; else AfxThrowOleException(TYPE_E_TYPEMISMATCH); } int _nTempCount = ::WideCharToMultiByte(nCodePage, 0, LPWSTR(varString.m_pData), varString.m_nSize, NULL, 0, NULL, NULL); CBoxBinPtr varPtr(_nTempCount); ::WideCharToMultiByte(nCodePage, 0, LPWSTR(varString.m_pData), varString.m_nSize, varPtr, _nTempCount, NULL, NULL); return varPtr; }
void PropertyPageHandler_BaseReloc::OnInitDialog() { // Insert Tabs TCITEM item; for (int i = 0; i < m_PEReaderWriter.getNoOfBaseRelocationTables(); ++i) { item.mask = TCIF_TEXT; item.pszText = LPWSTR(_wcsdup(wstring(L"Table " + DWORD_toString(i + 1)).c_str())); TabCtrl_InsertItem(m_hTabsBaseReloc, i, &item); free(item.pszText); } // Insert ListView columns LV_COLUMN column; ZeroMemory(&column, sizeof(LV_COLUMN)); for (size_t i = 0; i < ARRAYSIZE(szGenericColumnText); ++i) { column.mask = LVCF_TEXT; column.pszText = szGenericColumnText[i]; ListView_InsertColumn(m_hListViewBaseRelocTable, i, &column); } tabsBaseRelocations_OnTabChanged(m_hWnd, 0); }
bool CertStore::add( const QSslCertificate &cert, const QString &card ) { if( !d->s ) return false; SslCertificate c( cert ); DWORD keyCode = c.keyUsage().contains( SslCertificate::NonRepudiation ) ? AT_SIGNATURE : AT_KEYEXCHANGE; QString cardStr = card + (keyCode == AT_SIGNATURE ? "_SIG" : "_AUT" ); cardStr = QCryptographicHash::hash( cardStr.toUtf8(), QCryptographicHash::Md5 ).toHex(); PCCERT_CONTEXT context = d->certContext( cert ); QString str = QString( "%1 %2" ) .arg( keyCode == AT_SIGNATURE ? "Signature" : "Authentication" ) .arg( c.toString( "SN, GN" ).toUpper() ); CRYPT_DATA_BLOB DataBlob = { (str.length() + 1) * sizeof(QChar), (BYTE*)str.utf16() }; CertSetCertificateContextProperty( context, CERT_FRIENDLY_NAME_PROP_ID, 0, &DataBlob ); CRYPT_KEY_PROV_INFO KeyProvInfo = { LPWSTR(cardStr.utf16()), L"Microsoft Base Smart Card Crypto Provider", PROV_RSA_FULL, 0, 0, 0, keyCode }; CertSetCertificateContextProperty( context, CERT_KEY_PROV_INFO_PROP_ID, 0, &KeyProvInfo ); bool result = CertAddCertificateContextToStore( d->s, context, CERT_STORE_ADD_REPLACE_EXISTING, 0 ); CertFreeCertificateContext( context ); return result; }
void LoadBitmaps() { //Getting the address(es) of bitmaps OPENFILENAME ofn; char szFile[10000];//Large allocation for selection of many files ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = NULL; ofn.lpstrFile = LPWSTR(szFile); ofn.lpstrFile[0] = '\0'; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFilter = L"Bitmap file (*.bmp)\0*.bmp\0\0";//Filter to only bitmap files ofn.nFilterIndex = 1; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER; GetOpenFileName(&ofn); //Newly loaded bitmaps will replace existing ones for (unsigned int i = 0; i < bitmapsToDraw.size(); i++) { DeleteObject(bitmapsToDraw[i]); } bitmapsToDraw.clear(); //To break up the files into each individual name wchar_t* _wsfileStr = ofn.lpstrFile; std::wstring directory = _wsfileStr; _wsfileStr += (directory.length() + 1); //Used if one file is selected if (!*_wsfileStr) { fileNamesBit.push(ofn.lpstrFile); threads.push_back(std::thread(Load)); } else { //Continues to go through until all bitmaps have been loaded while (*_wsfileStr) { std::wstring filename = _wsfileStr; _wsfileStr += (filename.length() + 1); fileNamesBit.push(filename); } //Only necessary number of threads created for (unsigned int i = 0; i < _iNumThreads; i++) { threads.push_back(std::thread(Load)); } } //Joining threads for (unsigned int i = 0; i < threads.size(); i++) { threads[i].join(); } threads.clear(); }
void CAddCamDlg::OnBnClickedAddSetcampathBt() { // TODO: 在此添加控件通知处理程序代码 memset(Campath, 0, sizeof(Campath)); CString strDir; wchar_t mPath[MAX_PATH]; BROWSEINFO bi; char buffer[MAX_PATH]; ZeroMemory(buffer, MAX_PATH); bi.hwndOwner = GetSafeHwnd(); bi.pidlRoot = NULL; bi.pszDisplayName = LPWSTR(buffer); bi.lpszTitle = L"选择一个文件夹"; bi.ulFlags = BIF_EDITBOX; bi.lpfn = NULL; bi.lParam = 0; bi.iImage = 0; LPITEMIDLIST pList = NULL; if ((pList = SHBrowseForFolder(&bi)) != NULL) { SHGetPathFromIDList(pList, mPath); CStatic*pSt = (CStatic*)this->GetDlgItem(IDC_ADD_CAMPATH_ST); pSt->SetWindowTextW(mPath); CCommonFunc::UnicodeToAnsi(mPath, Campath, sizeof(mPath)); } else { return; } }
QByteArray QCNG::deriveConcatKDF(const QByteArray &publicKey, const QString &digest, int keySize, const QByteArray &algorithmID, const QByteArray &partyUInfo, const QByteArray &partyVInfo) const { d->err = PinUnknown; QByteArray derived; NCRYPT_PROV_HANDLE prov = 0; if(NCryptOpenStorageProvider(&prov, LPCWSTR(d->selected.provider.utf16()), 0)) return derived; NCRYPT_KEY_HANDLE key = 0; if(NCryptOpenKey(prov, &key, LPWSTR(d->selected.key.utf16()), d->selected.spec, 0)) { NCryptFreeObject(prov); return derived; } int err = derive(prov, key, publicKey, digest, keySize, algorithmID, partyUInfo, partyVInfo, derived); NCryptFreeObject(key); switch(err) { case ERROR_SUCCESS: d->err = PinOK; return derived; case SCARD_W_CANCELLED_BY_USER: d->err = PinCanceled; default: return derived; } }
EXTERN_C LRESULT WINAPI PluginProc(HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM lParam) { wchar_t szName[] = L"基本的なサンプル"; wchar_t szVersion[] = L"Version 2.0.0.0"; switch(nMsg) { case MP_GET_NAME: if(lParam != 0) lstrcpynW(LPWSTR(lParam), szName, wParam); return wcslen(szName); case MP_GET_VERSION: if(lParam != 0) lstrcpynW(LPWSTR(lParam), szVersion, wParam); return wcslen(szVersion); } return 0; }
void bootiniUndo(QString uninstPathL) { if (!QFile::copy(QDir::toNativeSeparators(QString("%1unetbtin/boot.ini").arg(uninstPathL)), QDir::toNativeSeparators(QString("%1boot.ini").arg(uninstPathL)))) { QFile::remove(QDir::toNativeSeparators(QString("%1boot.ini").arg(uninstPathL))); QFile::copy(QDir::toNativeSeparators(QString("%1unetbtin/boot.ini").arg(uninstPathL)), QDir::toNativeSeparators(QString("%1boot.ini").arg(uninstPathL))); } SetFileAttributesW(LPWSTR(QDir::toNativeSeparators(QString("%1boot.ini").arg(uninstPathL)).utf16()), FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_ARCHIVE); }
bool CWAVFileWriter::open() { m_handle = ::mmioOpen(LPWSTR(m_fileName.c_str()), 0, MMIO_WRITE | MMIO_CREATE | MMIO_ALLOCBUF); if (m_handle == NULL) { wxLogError(wxT("WAVFileWriter: could not open the file %s\n"), m_fileName.c_str()); return false; } m_parent.fccType = mmioFOURCC('W', 'A', 'V', 'E'); m_parent.cksize = 0; MMRESULT res = ::mmioCreateChunk(m_handle, &m_parent, MMIO_CREATERIFF); if (res != MMSYSERR_NOERROR) { wxLogError(wxT("WAVFileWriter: could not write to file %s\n"), m_fileName.c_str()); return false; } m_child.ckid = mmioFOURCC('f', 'm', 't', ' '); m_child.cksize = sizeof(WAVEFORMATEX); res = ::mmioCreateChunk(m_handle, &m_child, 0); if (res != MMSYSERR_NOERROR) { wxLogError(wxT("WAVFileWriter: could not write to the file %s\n"), m_fileName.c_str()); return false; } WAVEFORMATEX format; format.wBitsPerSample = m_sampleWidth; if (m_sampleWidth == 8U || m_sampleWidth == 16U) format.wFormatTag = WAVE_FORMAT_PCM; else format.wFormatTag = WAVE_FORMAT_IEEE_FLOAT; format.nChannels = m_channels; format.nSamplesPerSec = m_sampleRate; format.nAvgBytesPerSec = m_sampleRate * m_channels * m_sampleWidth / 8; format.nBlockAlign = m_channels * m_sampleWidth / 8; format.cbSize = 0; LONG n = ::mmioWrite(m_handle, (CHAR *)&format, sizeof(WAVEFORMATEX)); if (n != sizeof(WAVEFORMATEX)) { wxLogError(wxT("WAVFileWriter: could not write to the file %s\n"), m_fileName.c_str()); return false; } ::mmioAscend(m_handle, &m_child, 0); m_child.ckid = mmioFOURCC('d', 'a', 't', 'a'); m_child.cksize = 0; res = ::mmioCreateChunk(m_handle, &m_child, 0); if (res != MMSYSERR_NOERROR) { wxLogError(wxT("WAVFileWriter: could not write to the file %s\n"), m_fileName.c_str()); return false; } return true; }
NCRYPT_KEY_HANDLE QCNG::Private::key() const { NCRYPT_PROV_HANDLE prov = 0; NCryptOpenStorageProvider( &prov, LPCWSTR(selected.provider.utf16()), 0 ); NCRYPT_KEY_HANDLE key = 0; NCryptOpenKey( prov, &key, LPWSTR(selected.key.utf16()), selected.spec, 0 ); NCryptFreeObject( prov ); return key; }
void GlobalHelper::GetLastErrorWrapper() { LPVOID lpMsgBuf; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),(LPTSTR) &lpMsgBuf,0, NULL ); MessageBox( NULL, (LPWSTR)lpMsgBuf, LPWSTR("GetLastError"), MB_OK|MB_ICONINFORMATION ); LocalFree( lpMsgBuf ); }
void LoadSounds() { //Getting addresses of sound(s) to play OPENFILENAME ofn; char szFile[1028]; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = NULL; ofn.lpstrFile = LPWSTR(szFile); ofn.lpstrFile[0] = '\0'; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFilter = L"WAV file (*.wav)\0*.wav\0\0";//Restricted to WAV files only ofn.nFilterIndex = 1; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER; GetOpenFileName(&ofn); //Breaking up into individual addresses wchar_t* _wsfileStr = ofn.lpstrFile; std::wstring directory = _wsfileStr; _wsfileStr += (directory.length() + 1); //Used for an individual sound if (!*_wsfileStr) { fileNamesSounds.push(directory); threads.push_back(std::thread(Play)); } else { while (*_wsfileStr) { std::wstring filename = _wsfileStr; _wsfileStr += (filename.length() + 1); fileNamesSounds.push(filename); } //Only creating necessary number of threads for (unsigned int i = 0; i < _iNumThreads; i++) { threads.push_back(std::thread(Play)); } } for (unsigned int i = 0; i < threads.size(); i++) { threads[i].join(); } threads.clear(); }
void MenuAdapter::update(Action& action) { MENUITEMINFO info = { 0 }; // Set the new menu item information. info.cbSize = sizeof(info); info.fMask = MIIM_STRING | MIIM_STATE | MIIM_FTYPE; info.fState = MFS_ENABLED; info.fType = MFT_STRING; info.dwTypeData = LPWSTR(action.getText().toArray()); if (::SetMenuItemInfo(HMENU(getHandle()), UINT(action.getId()), FALSE, &info) == 0) throw UserInterfaceException("SetMenuItemInfo() failed"); }
void CopyToClipboard2(WCHAR *data) { if(OpenClipboard(NULL)) { HGLOBAL clipbuffer;//内存区 WCHAR *buffer;//内存区缓冲区 EmptyClipboard(); clipbuffer = GlobalAlloc(GMEM_DDESHARE, sizeof(WCHAR)*(wcslen(data)+1));//分配内存 buffer = (WCHAR*)GlobalLock(clipbuffer); wcscpy(buffer, LPWSTR(data)); GlobalUnlock(clipbuffer); SetClipboardData(CF_UNICODETEXT,clipbuffer); CloseClipboard(); } }
RadioButtonGroup::RadioButtonGroup(HINSTANCE hInst, HWND parent, int x, int y, int width, int height, int id, LPCWSTR title, DWORD additionalStyles, LPCWSTR *buttonsText, int buttonsCount) : Window(hInst, parent, x, y, width, height, title, L"RadioButtonGroup", NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | additionalStyles) { Header = nullptr; Id = id; CheckedButton = 0; RadioButtonsCount = buttonsCount > MAX_RADIOBUTTONS ? MAX_RADIOBUTTONS : buttonsCount; for (int i = 0; i < RadioButtonsCount; i++) { RadioButtonsText[i] = LPWSTR(malloc(sizeof(WCHAR)*lstrlen(buttonsText[i]))); lstrcpy(RadioButtonsText[i], buttonsText[i]); } }
BOOL CMSMdxCfgSequence::CreateTree( CMSMdxTreeNode* pParent, HWND hTree, HTREEITEM hRoot ) { TVINSERTSTRUCT tvInsert; ZeroMemory(&tvInsert,sizeof(TVINSERTSTRUCT)); tvInsert.hInsertAfter = NULL; tvInsert.item.mask = TVIF_TEXT|TVIF_PARAM; tvInsert.hParent = hRoot; tvInsert.item.pszText = LPWSTR( GetText() ); tvInsert.item.lParam = (LPARAM)this; HTREEITEM hSequence = TreeView_InsertItem(hTree,&tvInsert); SetItem( hSequence ); SetParent( pParent ); tvInsert.hParent = hSequence; tvInsert.item.pszText = LPWSTR( m_spAnimName.GetText() ); tvInsert.item.lParam = (LPARAM)&m_spAnimName; HTREEITEM hAnimName = TreeView_InsertItem(hTree,&tvInsert); m_spAnimName.SetParent( this ); m_spAnimName.SetItem( hAnimName ); tvInsert.hParent = hSequence; tvInsert.item.pszText = LPWSTR( m_npStartFrameId.GetText() ); tvInsert.item.lParam = (LPARAM)&m_npStartFrameId; HTREEITEM hStartFrameIdId = TreeView_InsertItem(hTree,&tvInsert); m_npStartFrameId.SetParent( this ); m_npStartFrameId.SetItem( hStartFrameIdId ); tvInsert.hParent = hSequence; tvInsert.item.pszText = LPWSTR( m_npEndFrameId.GetText() ); tvInsert.item.lParam = (LPARAM)&m_npEndFrameId; HTREEITEM hEndFrameIdId = TreeView_InsertItem(hTree,&tvInsert); m_npEndFrameId.SetParent( this ); m_npEndFrameId.SetItem( hEndFrameIdId ); //m_hitpoints.CreateTree( this, hTree, hSequence ); tvInsert.hParent = hSequence; tvInsert.item.pszText = LPWSTR( m_npRealHitPoint.GetText() ); tvInsert.item.lParam = (LPARAM)&m_npRealHitPoint; HTREEITEM hAttack = TreeView_InsertItem(hTree,&tvInsert); m_npRealHitPoint.SetParent( this ); m_npRealHitPoint.SetItem( hAttack ); tvInsert.hParent = hSequence; tvInsert.item.pszText = LPWSTR( m_npHasLightTrack.GetText() ); tvInsert.item.lParam = (LPARAM)&m_npHasLightTrack; HTREEITEM hLightTrack = TreeView_InsertItem(hTree,&tvInsert); m_npHasLightTrack.SetParent( this ); m_npHasLightTrack.SetItem( hLightTrack ); return TRUE; }
void MenuAdapter::insert(size_t index, Action& action) { MENUITEMINFO info = { 0 }; // Fill out the regular menu item information. info.cbSize = sizeof(info); info.fMask = MIIM_STRING | MIIM_STATE | MIIM_ID; info.fState = MFS_ENABLED; info.wID = UINT(action.getId()); info.dwTypeData = LPWSTR(action.getText().toArray()); // Insert the menu item into the menu. if (::InsertMenuItem(HMENU(_handle), UINT(index), TRUE, &info) == 0) throw UserInterfaceException("InsertMenuItem() failed"); }
void AudioGroupCollection::populateFiles(VSTEditor& editor, HTREEITEM colHandle, size_t parentIdx) { TVINSERTSTRUCT ins = {}; ins.item.mask = TVIF_TEXT | TVIF_PARAM; ins.hParent = colHandle; ins.hInsertAfter = TVI_LAST; m_iteratorVec.clear(); m_iteratorVec.reserve(m_groups.size()); for (auto it = m_groups.begin(); it != m_groups.end(); ++it) { ins.item.pszText = LPWSTR(it->first.c_str()); ins.item.lParam = LPARAM(0x80000000 | (parentIdx << 16) | m_iteratorVec.size()); HTREEITEM item = TreeView_InsertItem(editor.m_collectionTree, &ins); if (editor.m_selCollectionIdx == parentIdx && editor.m_selFileIdx == m_iteratorVec.size()) editor.m_deferredCollectionSel = item; m_iteratorVec.push_back(it); } }
int main (int argc, char **argv) { char *cl_cmd = getenv(CMD_ENVVAR); if (!cl_cmd) { fail(CMD_ENVVAR" not set"); } #ifndef WINTEST LPWSTR (*CDECL wine_get_dos_file_name_ptr)(LPCSTR); wine_get_dos_file_name_ptr = (void *)GetProcAddress(GetModuleHandleA("KERNEL32"), "wine_get_dos_file_name"); if (!wine_get_dos_file_name_ptr) { fail("cannot get wine_get_dos_file_name"); } #endif WCHAR cmdline[CMDLINE_BUF_LEN]; int cmdline_len = 0; void append_char (WCHAR c) { if (1 > MAX_CMDLINE_LEN - cmdline_len) { fail("out of command line buffer"); } cmdline[cmdline_len] = c; cmdline_len++; } int arg_writing = 0; void start_argument () { assert(!arg_writing); if (cmdline_len == 0) { append_char('"'); } else { append_char(' '); append_char('"'); } arg_writing = 1; }
void MainWindow::SearchRegistry(HKEY root, LPWSTR subkey, ListView *listView) { HKEY key; int resultCode = RegOpenKeyEx(root, subkey, 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &key); if (resultCode != 0) return; int index = 0; WCHAR name[10 * MAX_STR]; while (RegEnumKey(key, index++, name, 10240) != ERROR_NO_MORE_ITEMS && !SearchAgain && ThreadNeeded) { if (lstrlen(subkey) == 0) SearchRegistry(root, name, listView); else { WCHAR path[10 * MAX_STR]; swprintf(path, 10 * MAX_STR, L"%s\\%s", subkey, name); SearchRegistry(root, path, listView); } } index = 0; BYTE data[20 * MAX_STR]; DWORD namesize = 10 * MAX_STR, type, size = 20 * MAX_STR; while (RegEnumValue(key, index++, name, &namesize, NULL, &type, data, &size) != ERROR_NO_MORE_ITEMS && !SearchAgain && ThreadNeeded) { if (type == REG_SZ) { LPWSTR path = LPWSTR(data); WCHAR tmp[MAX_STR]; lstrcpy(tmp, L":\\"); if (lstrlen(path) != 0 && tmp[0] == path[1] && tmp[1] == path[2] && PathFileExists(path) == FALSE) { int newRow = listView->AddItem(subkey, -1, 0); listView->AddItem(name, newRow, 1); listView->AddItem(path, newRow, 2); } } namesize = size = 1024; } RegCloseKey(key); }
WideCharSeq const multibyte_to(MultiByteRange const& from) { std::string tmp = from|oven::copied; #if !(PSTADE_APPLE_ATL_VER < 0x0700) return ATL::CA2W(tmp.c_str()).operator LPWSTR() | oven::as_c_str | oven::copied; #else USES_CONVERSION_EX; return A2W_EX(tmp.c_str(), 128) | oven::as_c_str | oven::copied; #endif }
void AudioGroupFilePresenter::populateCollectionColumn(VSTEditor& editor) { TreeView_DeleteAllItems(editor.m_collectionTree); TVINSERTSTRUCT ins = {}; ins.hParent = TVI_ROOT; ins.hInsertAfter = TVI_LAST; ins.item.mask = TVIF_CHILDREN | TVIF_TEXT | TVIF_PARAM; m_iteratorVec.clear(); m_iteratorVec.reserve(m_audioGroupCollections.size()); for (auto it = m_audioGroupCollections.begin(); it != m_audioGroupCollections.end(); ++it) { ins.item.cChildren = it->second->m_groups.size() ? 1 : 0; ins.item.pszText = LPWSTR(it->first.c_str()); ins.item.lParam = LPARAM(m_iteratorVec.size() << 16); HTREEITEM item = TreeView_InsertItem(editor.m_collectionTree, &ins); it->second->populateFiles(editor, item, m_iteratorVec.size()); if (editor.m_selCollectionIdx == m_iteratorVec.size() && editor.m_selFileIdx == -1) editor.m_deferredCollectionSel = item; m_iteratorVec.push_back(it); } }
BOOL CMSMdxCfgSequences::CreateTree( CMSMdxTreeNode* pParent, HWND hTree, HTREEITEM hRoot ) { TVINSERTSTRUCT tvInsert; ZeroMemory(&tvInsert,sizeof(TVINSERTSTRUCT)); tvInsert.hParent = hRoot; tvInsert.hInsertAfter = NULL; tvInsert.item.mask = TVIF_TEXT|TVIF_PARAM; tvInsert.item.pszText = LPWSTR(GetText()); tvInsert.item.lParam = (LPARAM)this; HTREEITEM hChild = TreeView_InsertItem(hTree,&tvInsert); SetItem( hChild ); SetParent( pParent ); for( int i = 0; i < m_vectorSequence.size(); i++ ) m_vectorSequence[i]->CreateTree( this, hTree, hChild ); m_hRootItem = hChild; return TRUE; }
void MenuAdapter::insert(size_t index, Menu& menu) { MENUITEMINFO info = { 0 }; IMenuAdapter* adapter = menu.getAdapter(); if (!adapter) throw UserInterfaceException("Cannot insert menu without an adapter."); // Fill out the regular menu item information. info.cbSize = sizeof(info); info.fMask = MIIM_STRING | MIIM_STATE | MIIM_SUBMENU | MIIM_ID; info.fState = MFS_ENABLED; info.wID = UINT(menu.getId()); info.hSubMenu = HMENU(adapter->getHandle()); info.dwTypeData = LPWSTR(menu.getText().toArray()); // Insert the menu item into the Menu. if (::InsertMenuItem(HMENU(_handle), UINT(index), TRUE, &info) == 0) throw UserInterfaceException("InsertMenuItem() failed"); }
QStringList QCSP::containers( SslCertificate::KeyUsage usage ) { qWarning() << "Start enumerationg providers"; QHash<QString,QPair<QString,QString> > certs; HCRYPTPROV h = 0; DWORD index = 0, type = 0, size = 0; while( CryptEnumProvidersW( index, 0, 0, &type, 0, &size ) ) { QString provider( size / sizeof(wchar_t) - 1, 0 ); if( !CryptEnumProvidersW( index++, 0, 0, &type, LPWSTR(provider.data()), &size ) ) continue; qWarning() << "Found provider" << provider << "type" << type; if( type != PROV_RSA_FULL ) continue; // its broken and does not play well with pkcs11 if( provider.toLower().contains( "esteid" ) ) continue; qWarning() << "Acquiring provider" << provider << "context"; if( h ) CryptReleaseContext( h, 0 ); h = 0; if( !CryptAcquireContextW( &h, 0, LPCWSTR(provider.utf16()), type, CRYPT_SILENT ) ) continue; qWarning() << "Checking if provider" << provider << "is HW"; QByteArray imptype = QCSPPrivate::provParam( h, PP_IMPTYPE ); if( imptype.isEmpty() || !(imptype[0] & CRYPT_IMPL_HARDWARE) ) continue; qWarning() << "Enumerating provider " << provider << "containers"; QStringList containers; QByteArray container = QCSPPrivate::provParam( h, PP_ENUMCONTAINERS, CRYPT_FIRST ); while( !container.isEmpty() ) { containers << container; container = QCSPPrivate::provParam( h, PP_ENUMCONTAINERS, CRYPT_NEXT ); } qWarning() << "Provider" << provider << "containers" << containers; Q_FOREACH( const QString &container, containers ) { if( h ) CryptReleaseContext( h, 0 ); h = 0; qWarning() << "Acquiring provider" << provider << "container" << container << "context"; if( !CryptAcquireContextW( &h, LPCWSTR(container.utf16()), LPCWSTR(provider.utf16()), type, CRYPT_SILENT ) ) continue; qWarning() << "Geting provider" << provider << "container" << container << "key"; HCRYPTKEY key = 0; if( !CryptGetUserKey( h, usage == SslCertificate::NonRepudiation ? AT_SIGNATURE : AT_KEYEXCHANGE, &key ) ) continue; qWarning() << "Reading provider" << provider << "container" << container << "cert"; QSslCertificate cert( QCSPPrivate::keyParam( key, KP_CERTIFICATE, 0 ), QSsl::Der ); CryptDestroyKey( key ); if( cert.isNull() ) continue; qWarning() << "Adding provider" << provider << "container" << container << "list"; certs.insert( cert.subjectInfo( QSslCertificate::CommonName ), QPair<QString,QString>( provider, container ) ); } } if( h ) CryptReleaseContext( h, 0 ); qWarning() << "End enumerationg providers"; d->certs = certs; return d->certs.keys(); }
/* * Main function */ int wmain(int argc, WCHAR *argv[]) { LPSTR (*CDECL wine_get_unix_file_name_ptr)(LPCWSTR) = NULL; LPWSTR (*CDECL wine_get_dos_file_name_ptr)(LPCSTR) = NULL; WCHAR dos_pathW[MAX_PATH]; char path[MAX_PATH]; int outputformats; int i; outputformats = parse_options(argv); if (outputformats == 0) outputformats = UNIXFORMAT; if (outputformats & UNIXFORMAT) { wine_get_unix_file_name_ptr = (void*) GetProcAddress(GetModuleHandleA("KERNEL32"), "wine_get_unix_file_name"); if (wine_get_unix_file_name_ptr == NULL) { fprintf(stderr, "%s: cannot get the address of " "'wine_get_unix_file_name'\n", progname); exit(3); } } if (outputformats & WINDOWSFORMAT) { wine_get_dos_file_name_ptr = (void*) GetProcAddress(GetModuleHandleA("KERNEL32"), "wine_get_dos_file_name"); if (wine_get_dos_file_name_ptr == NULL) { fprintf(stderr, "%s: cannot get the address of " "'wine_get_dos_file_name'\n", progname); exit(3); } } for (i = 1; argv[i]; i++) { *path='\0'; if (outputformats & LONGFORMAT) { if (GetLongPathNameW(argv[i], dos_pathW, MAX_PATH)) WideCharToMultiByte(CP_UNIXCP, 0, dos_pathW, -1, path, MAX_PATH, NULL, NULL); printf("%s\n", path); } if (outputformats & SHORTFORMAT) { if (GetShortPathNameW(argv[i], dos_pathW, MAX_PATH)) WideCharToMultiByte(CP_UNIXCP, 0, dos_pathW, -1, path, MAX_PATH, NULL, NULL); printf("%s\n", path); } if (outputformats & UNIXFORMAT) { WCHAR *ntpath, *tail; int ntpathlen=lstrlenW(argv[i]); ntpath=HeapAlloc(GetProcessHeap(), 0, sizeof(*ntpath)*(ntpathlen+1)); lstrcpyW(ntpath, argv[i]); tail=NULL; while (1) { char *unix_name; WCHAR *slash, *c; unix_name = wine_get_unix_file_name_ptr(ntpath); if (unix_name) { if (tail) { WideCharToMultiByte(CP_UNIXCP, 0, tail+1, -1, path, MAX_PATH, NULL, NULL); printf("%s/%s\n", unix_name, path); } else { printf("%s\n", unix_name); } HeapFree( GetProcessHeap(), 0, unix_name ); break; } slash=(tail ? tail : ntpath+ntpathlen); while (slash != ntpath && *slash != '/' && *slash != '\\') slash--; if (slash == ntpath) { /* This is a complete path conversion failure. * It would typically happen if ntpath == "". */ printf("\n"); break; } c=slash+1; while (*c != '\0' && *c != '*' && *c != '?' && *c != '<' && *c != '>' && *c != '|' && *c != '"') c++; if (*c != '\0') { /* If this is not a valid NT path to start with, * then obviously we cannot convert it. */ printf("\n"); break; } if (tail) *tail='/'; tail=slash; *tail='\0'; } HeapFree(GetProcessHeap(), 0, ntpath); } if (outputformats & WINDOWSFORMAT) { WCHAR* windows_name; char* unix_name; DWORD size; size=WideCharToMultiByte(CP_UNIXCP, 0, argv[i], -1, NULL, 0, NULL, NULL); unix_name=HeapAlloc(GetProcessHeap(), 0, size); WideCharToMultiByte(CP_UNIXCP, 0, argv[i], -1, unix_name, size, NULL, NULL); if ((windows_name = wine_get_dos_file_name_ptr(unix_name))) { WideCharToMultiByte(CP_UNIXCP, 0, windows_name, -1, path, MAX_PATH, NULL, NULL); printf("%s\n", path); HeapFree( GetProcessHeap(), 0, windows_name ); } else printf( "\n" ); HeapFree( GetProcessHeap(), 0, unix_name ); } } exit(0); }
bool CDownloadAndSetupThread::SetupBankUsbKey(LPCTSTR lpPath, LPCTSTR lpSetUp) // 银行USBKEY安装 { ATLASSERT (NULL != lpPath); if (NULL == lpPath) return false; std::wstring strPath = lpPath; if (strPath.rfind (L".exe") == strPath.length () - 4) // 安装exe文件 { OSVERSIONINFO os = { sizeof(OSVERSIONINFO) }; ::GetVersionEx(&os); if(os.dwMajorVersion >= 6) { SHELLEXECUTEINFOW shExecInfo; shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); shExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;//SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI; shExecInfo.hwnd = NULL; shExecInfo.lpVerb = L"runas"; shExecInfo.lpFile = LPWSTR(lpPath); shExecInfo.lpParameters = NULL; shExecInfo.lpDirectory = NULL; shExecInfo.nShow = SW_SHOWNORMAL; shExecInfo.hInstApp = NULL; // 用户取消 if (true == m_bCancled) { return true; } if (!ShellExecuteExW(&shExecInfo)) { int err = GetLastError(); CRecordProgram::GetInstance()->FeedbackError(MY_ERROR_PRO_CORE, err, CRecordProgram::GetInstance()->GetRecordInfo(L"SetupBankUsbKey创建安装进程%s失败!", lpPath)); } else WaitForSingleObject (shExecInfo.hProcess, INFINITE); // 等待usbkey.exe安装完成才返回 while (!CBkInfoDownloadManager::GetInterfaceInstance ()->USBFinalTest (m_dlUSBParam.nVid, m_dlUSBParam.nPid, m_dlUSBParam.nMid, m_bSetupFinish)) { if (!ShellExecuteExW(&shExecInfo)) { CRecordProgram::GetInstance()->FeedbackError(MY_ERROR_PRO_CORE, GetLastError(), CRecordProgram::GetInstance()->GetRecordInfo(L"SetupBankUsbKey创建安装进程%s失败!", lpPath)); } else WaitForSingleObject (shExecInfo.hProcess, INFINITE); // 等待usbkey.exe安装完成才返回 } } else { STARTUPINFOW si; memset (&si, 0, sizeof (STARTUPINFOW)); si.wShowWindow = SW_HIDE; si.cb = sizeof (STARTUPINFOW); PROCESS_INFORMATION pi; memset (&pi, 0, sizeof (PROCESS_INFORMATION)); // 用户取消 if (true == m_bCancled) { return true; } if (!CreateProcess(NULL, LPWSTR(lpPath), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { CRecordProgram::GetInstance()->FeedbackError(MY_ERROR_PRO_CORE, ERR_CREATEPROCESS, CRecordProgram::GetInstance()->GetRecordInfo(L"SetupBankUsbKey创建安装进程失败!", lpPath)); m_bSetupFinish = true; return false; } else WaitForSingleObject (pi.hProcess, INFINITE); // 等待usbkey.exe安装完成才返回 while (!CBkInfoDownloadManager::GetInterfaceInstance ()->USBFinalTest (m_dlUSBParam.nVid, m_dlUSBParam.nPid, m_dlUSBParam.nMid, m_bSetupFinish)) { memset (&si, 0, sizeof (STARTUPINFOW)); memset (&pi, 0, sizeof (PROCESS_INFORMATION)); if (!CreateProcess(NULL, LPWSTR(lpPath), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { CRecordProgram::GetInstance()->FeedbackError(MY_ERROR_PRO_CORE, ERR_CREATEPROCESS, CRecordProgram::GetInstance()->GetRecordInfo(L"SetupBankUsbKey创建安装进程失败!", lpPath)); m_bSetupFinish = true; return false; } else WaitForSingleObject (pi.hProcess, INFINITE); // 等待usbkey.exe安装完成才返回 } CloseHandle (pi.hThread); CloseHandle (pi.hProcess); } m_bSetupFinish = true; // 标记安装完成 return true; } return false; }
bool CSoundFileReader::open(float sampleRate, unsigned int blockSize) { m_blockSize = blockSize; m_handle = ::mmioOpen(LPWSTR(m_fileName.c_str()), 0, MMIO_READ | MMIO_ALLOCBUF); if (m_handle == NULL) { wxLogError(wxT("SoundFileReader: could not open the WAV file %s."), m_fileName.c_str()); return false; } MMCKINFO parent; parent.fccType = mmioFOURCC('W', 'A', 'V', 'E'); MMRESULT res = ::mmioDescend(m_handle, &parent, 0, MMIO_FINDRIFF); if (res != MMSYSERR_NOERROR) { wxLogError(wxT("SoundFileReader: %s has no \"WAVE\" header."), m_fileName.c_str()); return false; } MMCKINFO child; child.ckid = mmioFOURCC('f', 'm', 't', ' '); res = ::mmioDescend(m_handle, &child, &parent, MMIO_FINDCHUNK); if (res != MMSYSERR_NOERROR) { wxLogError(wxT("SoundFileReader: %s has no \"fmt \" chunk."), m_fileName.c_str()); return false; } WAVEFORMATEX format; LONG len = ::mmioRead(m_handle, (char *)&format, child.cksize); if (len != LONG(child.cksize)) { wxLogError(wxT("SoundFileReader: %s is corrupt, cannot read the WAVEFORMATEX structure."), m_fileName.c_str()); return false; } if (format.wFormatTag != WAVE_FORMAT_PCM && format.wFormatTag != WAVE_FORMAT_IEEE_FLOAT) { wxLogError(wxT("SoundFileReader: %s is not PCM or IEEE Float format, is %u."), m_fileName.c_str(), format.wFormatTag); return false; } if (format.nSamplesPerSec != DWORD(sampleRate)) { wxLogError(wxT("SoundFileReader: %s has sample rate %lu, not %.0f"), m_fileName.c_str(), format.nSamplesPerSec, sampleRate); return false; } m_channels = format.nChannels; if (m_channels > 2U) { wxLogError(wxT("SoundFileReader: %s has %u channels, more than 2."), m_fileName.c_str(), m_channels); return false; } if (format.wBitsPerSample == 8U && format.wFormatTag == WAVE_FORMAT_PCM) { m_format = FORMAT_8BIT; } else if (format.wBitsPerSample == 16U && format.wFormatTag == WAVE_FORMAT_PCM) { m_format = FORMAT_16BIT; } else if (format.wBitsPerSample == 32U && format.wFormatTag == WAVE_FORMAT_IEEE_FLOAT) { m_format = FORMAT_32BIT; } else { wxLogError(wxT("SoundFileReader: %s has sample width %u and format %u."), m_fileName.c_str(), format.wBitsPerSample, format.wFormatTag); return false; } res = ::mmioAscend(m_handle, &child, 0); if (res != MMSYSERR_NOERROR) { wxLogError(wxT("SoundFileReader: %s is corrupt, cannot ascend."), m_fileName.c_str()); return false; } child.ckid = mmioFOURCC('d', 'a', 't', 'a'); res = ::mmioDescend(m_handle, &child, &parent, MMIO_FINDCHUNK); if (res != MMSYSERR_NOERROR) { wxLogError(wxT("SoundFileReader: %s has no \"data\" chunk."), m_fileName.c_str()); return false; } // Get the current location so we can rewind if needed m_offset = ::mmioSeek(m_handle, 0L, SEEK_CUR); switch (m_format) { case FORMAT_8BIT: m_buffer8 = new wxUint8[m_blockSize * m_channels]; break; case FORMAT_16BIT: m_buffer16 = new wxInt16[m_blockSize * m_channels]; break; case FORMAT_32BIT: m_buffer32 = new wxFloat32[m_blockSize * m_channels]; break; } m_buffer = new float[m_blockSize * 2U]; return CThreadReader::open(sampleRate, blockSize); }
bool CWAVFileReader::open() { m_handle = ::mmioOpen(LPWSTR(m_fileName.c_str()), 0, MMIO_READ | MMIO_ALLOCBUF); if (m_handle == NULL) { wxLogError(wxT("WAVFileReader: could not open the WAV file %s\n"), m_fileName.c_str()); return false; } MMCKINFO parent; parent.fccType = mmioFOURCC('W', 'A', 'V', 'E'); MMRESULT res = ::mmioDescend(m_handle, &parent, 0, MMIO_FINDRIFF); if (res != MMSYSERR_NOERROR) { wxLogError(wxT("WAVFileReader: %s has no \"WAVE\" header\n"), m_fileName.c_str()); ::mmioClose(m_handle, 0U); m_handle = NULL; return false; } MMCKINFO child; child.ckid = mmioFOURCC('f', 'm', 't', ' '); res = ::mmioDescend(m_handle, &child, &parent, MMIO_FINDCHUNK); if (res != MMSYSERR_NOERROR) { wxLogError(wxT("WAVFileReader: %s has no \"fmt \" chunk\n"), m_fileName.c_str()); ::mmioClose(m_handle, 0U); m_handle = NULL; return false; } WAVEFORMATEX format; LONG len = ::mmioRead(m_handle, (char *)&format, child.cksize); if (len != LONG(child.cksize)) { wxLogError(wxT("WAVFileReader: %s is corrupt, cannot read the WAVEFORMATEX structure\n"), m_fileName.c_str()); ::mmioClose(m_handle, 0U); m_handle = NULL; return false; } if (format.wFormatTag != WAVE_FORMAT_PCM && format.wFormatTag != WAVE_FORMAT_IEEE_FLOAT) { wxLogError(wxT("WAVFileReader: %s is not PCM or IEEE Float format, is %u\n"), m_fileName.c_str(), format.wFormatTag); ::mmioClose(m_handle, 0U); m_handle = NULL; return false; } m_sampleRate = format.nSamplesPerSec; m_channels = format.nChannels; if (m_channels > 2U) { wxLogError(wxT("WAVFileReader: %s has %u channels, more than 2\n"), m_fileName.c_str(), m_channels); ::mmioClose(m_handle, 0U); m_handle = NULL; return false; } if (format.wBitsPerSample == 8U && format.wFormatTag == WAVE_FORMAT_PCM) { m_format = FORMAT_8BIT; } else if (format.wBitsPerSample == 16U && format.wFormatTag == WAVE_FORMAT_PCM) { m_format = FORMAT_16BIT; } else if (format.wBitsPerSample == 32U && format.wFormatTag == WAVE_FORMAT_IEEE_FLOAT) { m_format = FORMAT_32BIT; } else { wxLogError(wxT("WAVFileReader: %s has sample width %u and format %u\n"), m_fileName.c_str(), format.wBitsPerSample, format.wFormatTag); ::mmioClose(m_handle, 0U); m_handle = NULL; return false; } res = ::mmioAscend(m_handle, &child, 0); if (res != MMSYSERR_NOERROR) { wxLogError(wxT("WAVFileReader: %s is corrupt, cannot ascend\n"), m_fileName.c_str()); ::mmioClose(m_handle, 0U); m_handle = NULL; return false; } child.ckid = mmioFOURCC('d', 'a', 't', 'a'); res = ::mmioDescend(m_handle, &child, &parent, MMIO_FINDCHUNK); if (res != MMSYSERR_NOERROR) { wxLogError(wxT("WAVFileReader: %s has no \"data\" chunk\n"), m_fileName.c_str()); ::mmioClose(m_handle, 0U); m_handle = NULL; return false; } // Get the current location so we can rewind if needed m_offset = ::mmioSeek(m_handle, 0L, SEEK_CUR); return true; }