예제 #1
0
QCollatorSortKey QCollator::sortKey(const QString &string) const
{
    if (d->dirty)
        d->init();

#ifndef USE_COMPARESTRINGEX
    int size = LCMapStringW(d->localeID, LCMAP_SORTKEY | d->collator,
                           reinterpret_cast<const wchar_t*>(string.constData()), string.size(),
                           0, 0);
#else
    int size = LCMapStringEx(LPCWSTR(d->localeName.utf16()), LCMAP_SORTKEY | d->collator,
                           reinterpret_cast<LPCWSTR>(string.constData()), string.size(),
                           0, 0, NULL, NULL, 0);
#endif
    QString ret(size, Qt::Uninitialized);
#ifndef USE_COMPARESTRINGEX
    int finalSize = LCMapStringW(d->localeID, LCMAP_SORTKEY | d->collator,
                           reinterpret_cast<const wchar_t*>(string.constData()), string.size(),
                           reinterpret_cast<wchar_t*>(ret.data()), ret.size());
#else
    int finalSize = LCMapStringEx(LPCWSTR(d->localeName.utf16()), LCMAP_SORTKEY | d->collator,
                           reinterpret_cast<LPCWSTR>(string.constData()), string.size(),
                           reinterpret_cast<LPWSTR>(ret.data()), ret.size(),
                           NULL, NULL, 0);
#endif
    if (finalSize == 0) {
        qWarning() << "there were problems when generating the ::sortKey by LCMapStringW with error:" << GetLastError();
    }
    return QCollatorSortKey(new QCollatorSortKeyPrivate(ret));
}
예제 #2
0
//---------------------------- PUBLIC           -----------------------------//
wxBaseRadioButton::wxBaseRadioButton(wxWindow* parent, wxWindowID id, 
									 const wxString& label, 
									 const HashString &color, 
									 const HashString &font, const wxPoint& pos, 
									 const wxSize& size, long style)
: wxRadioButton(parent, id, label, pos, size, style)
, BaseSkinMixin<wxBaseRadioButton>(color, font, shInputBackground)
{
#ifdef __WIN32__
	if ( wxApp::GetComCtl32Version() >= 600 )
    {
		wxLogNull nolog;

		typedef boost::scoped_ptr<wxDynamicLibrary> DynamicLibraryPtr;

		DynamicLibraryPtr lib(new wxDynamicLibrary);
		if(true == lib->Load(wxT("uxtheme.dll")))
		{
			typedef HRESULT (__stdcall *PFNWXUSETWINDOWTHEME)(WXHWND, 
				const wchar_t*, const wchar_t *) ;

			PFNWXUSETWINDOWTHEME func = (PFNWXUSETWINDOWTHEME) 
				lib->GetSymbol(_T("SetWindowTheme"));
			if(func)
			{
				func((HWND) GetHWND(), LPCWSTR(" "), LPCWSTR(" "));
			}
		}
	}
#endif

	OnSkin();
}
예제 #3
0
//
// CStringWתCStringA
//
CStringA CStrW2CStrA(const CStringW &cstrSrcW)
{
	int len = WideCharToMultiByte(CP_ACP, 0, LPCWSTR(cstrSrcW), -1, NULL, 0, NULL, NULL);
	char *str = new char[len];
	memset(str, 0, len);
	WideCharToMultiByte(CP_ACP, 0, LPCWSTR(cstrSrcW), -1, str, len, NULL, NULL);
	CStringA cstrDestA = str;
	delete[] str;

	return cstrDestA;
}
void CPasskeyEntry::ProcessPhrase()
{
  CGeneralMsgBox gmb;

  switch (GetMainDlg()->CheckPasskey(LPCWSTR(m_filespec), LPCWSTR(m_passkey))) {
  case PWScore::SUCCESS: {
    // OnOK clears the passkey, so we save it
    const CSecString save_passkey = m_passkey;
    // Try to change read-only state if user changed checkbox:
    // r/w -> r-o always succeeds
    // r-o -> r/w may fail
    // Note that if file is read-only, m_bForceReadOnly is true -> checkbox
    // is disabled -> don't need to worry about that.
    if ((m_index == GCP_RESTORE || m_index == GCP_WITHEXIT) && 
        (m_PKE_ReadOnly == TRUE) == pws_os::IsLockedFile(LPCWSTR(m_filespec))) {
      GetMainDlg()->ChangeMode(false); // false means
      //                           "don't prompt use for password", as we just got it.
    }
    CPWDialog::OnOK();
    m_passkey = save_passkey;
  }
    break;
  case PWScore::WRONG_PASSWORD:
    if (m_tries++ >= 2) { // too many tries
      CString cs_toomany;
      cs_toomany.Format(IDS_TOOMANYTRIES, m_tries);
      gmb.AfxMessageBox(cs_toomany);
    }
    else { // try again
      gmb.AfxMessageBox(m_index == GCP_CHANGEMODE ? IDS_BADPASSKEY : IDS_INCORRECTKEY);
    }
    m_pctlPasskey->SetSel(MAKEWORD(-1, 0));
    m_pctlPasskey->SetFocus();
    break;
  case PWScore::READ_FAIL:
    gmb.AfxMessageBox(IDSC_FILE_UNREADABLE);
    CPWDialog::OnCancel();
    break;
  case PWScore::TRUNCATED_FILE:
    gmb.AfxMessageBox(IDSC_FILE_TRUNCATED);
    CPWDialog::OnCancel();
    break;
  default:
    ASSERT(0);
    gmb.AfxMessageBox(IDSC_UNKNOWN_ERROR);
    CPWDialog::OnCancel();
    break;
  }
}
예제 #5
0
MciPlayer::MciPlayer()
: m_hWnd(NULL)
, m_hDev(NULL)
, m_nSoundID(0)
, m_uTimes(0)
, m_bPlaying(false)
{
    if (! s_hInstance)
    {
        s_hInstance = GetModuleHandle( NULL );            // Grab An Instance For Our Window

        WNDCLASS  wc;        // Windows Class Structure

        // Redraw On Size, And Own DC For Window.
        wc.style          = 0;  
        wc.lpfnWndProc    = _SoundPlayProc;                    // WndProc Handles Messages
        wc.cbClsExtra     = 0;                              // No Extra Window Data
        wc.cbWndExtra     = 0;                                // No Extra Window Data
        wc.hInstance      = s_hInstance;                    // Set The Instance
        wc.hIcon          = 0;                                // Load The Default Icon
        wc.hCursor        = LoadCursor( NULL, IDC_ARROW );    // Load The Arrow Pointer
        wc.hbrBackground  = NULL;                           // No Background Required For GL
        wc.lpszMenuName   = NULL;                           // We Don't Want A Menu
        wc.lpszClassName  = LPCWSTR(WIN_CLASS_NAME);        // Set The Class Name

        if (! RegisterClass(&wc)
            && 1410 != GetLastError())
        {
            return;
        }
    }

    m_hWnd = CreateWindowEx(
        WS_EX_APPWINDOW,                                    // Extended Style For The Window
        LPCWSTR(WIN_CLASS_NAME),                            // Class Name
        NULL,                                               // Window Title
        WS_POPUPWINDOW,/*WS_OVERLAPPEDWINDOW*/              // Defined Window Style
        0, 0,                                               // Window Position
        0,                                                  // Window Width
        0,                                                  // Window Height
        NULL,                                               // No Parent Window
        NULL,                                               // No Menu
        s_hInstance,                                        // Instance
        NULL );
    if (m_hWnd)
    {
        SetWindowLong(m_hWnd, GWL_USERDATA, (LONG)this);
    }
}
예제 #6
0
int main() {

	hMutex = CreateMutex( NULL, FALSE, LPCWSTR( "MyMutex"));
	
	if (GetLastError() == ERROR_ALREADY_EXISTS || GetLastError() == ERROR_ACCESS_DENIED) 
			return 1 ;
	

	programHandle = GetModuleHandle(NULL);
	firstCursor = CopyCursor(LoadCursor(NULL, IDC_IBEAM));
	hookHandle = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardHook, programHandle, 0);	
	timerHandle = SetTimer(NULL, timerHandle, 200, UpdateCursor);

	
	HCURSOR cursorHandle = LoadCursor(programHandle, MAKEINTRESOURCE(1033));
	SetSystemCursor(cursorHandle, OCR_IBEAM);

	MSG message;
	while (	GetMessage(&message, 0, 0, 0))
	{
		TranslateMessage(&message);
		DispatchMessage(&message);
	}

		SetSystemCursor(firstCursor, OCR_IBEAM);			
		DestroyCursor(firstCursor);
		UnhookWindowsHookEx(hookHandle);
		ReleaseMutex(hMutex);

	return 0;
}
예제 #7
0
파일: QCNG.cpp 프로젝트: open-eid/qdigidoc
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;
	}
}
예제 #8
0
파일: Game.cpp 프로젝트: nebula2/Pew
void Game::Run(){
	while (running)	{

		
		//trap mouse curser in window
		HWND hwnd;
		hwnd = FindWindow(0,LPCWSTR("Pew"));
		RECT r;
		//top left coords
		r.left = window.getPosition().x;
		r.top = window.getPosition().y;
		//bottom right coords
		r.right = window.getPosition().x + window.getSize().x;
		r.bottom = window.getPosition().y + window.getSize().y;

		//clip mouse to window
		GetWindowRect(hwnd, &r);
		ClipCursor(&r);
		
		//do the game stuff
		Update();
		HandleEvents();
		Render();
		Quit();		
	}
}
예제 #9
0
int _tmain(int argc, _TCHAR* argv[])
{
    // DLLのハンドル
    HMODULE hModule;

    // コールバック関数の定義
    LPCWSTR (__stdcall *func) (LPCWSTR);

    // LoadLibraryを使用したDLL関数の呼び出し方法。

    // LoadLibraryでDLLをロード
    hModule = LoadLibrary( _T("BridgeDLL.dll") );

    if( hModule == NULL )
    {
        // ロードに失敗(DLLが存在しない)
        MessageBox(NULL, L"BridgeDLL.dllが見つかりません", L"エラー", MB_OK);
    }
    else
    {
        // DLL内の関数のアドレスを取得する(DEFを使用していないので)
        func = (LPCWSTR (__stdcall *)(LPCWSTR))GetProcAddress( hModule, "_TestMethod@4" );

        if( func != NULL )
        {
            // 取得したアドレスを経由して呼び出す
            MessageBox(NULL, func(L"アンマネージからマネージ!!!"), L"戻り値", MB_OK);
        }

        // ロードしたDLLを解放
        FreeLibrary( hModule );
    }

    return 0;
}
VARIANT* GpuCapabilitiesWindows::WMIquery(std::string wmiClass, std::string attribute) {

    // Code based upon:  "Example: Getting WMI Data from the Local Computer"
    // http://msdn2.microsoft.com/en-us/library/aa390423.aspx

    if (!isWMIinited()) {
        LWARNING("WMI not initiated");
        return 0;
    }

    HRESULT hres;
    VARIANT* result = 0;

    // Step 6: --------------------------------------------------
    // Use the IWbemServices pointer to make requests of WMI ----
    IEnumWbemClassObject* pEnumerator = NULL;
    std::string query = "SELECT " + attribute + " FROM " + wmiClass;
    hres = pWbemServices_->ExecQuery(
        bstr_t("WQL"),
        bstr_t(query.c_str()),
        WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
        NULL,
        &pEnumerator);

    if (FAILED(hres)) {
        LWARNING("ERROR: WMI query failed: " << query);
        return 0;
    }

    // Step 7: -------------------------------------------------
    // Get the data from the query in step 6 -------------------

    IWbemClassObject* pclsObj = 0;
    ULONG uReturn = 0;

    if (pEnumerator) {
        HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1,
            &pclsObj, &uReturn);

        if (uReturn) {
            // Get the value of the attribute and store it in result
            result = new VARIANT;
            hr = pclsObj->Get(LPCWSTR(str2wstr(attribute).c_str()), 0, result, 0, 0);
        }
    }

    if (!result) {
        LWARNING("No WMI query result");
    }

    // Clean enumerator and pclsObject
    if (pEnumerator)
        pEnumerator->Release();
    if (pclsObj)
        pclsObj->Release();

    return result;

}
예제 #11
0
void CLVHdrCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
  CHeaderCtrl::OnLButtonDown(nFlags, point);

  if (!m_bCCActive)
    return;

  // Start of Drag a column (m_dwHDRType) from Header to .....

  // Get client window position
  CPoint currentClientPosition;
  currentClientPosition = ::GetMessagePos();
  ScreenToClient(&currentClientPosition);

  // Get index of column we are on
  HDHITTESTINFO hdhti;
  hdhti.pt = currentClientPosition;
  hdhti.flags = 0;
  ::SendMessage(this->GetSafeHwnd(), HDM_HITTEST, 0, (LPARAM) &hdhti);

  // Get column name and type
  HD_ITEM hdi;
  hdi.mask = HDI_WIDTH | HDI_LPARAM | HDI_TEXT;
  enum { sizeOfBuffer = 256 };
  wchar_t lpBuffer[sizeOfBuffer];
  hdi.pszText = lpBuffer;
  hdi.cchTextMax = sizeOfBuffer;

  GetItem(hdhti.iItem, &hdi);
  m_dwHDRType = hdi.lParam;

  // Can't play with TITLE or USER
  if (m_dwHDRType == CItemData::TITLE || m_dwHDRType == CItemData::USER)
    return;

  // Get the data: ColumnChooser Listbox needs the column string
  const size_t iLen = wcslen(lpBuffer);
  CString cs_text;
  cs_text.Format(L"%08x%02x%02x%04x%s", GetCurrentProcessId(),
    FROMHDR, m_dwHDRType, iLen, lpBuffer);

  // Set drag image
  m_pDragImage = CreateDragImage(hdhti.iItem);
  m_pDragImage->BeginDrag(0, CPoint(8, 8));
  m_pDragImage->DragEnter(GetDesktopWindow(), point);

  // Get client rectangle
  RECT rClient;
  GetClientRect(&rClient);

  // Start dragging
  StartDragging((BYTE *)LPCWSTR(cs_text), cs_text.GetLength() * sizeof(wchar_t),
    m_ccddCPFID, &rClient, &point);

  // End dragging image
  m_pDragImage->DragLeave(GetDesktopWindow());
  m_pDragImage->EndDrag();
  //delete m_pDragImage;
}
예제 #12
0
HRESULT CDBConnection::OpenDataSource(LPCWSTR lpszPathFileName, LPCWSTR lpszUserName, LPCWSTR lpszPassword)
{
	_ASSERTE(lpszPathFileName != NULL);
	_ASSERTE(lpszUserName != NULL);
	_ASSERTE(lpszPassword != NULL);

	USES_CONVERSION;

	HRESULT hr = E_FAIL;

	if (lpszPathFileName != NULL && lpszUserName != NULL && lpszPassword != NULL)
	{
		if (::PathFileExists(lpszPathFileName))
		{
			CAtlStringW strConnection;

			strConnection.Format(
#if defined(USES_JET_OLEDB_DRIVER)
				L"Provider=Microsoft.Jet.OLEDB.4.0;"
#else
				L"Provider=Microsoft.ACE.OLEDB.12.0;"
#endif
				L"Data Source=%s;"
				L"User ID=%s;"
				L"Mode=Share Deny None;"
				L"Extended Properties=\"\";"
				L"Jet OLEDB:System database=\"\";"
				L"Jet OLEDB:Registry Path=\"\";"
				L"Jet OLEDB:Database Password=\"%s\";"
				L"Jet OLEDB:Engine Type=5;"
				L"Jet OLEDB:Database Locking Mode=1;"
				L"Jet OLEDB:Global Partial Bulk Ops=2;"
				L"Jet OLEDB:Global Bulk Transactions=1;"
				L"Jet OLEDB:New Database Password=\"\";"
				L"Jet OLEDB:Create System Database=False;"
				L"Jet OLEDB:Encrypt Database=False;"
				L"Jet OLEDB:Don't Copy Locale on Compact=False;"
				L"Jet OLEDB:Compact Without Replica Repair=False;"
				L"Jet OLEDB:SFP=False"
				, lpszPathFileName, lpszUserName, lpszPassword);

			hr = Open(LPCWSTR(strConnection));

			if (FAILED(hr))
			{
#ifdef _DEBUG
				ATL::AtlTraceErrorRecords(hr);
#endif
			}
		}
		else
			hr = HRESULT_FROM_WIN32(::GetLastError());
	}
	else
		hr = E_POINTER;


	return hr;
}
예제 #13
0
파일: QCNG.cpp 프로젝트: open-eid/qdigidoc
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;
}
예제 #14
0
파일: OS.cpp 프로젝트: penbor/jwebtop
			// 根据文件名获取文件所在路径
			wstring GetFilePath(wstring appDefFile){
				const int BUFSIZE = 4096;
				TCHAR  buffer[BUFSIZE] = TEXT("");
				GetFullPathName(LPCWSTR(appDefFile.data()), BUFSIZE, buffer, NULL);// 获取文件的绝对路径
				wstring pp(buffer);
				int p = pp.find_last_of('\\');
				if (p != -1)pp = pp.substr(0, p + 1);
				return pp;
			}
예제 #15
0
bool CCharsetConvert::Utf16ToMultiByte(unsigned char *pUTF16, int nUTF16Size, unsigned char *pMultiByte, int *pMultiByteSize, int nCodePage)
{
#ifdef WIN32
	bool bReturn = false;

	int nByteNeed = WideCharToMultiByte(nCodePage,0,LPCWSTR(pUTF16),nUTF16Size/sizeof(WCHAR),NULL,0,NULL,NULL);
	if (nByteNeed > 0
		&& nByteNeed < *pMultiByteSize)
	{
		*pMultiByteSize = 0;
		nByteNeed = WideCharToMultiByte(nCodePage,0,LPCWSTR(pUTF16),nUTF16Size/sizeof(WCHAR),(LPSTR)pMultiByte,nByteNeed,NULL,NULL);
		if (nByteNeed > 0)
		{
			bReturn = true;
			*pMultiByteSize = nByteNeed;
		}
	}

	return bReturn;
#else
	iconv_t cd;
	bool bReturn = false;

	cd = iconv_open(GetCodePageName(nCodePage),"UTF-16LE");
	if(cd == 0)
	{
		return false;
	}

	size_t nUtf16Size = nUTF16Size;
	size_t nOriginLen = *pMultiByteSize;
	size_t nOut = *pMultiByteSize;
	size_t nresult = iconv(cd,(char**)&pUTF16,&nUtf16Size,(char**)&pMultiByte,&nOut);
	if (nresult != (size_t)(-1))
	{
		bReturn = true;
		*pMultiByteSize = nOriginLen - nOut;
	}

	iconv_close(cd);

	return bReturn;
#endif // WIN32
}
예제 #16
0
파일: File_win32.cpp 프로젝트: 2php/mp4v2
/**
 * Open a file
 *
 * @param name the name of a file to open
 * @param mode the mode to open @p name
 *
 * @retval false successfully opened @p name
 * @retval true error opening @p name
 */
bool
StandardFileProvider::open( std::string name, Mode mode )
{
    _orig_name = name;

    DWORD access = 0;
    DWORD share  = 0;
    DWORD crdisp = 0;
    DWORD flags  = FILE_ATTRIBUTE_NORMAL;

    switch( mode ) {
        case MODE_UNDEFINED:
        case MODE_READ:
        default:
            access |= GENERIC_READ;
            share  |= FILE_SHARE_READ;
            crdisp |= OPEN_EXISTING;
            break;

        case MODE_MODIFY:
            access |= GENERIC_READ | GENERIC_WRITE;
            share  |= FILE_SHARE_READ;
            crdisp |= OPEN_EXISTING;
            break;

        case MODE_CREATE:
            access |= GENERIC_READ | GENERIC_WRITE;
            share  |= FILE_SHARE_READ;
            crdisp |= CREATE_ALWAYS;
            break;
    }

    win32::Utf8ToFilename filename(name);

    if (!filename.IsUTF16Valid())
    {
        // The logging is done
        return true;
    }

    ASSERT(LPCWSTR(filename));
    _handle = CreateFileW( filename, access, share, NULL, crdisp, flags, NULL );
    if (_handle == INVALID_HANDLE_VALUE)
    {
        log.errorf("%s: CreateFileW(%s) failed (%d)",__FUNCTION__,filename.utf8.c_str(),GetLastError());
        return true;
    }

    /*
    ** Make a copy of the name for future log messages, etc.
    */
    log.verbose2f("%s: CreateFileW(%s) succeeded",__FUNCTION__,filename.utf8.c_str());

    _name = filename.utf8;
    return false;
}
예제 #17
0
void CAddEdit_Attachment::OnAttImport()
{
  CString filter;
  CSimpleArray<GUID> aguidFileTypes;
  HRESULT hr;

  UpdateData(TRUE);

  if (m_AttFileName.IsEmpty()) {
    // Ask user for file name - annoyingly - returned string is all in upper case!
    // Remove last separator
    const CString cs_allimages(MAKEINTRESOURCE(IDS_ALL_IMAGE_FILES));
    const DWORD dwExclude = CImage::excludeOther;
    hr = m_AttImage.GetImporterFilterString(filter, aguidFileTypes, cs_allimages, dwExclude);
    ASSERT(hr >= 0);

    // Make better visually
    filter = filter.Right(filter.GetLength() - cs_allimages.GetLength());
    filter.MakeLower();
    filter = cs_allimages + filter;

    // Remove last separator to add the all files
    filter = filter.Left(filter.GetLength() - 1);

    // Add "All files"
    const CString cs_allfiles(MAKEINTRESOURCE(IDS_FDF_ALL));
    filter.Append(cs_allfiles);

    CFileDialog fileDlg(TRUE, NULL, NULL, OFN_FILEMUSTEXIST, filter, this);
    if (fileDlg.DoModal() == IDCANCEL)
      return;

    m_AttFileName = CSecString(fileDlg.GetPathName());
  } else {
    if (!pws_os::FileExists(LPCWSTR(m_AttFileName))) {
      CGeneralMsgBox gmb;
      gmb.AfxMessageBox(IDS_ATTACHMENT_NOTFOUND);
      return;
    }
  }

  // Get file information
  struct _stati64 info;
  VERIFY(_wstati64(m_AttFileName, &info) == 0);

  m_csFileCTime = PWSUtil::ConvertToDateTimeString(info.st_ctime, PWSUtil::TMC_LOCALE).c_str();
  m_csFileMTime = PWSUtil::ConvertToDateTimeString(info.st_mtime, PWSUtil::TMC_LOCALE).c_str();

  ShowPreview();

  m_ae_psh->SetChanged(true);
  Invalidate();
  UpdateControls();
  UpdateData(FALSE);
  UpdateWindow();
}
예제 #18
0
CMATLAB::CMATLAB()
{
    std::wstring wpath=string2WideString(path);
    SetDllDirectory(LPCWSTR(wpath.data()));

    libmat.setFileName("libmat");
    if (!libmat.load()) throw "CMATLAB::CMATLAB error: unable to load libmat";

    libmx.setFileName("libmx");
    if(!libmx.load()) throw "CMATLAB::CMATLAB error: unable to load libmx";

    libeng.setFileName("libeng");
    if(!libeng.load()) throw "CMATLAB::CMATLAB error: unable to load libeng";

    pMatOpen = (matftype1) libmat.resolve("matOpen");
    if (!pMatOpen)  throw "CMATLAB::CMATLAB error: unable to resolve libmat for matOpen";
    pMatClose = (matftype2) libmat.resolve("matClose");
    if (!pMatClose) throw "CMATLAB::CMATLAB error: unable to resolve libmat for matClose";
    pMatPutVariable = (matftype3) libmat.resolve("matPutVariable");
    if (!pMatPutVariable) throw "CMATLAB::CMATLAB error: unable to resolve libmat for matPutVariable";
    pMatGetVariable = (matftype4) libmat.resolve("matGetVariable");
    if (!pMatGetVariable) throw "CMATLAB::CMATLAB error: unable to resolve libmat for matGetVariable";


    pMxCreateDoubleMatrix = (mxftype1) libmx.resolve("mxCreateDoubleMatrix");
    if (!pMxCreateDoubleMatrix) throw "CMATLAB::CMATLAB error: unable to resolve libmx for mxCreateDoubleMatrix";
    pMxDestroyArray = (mxftype2) libmx.resolve("mxDestroyArray");
    if (!pMxDestroyArray) throw "CMATLAB::CMATLAB error: unable to resolve libmx for mxDestroyArray";
    pMxGetPr = (mxftype3) libmx.resolve("mxGetPr");
    if (!pMxGetPr) throw "CMATLAB::CMATLAB error: unable to resolve libmx for mxGetPr";
    pMxSetPr = (mxftype4) libmx.resolve("mxSetPr");
    if (!pMxSetPr) throw "CMATLAB::CMATLAB error: unable to resolve libmx for mxSetPr";
    pMxGetNumberOfElements = (mxftype5) libmx.resolve("mxGetNumberOfElements");
    if (!pMxGetNumberOfElements) throw "CMATLAB::CMATLAB error: unable to resolve libmx for mxGetNumberOfElements";


    pEngOpenSingleUse = (engftype1) libeng.resolve("engOpenSingleUse");
    if (!pEngOpenSingleUse) throw "CMATLAB::CMATLAB error: unable to resolve libeng for engOpenSingleUse";
    pEngOpen = (engftype2) libeng.resolve("engOpen");
    if (!pEngOpen) throw "CMATLAB::CMATLAB error: unable to resolve libeng for engOpen";
    pEngClose = (engftype3) libeng.resolve("engClose");
    if (!pEngClose) throw "CMATLAB::CMATLAB error: unable to resolve libeng for engClose";
    pEngGetVisible = (engftype4) libeng.resolve("engGetVisible");
    if (!pEngGetVisible) throw "CMATLAB::CMATLAB error: unable to resolve libeng for engGetVisible";
    pEngSetVisible = (engftype5) libeng.resolve("engSetVisible");
    if (!pEngSetVisible) throw "CMATLAB::CMATLAB error: unable to resolve libeng for engSetVisible";
    pEngEvalString = (engftype6) libeng.resolve("engEvalString");
    if (!pEngEvalString) throw "CMATLAB::CMATLAB error: unable to resolve libeng for engEvalString";
    pEngGetVariable = (engftype7) libeng.resolve("engGetVariable");
    if (!pEngGetVariable) throw "CMATLAB::CMATLAB error: unable to resolve libeng for engGetVariable";
    pEngPutVariable = (engftype8) libeng.resolve("engPutVariable");
    if (!pEngPutVariable) throw "CMATLAB::CMATLAB error: unable to resolve libeng for engPutVariable";
    pEngOutputBuffer = (engftype9) libeng.resolve("engOutputBuffer");
    if (!pEngOutputBuffer) throw "CMATLAB::CMATLAB error: unable to resolve libeng for engOutputBuffer";
}
예제 #19
0
void DXApp::Run()
{
	MSG msg = { 0 };

	BOOL bRet = 1;

	float dt = 0;
	PreInit();
	InitGame();
	LateInit();
	while (msg.message != WM_QUIT)
	{
		if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		else
		{
			m_gameTimer->Tick();
			if (!m_appPaused)
			{
				CalculateFrameStats();
				dt += m_gameTimer->DeltaTime();
				if (dt >= 1.f / TICKS_PER_SECOND)
				{
					OnTickUpdate(m_gameTimer->DeltaTime());
					LateTickUpdate(m_gameTimer->DeltaTime());
					dt = 0;
					tick++;
				}
				if (tick == TICKS_PER_SECOND)
				{
					std::wstringstream ss;
					ss << "DirectX title - FPS: ";
					ss << fps;
					BOOL b = SetWindowText(m_mainHandle, LPCWSTR(ss.str().c_str()));
					DWORD d = GetLastError();
					fps = 0;
					tick = 0;
				}
				PrepareWindow();
				RenderUpdate();
				RenderWindow();
				fps++;
			}
			else
			{
				Sleep(100);
			}
		}
	}

}
예제 #20
0
bool Prim::draw(IDirect3DDevice9* device)
{
	IDirect3DTexture9* tex = 0;
	D3DXCreateTextureFromFile(device, LPCWSTR(textureName), &tex);
	device->SetTexture(0, tex);
	device->SetTransform(D3DTS_WORLD, &d3dMat);

	if(FAILED(primMesh->DrawSubset(0)))
		return false;
	return true;
}
예제 #21
0
void CPasswordPolicyDlg::OnGeneratePassword()
{
  UpdateData(TRUE);

  PWPolicy st_pp;

  if (m_UseNamedPolicy == BST_UNCHECKED) {
    // Use specific policy but validate it first
    if (Validate() == FALSE)
      return;

    if (m_PWUseLowercase == TRUE)
      st_pp.flags |= PWPolicy::UseLowercase;
    if (m_PWUseUppercase == TRUE)
      st_pp.flags |= PWPolicy::UseUppercase;
    if (m_PWUseDigits == TRUE)
      st_pp.flags |= PWPolicy::UseDigits;
    if (m_PWUseSymbols == TRUE)
      st_pp.flags |= PWPolicy::UseSymbols;
    if (m_PWUseHexdigits == TRUE)
      st_pp.flags |= PWPolicy::UseHexDigits;
    if (m_PWEasyVision == TRUE)
      st_pp.flags |= PWPolicy::UseEasyVision;
    if (m_PWMakePronounceable == TRUE)
      st_pp.flags |= PWPolicy::MakePronounceable;
    st_pp.length = m_PWDefaultLength;
    st_pp.digitminlength = m_PWDigitMinLength;
    st_pp.lowerminlength = m_PWLowerMinLength;
    st_pp.symbolminlength = m_PWSymbolMinLength;
    st_pp.upperminlength = m_PWUpperMinLength;

    m_SymbolsEdit.GetWindowText(m_Symbols);
    st_pp.symbols = LPCWSTR(m_Symbols);
  } else {
    // Use named policy
    if (m_PolicyNameEdit.IsWindowVisible()) {
      m_PolicyNameEdit.GetWindowText((CString &)m_policyname);
    } else {
      int index = m_cbxPolicyNames.GetCurSel();
      m_cbxPolicyNames.GetLBText(index, m_policyname);
    }
    StringX sxPolicyName(m_policyname);
    GetMainDlg()->GetPolicyFromName(sxPolicyName, st_pp);
  }

  StringX passwd;
  GetMainDlg()->MakeRandomPassword(passwd, st_pp);
  m_password = passwd.c_str();
  m_ex_password.SetWindowText(m_password);
  m_ex_password.Invalidate();

  UpdateData(FALSE);
}
void DisplayKeyVolumeEnvelope::Init(HANDLE hOut)
{
	// show the note keys
	DWORD written;
	WriteConsoleOutputCharacterW(hOut, LPCWSTR(keys), KEYS, key_pos, &written);
	FillConsoleOutputAttribute(hOut, env_attrib[EnvelopeState::OFF], KEYS, key_pos, &written);

	// voice indicators
	CHAR voice[VOICES];
	memset(voice, 7, VOICES);
	WriteConsoleOutputCharacter(hOut, voice, VOICES, voice_pos, &written);
}
예제 #23
0
TokenData QCSP::selectCert( const QString &cn, SslCertificate::KeyUsage usage )
{
	TokenData t;
	t.setCard( cn );

	if( d->h )
		CryptReleaseContext( d->h, 0 );

	QPair<QString,QString> c = d->certs.value( cn );
	if( !CryptAcquireContextW( &d->h, LPCWSTR(c.second.utf16()), LPCWSTR(c.first.utf16()), PROV_RSA_FULL, 0 ) )
		return t;

	HCRYPTKEY key = 0;
	if( !CryptGetUserKey( d->h, usage == SslCertificate::NonRepudiation ? AT_SIGNATURE : AT_KEYEXCHANGE, &key ) )
		return t;

	SslCertificate cert = QSslCertificate( d->keyParam( key, KP_CERTIFICATE, 0 ), QSsl::Der );
	CryptDestroyKey( key );
	if( cert.keyUsage().keys().contains( usage ) )
		t.setCert( cert );

	return t;
}
void CPasskeyEntry::UpdateRO()
{
  if (!m_bForceReadOnly) {
    // If allowed, change R-O state to reflect file's permission - only if file is R-O
    bool fro;
    if (pws_os::FileExists(LPCWSTR(m_filespec), fro) && fro) {
      m_PKE_ReadOnly = TRUE;
      GetDlgItem(IDC_READONLY)->EnableWindow(FALSE);
      ((CButton *)GetDlgItem(IDC_READONLY))->SetCheck(BST_CHECKED);
    } else {
      GetDlgItem(IDC_READONLY)->EnableWindow(TRUE);
    }

    UpdateData(FALSE);
  } // !m_bForceReadOnly
}
예제 #25
0
파일: Video.cpp 프로젝트: thomx12/Tribute
void Video::PlayMovie(string path)
{
	IGraphBuilder *pGraph = NULL;
    IMediaControl *pControl = NULL;
    IMediaEvent   *pEvent = NULL;
	IVideoWindow  *pVideo = NULL;
	
    // Initialize the COM library.
    CoInitialize(NULL);

    // Create the filter graph manager and query for interfaces.
    CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph);

	// Build the graph
	int len;
	int slength = (int)path.length() + 1;
	len = MultiByteToWideChar(CP_ACP, 0, path.c_str(), slength, 0, 0);
	 wchar_t* buf = new wchar_t[len];
	MultiByteToWideChar(CP_ACP, 0, path.c_str(), slength, buf, len);
	 std::wstring r(buf);
	delete[] buf;

	pGraph->RenderFile(LPCWSTR(r.c_str()), NULL);

	// set the owner window
	pGraph->QueryInterface(IID_IVideoWindow, (void **) &pVideo);	
	pVideo->put_Owner((OAHWND)window);
	pVideo->put_WindowStyle( WS_CHILD );
	pVideo->put_Left(0);
	pVideo->put_Top(0);
	

    pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
    pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);

	pControl->Run();
	long evCode;
	pEvent->WaitForCompletion(-1, &evCode);
	
	// release controls
    pControl->Release();
    pEvent->Release();
    pGraph->Release();
	pVideo->Release();
    CoUninitialize();
}
예제 #26
0
//Textures Methods
HTexture* D3DCore_Impl::Texture_Load( LPCWSTR FileName )
{
	ID3D10Texture2D* texture2D = NULL;
	ID3D10Resource* pD3D10Resource = NULL;

	// Loads the texture into a temporary ID3D10Resource object
	HR( D3DX10CreateTextureFromFile(md3dDevice, LPCWSTR(FileName),
									NULL, NULL, &pD3D10Resource, NULL) );

	// Translates the ID3D10Resource object into a ID3D10Texture2D object
	HR( pD3D10Resource ->QueryInterface(__uuidof( ID3D10Texture2D), (LPVOID*)&texture2D) );
	HR( pD3D10Resource ->Release() );

	mTextureList.push_back( texture2D );

	// returns the ID3D10Texture2D object
	return texture2D;
}
예제 #27
0
파일: comm.cpp 프로젝트: winsel/VS
bool Comm::ProcessErrorMessage(char* ErrorText)
{
	char *Temp = new char[200];
	LPVOID lpMsgBuf;
	FormatMessage(
		FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
		NULL,
		GetLastError(),
		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
		(LPTSTR)&lpMsgBuf,
		0,
		NULL
		);
	sprintf_s(Temp, sizeof(Temp), "WARNING:  %s Failed with the following error: \n%s\nPort: %d\n", (char*)ErrorText, lpMsgBuf, "com2");
	MessageBox(NULL, LPCWSTR(Temp), _T("Application Error"), MB_ICONSTOP);
	LocalFree(lpMsgBuf);
	delete[] Temp;
	return true;
}
예제 #28
0
void CColumnChooserLC::OnLButtonDown(UINT nFlags, CPoint point)
{
  CListCtrl::OnLButtonDown(nFlags, point);

  // Move our text
  m_iItem = HitTest(point);
  if (m_iItem == -1)
    return;

  // Start of Drag of column (m_iItem) from Column Chooser dialog to.....
  CString cs_text;
  DWORD_PTR dw_type;

  dw_type = GetItemData(m_iItem);

  // ListView HeaderCtrl only needs the type as it uses main routine
  // to add/delete columns via SendMessage
  cs_text.Format(L"%08x%02x%02x", GetCurrentProcessId(), FROMCC, dw_type);

  // Get client window position
  CPoint currentClientPosition;
  currentClientPosition = ::GetMessagePos();
  ScreenToClient(&currentClientPosition);

  // Set drag image
  m_pDragImage = CreateDragImage(m_iItem, &currentClientPosition);
  m_pDragImage->BeginDrag(0, CPoint(8, 8));
  m_pDragImage->DragEnter(GetDesktopWindow(), point);

  // Get client rectangle
  RECT rClient;
  GetClientRect(&rClient);

  // Start dragging
  StartDragging((BYTE *)LPCWSTR(cs_text),
        cs_text.GetLength() * sizeof(wchar_t),
        m_ccddCPFID, &rClient, &point);

  // End dragging image
  m_pDragImage->DragLeave(GetDesktopWindow());
  m_pDragImage->EndDrag();
  delete m_pDragImage;
}
예제 #29
0
int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) const
{
    if (d->dirty)
        d->init();

    //* from Windows documentation *
    // Returns one of the following values if successful. To maintain the C runtime convention of
    // comparing strings, the value 2 can be subtracted from a nonzero return value. Then, the
    // meaning of <0, ==0, and >0 is consistent with the C runtime.

#ifndef USE_COMPARESTRINGEX
    return CompareString(d->localeID, d->collator,
                         reinterpret_cast<const wchar_t*>(s1), len1,
                         reinterpret_cast<const wchar_t*>(s2), len2) - 2;
#else
    return CompareStringEx(LPCWSTR(d->localeName.utf16()), d->collator,
                           reinterpret_cast<LPCWSTR>(s1), len1,
                           reinterpret_cast<LPCWSTR>(s2), len2, NULL, NULL, 0) - 2;
#endif
}
예제 #30
0
/// <summary>
/// Attempts to paste the contents of the clipboard to the desktop
/// </summary>
void TileGroup::DoPaste() {
  if (IsClipboardFormatAvailable(CF_HDROP)) {
    if (OpenClipboard(mWindow->GetWindowHandle())) {
      LPDROPFILES data = LPDROPFILES(GetClipboardData(CF_HDROP));
      bool move = false;
      WCHAR target[MAX_PATH];

      // Check if the file should be moved rather than copied.
      UINT cfDropEffect = RegisterClipboardFormat(CFSTR_PREFERREDDROPEFFECT);
      if (IsClipboardFormatAvailable(cfDropEffect)) {
        move = (*(DWORD*)GetClipboardData(cfDropEffect) & DROPEFFECT_MOVE) == DROPEFFECT_MOVE;
      }

      GetFolderPath(target, _countof(target));

      // TODO::Handle data->fWide == 0
      SHFILEOPSTRUCTW shFileOp;
      ZeroMemory(&shFileOp, sizeof(shFileOp));
      shFileOp.wFunc = move ? FO_MOVE : FO_COPY;
      shFileOp.hwnd = mWindow->GetWindowHandle();
      shFileOp.pFrom = LPCWSTR((BYTE*)data + data->pFiles);
      shFileOp.pTo = target;
      shFileOp.fFlags = FOF_NOCONFIRMMKDIR;
      SHFileOperationW(&shFileOp);

      if (move && !shFileOp.fAnyOperationsAborted) {
        EmptyClipboard();
      }

      CloseClipboard();
    }
  }
  else if (IsClipboardFormatAvailable(CF_TEXT)) {
  }
  else if (IsClipboardFormatAvailable(CF_BITMAP)) {
  }
  else if (IsClipboardFormatAvailable(CF_WAVE)) {
  }
}