当前位置: 首页>>代码示例>>C++>>正文


C++ GlobalLock函数代码示例

本文整理汇总了C++中GlobalLock函数的典型用法代码示例。如果您正苦于以下问题:C++ GlobalLock函数的具体用法?C++ GlobalLock怎么用?C++ GlobalLock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GlobalLock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateDialogBoxHandle


//.........这里部分代码省略.........
// procédé, on inclut aussi les pointeurs sur les chaînes de caractères.
	size  = sizeof ( DLGTEMPLATE ) +
			( sizeof ( DLGITEMTEMPLATE ) * DlgTemplate. dtItemCount ) ;
	size += strlen ( DlgTemplate. dtMenuName ) 	+ 1 +
		strlen ( DlgTemplate. dtClassName )     + 1 +
		strlen ( DlgTemplate. dtCaptionText )	+ 1 ;

	for  ( i = 0, pItem = ItemTemplates ;
			i < DlgTemplate. dtItemCount ;
				i ++, pItem ++ )
		size += strlen ( pItem -> dtilClass ) 	+ 1 +
			strlen ( pItem -> dtilText )	+ 1 ;

	memp    = memory_dialog = new  char [ size ] ;
	memset ( memp, 0, size ) ;
	memsize = size ;


// La place mémoire est allouée pour la définition du dialogue : on copie
// maintenant les données de la boîte.

// Recopie des champs entiers
	size  = sizeof ( DlgTemplate. dtStyle ) 	+
		sizeof ( DlgTemplate. dtItemCount )	+
		sizeof ( DlgTemplate. dtX )		+
		sizeof ( DlgTemplate. dtY )		+
		sizeof ( DlgTemplate. dtCX )		+
		sizeof ( DlgTemplate. dtCY ) ;
	memmove ( memp, & DlgTemplate. dtStyle, size ) ;
	memp += size ;

 // Recopie du nom de menu, de la classe et du titre
	strcpy ( memp, DlgTemplate. dtMenuName ) ;
	memp += strlen ( DlgTemplate. dtMenuName ) + 1 ;

	strcpy ( memp, DlgTemplate. dtClassName ) ;
	memp += strlen ( DlgTemplate. dtClassName ) + 1 ;

	strcpy ( memp, DlgTemplate. dtCaptionText ) ;
	memp += strlen ( DlgTemplate. dtCaptionText ) + 1 ;

// Taille et nom de la police
	memmove ( memp, & FontInfo. PointSize, sizeof ( FontInfo. PointSize ) ) ;
	memp += sizeof ( FontInfo. PointSize ) ;

	strcpy ( memp, FontInfo. szTypeFace ) ;
	memp += strlen ( FontInfo. szTypeFace ) + 1 ;


// Recopie des contrôles
	for  ( i = 0, pItem = ItemTemplates ; i < DlgTemplate. dtItemCount ; i ++, pItem ++ )
	   {

	// Recopie des premiers champs numériques
		size  = sizeof ( pItem -> dtilX )  +
			sizeof ( pItem -> dtilY )  +
			sizeof ( pItem -> dtilCX ) +
			sizeof ( pItem -> dtilCY ) +
			sizeof ( pItem -> dtilID ) +
			sizeof ( pItem -> dtilStyle ) ;

		memmove ( memp, & pItem -> dtilX, size ) ;
		memp += size ;

	// Recopie de la classe et du texte
		strcpy ( memp, pItem -> dtilClass ) ;
		memp += strlen ( pItem -> dtilClass ) + 1 ;

		strcpy ( memp, pItem -> dtilText ) ;
		memp += strlen ( pItem -> dtilText ) + 1 ;

	// Recopie des éventuelles données propres à ce contrôle
		memmove ( memp, & pItem -> dtilInfo, sizeof ( pItem -> dtilInfo ) ) ;
		memp += sizeof ( pItem -> dtilInfo ) ;

		if  ( pItem -> dtilInfo )
		   {
			memmove ( memp, pItem -> dtilData, pItem -> dtilInfo ) ;
			memp += pItem -> dtilInfo ;
		    }
	}



// Allocation d'un bloc de mémoire globale pour y placer la définition de
// la boîte
	handle = GlobalAlloc ( GMEM_FIXED, memsize ) ;
	globalp      = ( char far * ) GlobalLock  ( handle ) ;
	movedata ( FP_SEG ( memory_dialog ), FP_OFF ( memory_dialog ),
		   FP_SEG ( globalp       ), FP_OFF ( globalp ),
			memsize ) ;
	GlobalUnlock ( handle ) ;


// Effacement de tous les objects alloués
	delete []  memory_dialog ;


	return ( handle ) ;
    }
开发者ID:wuthering-bytes,项目名称:cheops,代码行数:101,代码来源:UTIL.CPP

示例2: GetNextItem

void CIOSFileList::OnLvnBegindrag(NMHDR *pNMHDR, LRESULT *pResult)
{
	CIOSDirectoryTree::m_askIsTransPng = true;
	CIOSDirectoryTree::m_askIsTransPlist = true;
	LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);

	UINT uFileCount = 0;
	int iItem = GetNextItem(-1,LVNI_SELECTED);
	std::vector<std::wstring> names;
	std::vector<int> items;
	while (iItem != -1)
	{
		std::wstring name = this->GetItemText(iItem, 0).GetString();
		std::wstring path = m_indexList->GetPathByHTreeItem(m_hTreeItem) + name;
		if (m_indexList->IsFolderItem(path, true))
		{
			iItem = GetNextItem(iItem,LVNI_SELECTED);
			continue;
		}
		++uFileCount;
		names.push_back(name);
		items.push_back(iItem);
		iItem = GetNextItem(iItem,LVNI_SELECTED);
	}

	UINT uBuffSize = sizeof(FILEGROUPDESCRIPTOR) + (uFileCount) * sizeof(FILEDESCRIPTOR);
	HGLOBAL hFileDescriptor = GlobalAlloc (GHND | GMEM_SHARE, uBuffSize);        
	if(hFileDescriptor)
	{
		FILEGROUPDESCRIPTOR* pGroupDescriptor = (FILEGROUPDESCRIPTOR*) GlobalLock ( hFileDescriptor );
		if(pGroupDescriptor)
		{
			FILEDESCRIPTOR* pFileDescriptorArray = (FILEDESCRIPTOR*)((LPBYTE)pGroupDescriptor + sizeof(UINT));
			pGroupDescriptor->cItems = uFileCount;
			for (size_t index = 0; index < names.size(); ++index)
			{          
				ZeroMemory(&pFileDescriptorArray[index], sizeof(FILEDESCRIPTOR));
				pFileDescriptorArray[index].dwFlags = FD_FILESIZE|FD_ATTRIBUTES;

				int size = 0;
				for (size_t i = 0; i < m_itemDatas.size(); ++i)
				{
					if (m_itemDatas[i])
					{
						if (!wcscmp(m_itemDatas[i]->itemData[0]->strValue, names[index].c_str()))
						{
							size = m_itemDatas[i]->itemData[2]->intValue;
							break;
						}
					}
				}
				pFileDescriptorArray[index].nFileSizeLow = size;
				pFileDescriptorArray[index].nFileSizeHigh = 0;
				pFileDescriptorArray[index].dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
				lstrcpy ( pFileDescriptorArray[index].cFileName, names[index].c_str());	
			}
			GlobalUnlock ( hFileDescriptor ); 
		}
	}
	else
	{
		GlobalFree ( hFileDescriptor );
	}


	CHOleDataSource dragDataSource;
	dragDataSource.SetAssociat(items, m_indexList);
	FORMATETC etcDescriptor = { RegisterClipboardFormat(CFSTR_FILEDESCRIPTOR), NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
	dragDataSource.CacheGlobalData( RegisterClipboardFormat(CFSTR_FILEDESCRIPTOR), hFileDescriptor, &etcDescriptor );

	FORMATETC etcContents = {RegisterClipboardFormat(CFSTR_FILECONTENTS), NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
	dragDataSource.DelayRenderFileData(RegisterClipboardFormat(CFSTR_FILECONTENTS), &etcContents);

	DROPEFFECT dwEffect = dragDataSource.DoDragDrop( DROPEFFECT_COPY | DROPEFFECT_MOVE );
	if(dwEffect == DROPEFFECT_NONE )
	{
		GlobalFree( hFileDescriptor );
	} 

	CIOSDirectoryTree::m_askIsTransPng = true;
	CIOSDirectoryTree::m_askIsTransPlist = true;
	*pResult = 0;
}
开发者ID:babaloveyou,项目名称:iOs-Explorer,代码行数:83,代码来源:ios_file_list.cpp

示例3: WDML_ServerHandleAdvise

/******************************************************************
 *		WDML_ServerHandleAdvise
 *
 *
 */
static	WDML_QUEUE_STATE WDML_ServerHandleAdvise(WDML_CONV* pConv, WDML_XACT* pXAct)
{
    UINT		uType;
    WDML_LINK*		pLink;
    DDEADVISE*		pDdeAdvise;
    HDDEDATA		hDdeData = 0;
    BOOL		fAck = TRUE;

    pDdeAdvise = GlobalLock(pXAct->hMem);
    uType = XTYP_ADVSTART |
	    (pDdeAdvise->fDeferUpd ? XTYPF_NODATA : 0) |
	    (pDdeAdvise->fAckReq ? XTYPF_ACKREQ : 0);

    if (!(pConv->instance->CBFflags & CBF_FAIL_ADVISES))
    {
	hDdeData = WDML_InvokeCallback(pConv->instance, XTYP_ADVSTART, pDdeAdvise->cfFormat,
				       (HCONV)pConv, pConv->hszTopic, pXAct->hszItem, 0, 0, 0);
    }

    switch ((ULONG_PTR)hDdeData)
    {
    case 0:
	TRACE("No data returned from the Callback\n");
	fAck = FALSE;
	break;

    case (ULONG_PTR)CBR_BLOCK:
	return WDML_QS_BLOCK;

    default:
	/* billx: first to see if the link is already created. */
	pLink = WDML_FindLink(pConv->instance, (HCONV)pConv, WDML_SERVER_SIDE,
			      pXAct->hszItem, TRUE, pDdeAdvise->cfFormat);

	if (pLink != NULL)
	{
	    /* we found a link, and only need to modify it in case it changes */
	    pLink->transactionType = uType;
	}
	else
	{
	    TRACE("Adding Link with hConv %p\n", pConv);
	    WDML_AddLink(pConv->instance, (HCONV)pConv, WDML_SERVER_SIDE,
			 uType, pXAct->hszItem, pDdeAdvise->cfFormat);
	}
	break;
    }

    GlobalUnlock(pXAct->hMem);
    if (fAck)
    {
	GlobalFree(pXAct->hMem);
    }
    pXAct->hMem = 0;

    WDML_PostAck(pConv, WDML_SERVER_SIDE, 0, FALSE, fAck, pXAct->atom, pXAct->lParam, WM_DDE_ADVISE);

    WDML_DecHSZ(pConv->instance, pXAct->hszItem);

    return WDML_QS_HANDLED;
}
开发者ID:Moteesh,项目名称:reactos,代码行数:66,代码来源:ddeserver.c

示例4: test_PrintDlgExW


//.........这里部分代码省略.........
    pDlg->lStructSize = sizeof(PRINTDLGEXW);
    pDlg->hwndOwner = GetDesktopWindow();
    pDlg->Flags = PD_RETURNDEFAULT | PD_NOWARNING;
    pDlg->nStartPage = START_PAGE_GENERAL;
    res = pPrintDlgExW(pDlg);
    ok((res == E_INVALIDARG), "got 0x%x (expected 'E_INVALIDARG')\n", res);

    /* this is invalid: a valid lpPageRanges with 0 for nMaxPageRanges */
    ZeroMemory(pDlg, sizeof(PRINTDLGEXW));
    pDlg->lStructSize = sizeof(PRINTDLGEXW);
    pDlg->hwndOwner = GetDesktopWindow();
    pDlg->Flags = PD_RETURNDEFAULT | PD_NOWARNING;
    pDlg->lpPageRanges = pagerange;
    pDlg->nStartPage = START_PAGE_GENERAL;
    res = pPrintDlgExW(pDlg);
    ok((res == E_INVALIDARG), "got 0x%x (expected 'E_INVALIDARG')\n", res);

    /* this is invalid: NULL for lpPageRanges with a valid nMaxPageRanges */
    ZeroMemory(pDlg, sizeof(PRINTDLGEXW));
    pDlg->lStructSize = sizeof(PRINTDLGEXW);
    pDlg->hwndOwner = GetDesktopWindow();
    pDlg->Flags = PD_RETURNDEFAULT | PD_NOWARNING;
    pDlg->nMaxPageRanges = 1;
    pDlg->nStartPage = START_PAGE_GENERAL;
    res = pPrintDlgExW(pDlg);
    ok((res == E_INVALIDARG), "got 0x%x (expected 'E_INVALIDARG')\n", res);

    /* this works: lpPageRanges with a valid nMaxPageRanges */
    ZeroMemory(pDlg, sizeof(PRINTDLGEXW));
    pDlg->lStructSize = sizeof(PRINTDLGEXW);
    pDlg->hwndOwner = GetDesktopWindow();
    pDlg->Flags = PD_RETURNDEFAULT | PD_NOWARNING;
    pDlg->nMaxPageRanges = 1;
    pDlg->lpPageRanges = pagerange;
    pDlg->nStartPage = START_PAGE_GENERAL;
    res = pPrintDlgExW(pDlg);
    if (res == E_FAIL)
    {
        skip("No printer configured.\n");
        HeapFree(GetProcessHeap(), 0, pDlg);
        return;
    }

    ok(res == S_OK, "got 0x%x (expected S_OK)\n", res);

    dn = GlobalLock(pDlg->hDevNames);
    ok(dn != NULL, "expected '!= NULL' for GlobalLock(%p)\n",pDlg->hDevNames);
    if (dn)
    {
        ok(dn->wDriverOffset, "(expected '!= 0' for wDriverOffset)\n");
        ok(dn->wDeviceOffset, "(expected '!= 0' for wDeviceOffset)\n");
        ok(dn->wOutputOffset, "(expected '!= 0' for wOutputOffset)\n");
        ok(dn->wDefault == DN_DEFAULTPRN, "got 0x%x (expected DN_DEFAULTPRN)\n", dn->wDefault);

        GlobalUnlock(pDlg->hDevNames);
    }
    GlobalFree(pDlg->hDevMode);
    GlobalFree(pDlg->hDevNames);

    /* this works also: PD_NOPAGENUMS */
    ZeroMemory(pDlg, sizeof(PRINTDLGEXW));
    pDlg->lStructSize = sizeof(PRINTDLGEXW);
    pDlg->hwndOwner = GetDesktopWindow();
    pDlg->Flags = PD_RETURNDEFAULT | PD_NOWARNING | PD_NOPAGENUMS;
    pDlg->nStartPage = START_PAGE_GENERAL;
    res = pPrintDlgExW(pDlg);
    ok(res == S_OK, "got 0x%x (expected S_OK)\n", res);
    GlobalFree(pDlg->hDevMode);
    GlobalFree(pDlg->hDevNames);

    /* this works: PD_RETURNDC with PD_RETURNDEFAULT */
    ZeroMemory(pDlg, sizeof(PRINTDLGEXW));
    pDlg->lStructSize = sizeof(PRINTDLGEXW);
    pDlg->hwndOwner = GetDesktopWindow();
    pDlg->Flags = PD_RETURNDEFAULT | PD_NOWARNING | PD_NOPAGENUMS | PD_RETURNDC;
    pDlg->nStartPage = START_PAGE_GENERAL;
    res = pPrintDlgExW(pDlg);
    ok(res == S_OK, "got 0x%x (expected S_OK)\n", res);
    ok(pDlg->hDC != NULL, "HDC missing for PD_RETURNDC\n");
    GlobalFree(pDlg->hDevMode);
    GlobalFree(pDlg->hDevNames);
    DeleteDC(pDlg->hDC);

    /* this works: PD_RETURNIC with PD_RETURNDEFAULT */
    ZeroMemory(pDlg, sizeof(PRINTDLGEXW));
    pDlg->lStructSize = sizeof(PRINTDLGEXW);
    pDlg->hwndOwner = GetDesktopWindow();
    pDlg->Flags = PD_RETURNDEFAULT | PD_NOWARNING | PD_NOPAGENUMS | PD_RETURNIC;
    pDlg->nStartPage = START_PAGE_GENERAL;
    res = pPrintDlgExW(pDlg);
    ok(res == S_OK, "got 0x%x (expected S_OK)\n", res);
    ok(pDlg->hDC != NULL, "HDC missing for PD_RETURNIC\n");
    GlobalFree(pDlg->hDevMode);
    GlobalFree(pDlg->hDevNames);
    DeleteDC(pDlg->hDC);

    HeapFree(GetProcessHeap(), 0, pDlg);
    return;

}
开发者ID:AmesianX,项目名称:RosWine,代码行数:101,代码来源:printdlg.c

示例5: __declspec

// Here you can process the Npp Messages 
// I will make the messages accessible little by little, according to the need of plugin development.
// Please let me know if you need to access to some messages :
// http://sourceforge.net/forum/forum.php?forum_id=482781
//
extern "C" __declspec(dllexport) LRESULT messageProc(UINT Message, WPARAM wParam, LPARAM lParam)
{
	switch (Message){
		case WM_CREATE:
		hInst = GetModuleHandle(NULL);

		//Create PopupMenu Dynamically
		HGLOBAL hgbl;
		LPDLGTEMPLATE lpdt;
		LPWORD lpw;
		hwndEdit = nppData._scintillaMainHandle;
		hgbl = GlobalAlloc(GMEM_ZEROINIT, 1024);

		lpdt = (LPDLGTEMPLATE)GlobalLock(hgbl);

		// Define a dialog box.

		lpdt->style = WS_POPUP | WS_BORDER ;
		lpdt->cdit = 0;         // Number of controls = 0
		lpdt->x  = 10;  lpdt->y  = 10;
		lpdt->cx = 100; lpdt->cy = 100;

		lpw = (LPWORD)(lpdt + 1);
		*lpw++ = 0;             // No menu
		*lpw++ = 0;             // Predefined dialog box class (by default)

		GlobalUnlock(hgbl);
		hwndPopupMenu = CreateDialogIndirect(hInst,
			(LPDLGTEMPLATE)hgbl,
			nppData._nppHandle,
			(DLGPROC)PopupMenuProc);
		GlobalFree(hgbl);
		
		//End PopupMenuDialog

		hfontCurrent = MyCreateFont(nppData._nppHandle, 10,L"Zawgyi-One");
		EditProc =(WNDPROC)GetWindowLongW(nppData._scintillaMainHandle, GWL_WNDPROC);
		SetWindowLong(nppData._scintillaMainHandle, GWL_WNDPROC, (long)SubEditProc);
		hMenu = GetMenu(nppData._nppHandle);
		CheckMenuItem(hMenu,funcItem[1]._cmdID,MF_BYCOMMAND|MF_CHECKED);//Check Disable Menu
		break;
		case WM_MOVE:
			//move menu along with the main window
			if(IsWindowVisible(hwndPopupMenu))
			{
				RECT rctWinMain;
				GetWindowRect(hwndEdit,&rctWinMain);

				int height=(burmese.menuLength>MROW?10:burmese.menuLength)*MHEIGHT+MHEIGHT+10;
				int width=((burmese.menuLength/MROW)+1)*MWIDTH;

				MoveWindow (hwndPopupMenu,
					rctWinMain.left + pointEditCursor.x + 10,
					rctWinMain.top + pointEditCursor.y + 20 ,
					width,
					height,
					TRUE) ;
			}
	        
			break;
		}
	return true;
}
开发者ID:aungkozaw,项目名称:zawgyi,代码行数:68,代码来源:Plugin+Main.cpp

示例6: WindowSetIcon

void CJabberDlgGcJoin::OnInitDialog()
{
	CSuper::OnInitDialog();

	WindowSetIcon(m_hwnd, m_proto, "group");

	JabberGcRecentInfo *pInfo = NULL;
	if (m_jid)
		pInfo = new JabberGcRecentInfo(m_proto, m_jid);
	else if(OpenClipboard(m_hwnd)) {
		HANDLE hData = GetClipboardData(CF_UNICODETEXT);

		if (hData) {
			TCHAR *buf = (TCHAR *)GlobalLock(hData);
			if (buf && _tcschr(buf, _T('@')) && !_tcschr(buf, _T(' ')))
				pInfo = new JabberGcRecentInfo(m_proto, buf);
			GlobalUnlock(hData);
		}
		CloseClipboard();
	}

	if (pInfo) {
		pInfo->fillForm(m_hwnd);
		delete pInfo;
	}

	ptrT tszNick(m_proto->getTStringA("Nick"));
	if (tszNick == NULL)
		tszNick = JabberNickFromJID(m_proto->m_szJabberJID);
	SetDlgItemText(m_hwnd, IDC_NICK, tszNick);

	TEXTMETRIC tm = { 0 };
	HDC hdc = GetDC(m_hwnd);
	GetTextMetrics(hdc, &tm);
	ReleaseDC(m_hwnd, hdc);
	sttTextLineHeight = tm.tmHeight;
	SendDlgItemMessage(m_hwnd, IDC_ROOM, CB_SETITEMHEIGHT, -1, sttTextLineHeight - 1);

	LOGFONT lf = { 0 };
	HFONT hfnt = (HFONT)SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_GETFONT, 0, 0);
	GetObject(hfnt, sizeof(lf), &lf);
	lf.lfWeight = FW_BOLD;
	SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), TRUE);

	SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx("bookmarks"));
	SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONSETASFLATBTN, TRUE, 0);
	SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONADDTOOLTIP, (WPARAM)"Bookmarks", 0);
	SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONSETASPUSHBTN, TRUE, 0);

	m_proto->ComboLoadRecentStrings(m_hwnd, IDC_SERVER, "joinWnd_rcSvr");

	int i;
	for (i = 0; i < 5; i++) {
		TCHAR jid[JABBER_MAX_JID_LEN];
		JabberGcRecentInfo info(m_proto);
		if (!info.loadRecent(i))
			break;

		mir_sntprintf(jid, _T("%[email protected]%s (%s)"), info.m_room, info.m_server, info.m_nick ? info.m_nick : TranslateT("<no nick>"));
		SetDlgItemText(m_hwnd, IDC_RECENT1 + i, jid);
	}
	sttJoinDlgShowRecentItems(m_hwnd, i);
}
开发者ID:kxepal,项目名称:miranda-ng,代码行数:63,代码来源:jabber_groupchat.cpp

示例7: _T

void CAboutDlg::OnCopyToClipboard()
{
    CStringW info = m_appname + _T("\r\n");
    info += CString(_T('-'), m_appname.GetLength()) + _T("\r\n\r\n");
    info += _T("Build information:\r\n");
    info += _T("    Version:            ") + m_strBuildNumber + _T("\r\n");
    info += _T("    Compiler:           ") + m_MPCCompiler + _T("\r\n");
    info += _T("    Build date:         ") + m_buildDate + _T("\r\n\r\n");
#ifndef MPCHC_LITE
    info += _T("LAV Filters:\r\n");
    info += _T("    LAV Splitter:       ") + CFGFilterLAV::GetVersion(CFGFilterLAV::SPLITTER) + _T("\r\n");
    info += _T("    LAV Video:          ") + CFGFilterLAV::GetVersion(CFGFilterLAV::VIDEO_DECODER) + _T("\r\n");
    info += _T("    LAV Audio:          ") + CFGFilterLAV::GetVersion(CFGFilterLAV::AUDIO_DECODER) + _T("\r\n");
    info += _T("    FFmpeg compiler:    ") + VersionInfo::GetGCCVersion() + _T("\r\n\r\n");
#endif
    info += _T("Operating system:\r\n");
    info += _T("    Name:               ") + m_OSName + _T("\r\n");
    info += _T("    Version:            ") + m_OSVersion + _T("\r\n\r\n");

    info += _T("Hardware:\r\n");

    CRegKey key;
    if (key.Open(HKEY_LOCAL_MACHINE, _T("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"), KEY_READ) == ERROR_SUCCESS) {
        ULONG nChars = 0;
        if (key.QueryStringValue(_T("ProcessorNameString"), nullptr, &nChars) == ERROR_SUCCESS) {
            CString cpuName;
            if (key.QueryStringValue(_T("ProcessorNameString"), cpuName.GetBuffer(nChars), &nChars) == ERROR_SUCCESS) {
                cpuName.ReleaseBuffer(nChars);
                cpuName.Trim();
                info.AppendFormat(_T("    CPU:                %s\r\n"), cpuName);
            }
        }
    }

    if (CComPtr<IDirect3D9> pD3D9 = Direct3DCreate9(D3D_SDK_VERSION)) {
        for (UINT adapter = 0, adapterCount = pD3D9->GetAdapterCount(); adapter < adapterCount; adapter++) {
            D3DADAPTER_IDENTIFIER9 adapterIdentifier;
            if (pD3D9->GetAdapterIdentifier(adapter, 0, &adapterIdentifier) == D3D_OK) {
                CString deviceName = adapterIdentifier.Description;
                deviceName.Trim();

                if (adapterCount > 1) {
                    info.AppendFormat(_T("    GPU%u:               %s"), adapter + 1, deviceName);
                } else {
                    info.AppendFormat(_T("    GPU:                %s"), deviceName);
                }
                if (adapterIdentifier.DriverVersion.QuadPart) {
                    info.AppendFormat(_T(" (driver version: %s)"),
                                      FileVersionInfo::FormatVersionString(adapterIdentifier.DriverVersion.LowPart, adapterIdentifier.DriverVersion.HighPart));
                }
                info += _T("\r\n");
            }
        }
    }

    // Allocate a global memory object for the text
    int len = info.GetLength() + 1;
    HGLOBAL hGlob = GlobalAlloc(GMEM_MOVEABLE, len * sizeof(WCHAR));
    if (hGlob) {
        // Lock the handle and copy the text to the buffer
        LPVOID pData = GlobalLock(hGlob);
        if (pData) {
            wcscpy_s((WCHAR*)pData, len, (LPCWSTR)info);
            GlobalUnlock(hGlob);

            if (GetParent()->OpenClipboard()) {
                // Place the handle on the clipboard, if the call succeeds
                // the system will take care of the allocated memory
                if (::EmptyClipboard() && ::SetClipboardData(CF_UNICODETEXT, hGlob)) {
                    hGlob = nullptr;
                }

                ::CloseClipboard();
            }
        }

        if (hGlob) {
            GlobalFree(hGlob);
        }
    }
}
开发者ID:JanChou,项目名称:mpc-hc,代码行数:81,代码来源:AboutDlg.cpp

示例8: ReadDIBFile

HANDLE ReadDIBFile(int hFile)
{
   BITMAPFILEHEADER bmfHeader;
   DWORD dwBitsSize;
   UINT nNumColors;   // Number of colors in table
   HANDLE hDIB;        
   HANDLE hDIBtmp;    // Used for GlobalRealloc() //MPB
   LPBITMAPINFOHEADER lpbi;
   DWORD offBits;

   /*
    * get length of DIB in bytes for use when reading
    */

   dwBitsSize = filelength(hFile);

   // Allocate memory for header & color table.	We'll enlarge this
   // memory as needed.

   hDIB = GlobalAlloc(GMEM_MOVEABLE,
       (DWORD)(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)));
   
   if (!hDIB) return NULL;

   lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
   if (!lpbi) 
   {
     GlobalFree(hDIB);
     return NULL;
   }

   // read the BITMAPFILEHEADER from our file

   if (sizeof (BITMAPFILEHEADER) != _lread (hFile, (LPSTR)&bmfHeader, sizeof (BITMAPFILEHEADER)))
     goto ErrExit;

   if (bmfHeader.bfType != 0x4d42)	/* 'BM' */
     goto ErrExit;

   // read the BITMAPINFOHEADER

   if (sizeof(BITMAPINFOHEADER) != _lread (hFile, (LPSTR)lpbi, sizeof(BITMAPINFOHEADER)))
     goto ErrExit;

   // Check to see that it's a Windows DIB -- an OS/2 DIB would cause
   // strange problems with the rest of the DIB API since the fields
   // in the header are different and the color table entries are
   // smaller.
   //
   // If it's not a Windows DIB (e.g. if biSize is wrong), return NULL.

   if (lpbi->biSize == sizeof(BITMAPCOREHEADER))
     goto ErrExit;

   // Now determine the size of the color table and read it.  Since the
   // bitmap bits are offset in the file by bfOffBits, we need to do some
   // special processing here to make sure the bits directly follow
   // the color table (because that's the format we are susposed to pass
   // back)

   if (!(nNumColors = (UINT)lpbi->biClrUsed))
    {
      // no color table for 24-bit, default size otherwise
      if (lpbi->biBitCount != 24)
        nNumColors = 1 << lpbi->biBitCount; /* standard size table */
    }

   // fill in some default values if they are zero
   if (lpbi->biClrUsed == 0)
     lpbi->biClrUsed = nNumColors;

   if (lpbi->biSizeImage == 0)
   {
     lpbi->biSizeImage = ((((lpbi->biWidth * (DWORD)lpbi->biBitCount) + 31) & ~31) >> 3)
			 * lpbi->biHeight;
   }
开发者ID:willmomo,项目名称:ry2kojima,代码行数:76,代码来源:FILE.C

示例9: OnMenuPrint


//.........这里部分代码省略.........
    pd.nMaxPage = dm->PageCount();
    pd.nStartPage = START_PAGE_GENERAL;

    Print_Advanced_Data advanced(PrintRangeAll, defaultScaleAdv);
    ScopedMem<DLGTEMPLATE> dlgTemplate; // needed for RTL languages
    HPROPSHEETPAGE hPsp = CreatePrintAdvancedPropSheet(&advanced, dlgTemplate);
    pd.lphPropertyPages = &hPsp;
    pd.nPropertyPages = 1;

    LPDEVNAMES devNames;
    LPDEVMODE devMode;
    bool failedEngineClone;
    PrintData *data = nullptr;

    // restore remembered settings
    if (defaultDevMode) {
        DEVMODE *p = defaultDevMode.Get();
        pd.hDevMode = GlobalMemDup(p, p->dmSize + p->dmDriverExtra);
    }

    if (PrintDlgEx(&pd) != S_OK) {
        if (CommDlgExtendedError() != 0) {
            /* if PrintDlg was cancelled then
               CommDlgExtendedError is zero, otherwise it returns the
               error code, which we could look at here if we wanted.
               for now just warn the user that printing has stopped
               becasue of an error */
            MessageBoxWarning(win->hwndFrame, _TR("Couldn't initialize printer"),
                              _TR("Printing problem."));
        }
        goto Exit;
    }

    if (pd.dwResultAction == PD_RESULT_PRINT || pd.dwResultAction == PD_RESULT_APPLY) {
        // remember settings for this process
        devMode = (LPDEVMODE)GlobalLock(pd.hDevMode);
        if (devMode) {
            defaultDevMode.Set(
                (LPDEVMODE)memdup(devMode, devMode->dmSize + devMode->dmDriverExtra));
            GlobalUnlock(pd.hDevMode);
        }
        defaultScaleAdv = advanced.scale;
    }

    if (pd.dwResultAction != PD_RESULT_PRINT)
        goto Exit;

    if (pd.Flags & PD_CURRENTPAGE) {
        PRINTPAGERANGE pr = { (DWORD)dm->CurrentPageNo(), (DWORD)dm->CurrentPageNo() };
        ranges.Append(pr);
    } else if (win->currentTab->selectionOnPage && (pd.Flags & PD_SELECTION)) {
        printSelection = true;
    } else if (!(pd.Flags & PD_PAGENUMS)) {
        PRINTPAGERANGE pr = { 1, (DWORD)dm->PageCount() };
        ranges.Append(pr);
    } else {
        assert(pd.nPageRanges > 0);
        for (DWORD i = 0; i < pd.nPageRanges; i++)
            ranges.Append(pd.lpPageRanges[i]);
    }

    devNames = (LPDEVNAMES)GlobalLock(pd.hDevNames);
    devMode = (LPDEVMODE)GlobalLock(pd.hDevMode);
    if (devNames) {
        printerInfo.pDriverName = (LPWSTR)devNames + devNames->wDriverOffset;
        printerInfo.pPrinterName = (LPWSTR)devNames + devNames->wDeviceOffset;
        printerInfo.pPortName = (LPWSTR)devNames + devNames->wOutputOffset;
    }
    data =
        new PrintData(dm->GetEngine(), &printerInfo, devMode, ranges, advanced, dm->GetRotation(),
                      printSelection ? win->currentTab->selectionOnPage : nullptr);
    if (devNames)
        GlobalUnlock(pd.hDevNames);
    if (devMode)
        GlobalUnlock(pd.hDevMode);

    // if a file is missing and the engine can't thus be cloned,
    // we print using the original engine on the main thread
    // so that the document can't be closed and the original engine
    // unexpectedly deleted
    // TODO: instead prevent closing the document so that printing
    // can still happen on a separate thread and be interruptible
    failedEngineClone = dm->GetEngine() && !data->engine;
    if (failedEngineClone)
        data->engine = dm->GetEngine();

    if (!waitForCompletion && !failedEngineClone)
        PrintToDeviceOnThread(win, data);
    else {
        PrintToDevice(*data);
        if (failedEngineClone)
            data->engine = nullptr;
        delete data;
    }

Exit:
    free(ppr);
    GlobalFree(pd.hDevNames);
    GlobalFree(pd.hDevMode);
}
开发者ID:BanalityOfSeeking,项目名称:sumatrapdf,代码行数:101,代码来源:Print.cpp

示例10: DeleteMenuInfoForWnd

/*************************************
*
*  Unregister all TwinView menus
*  associated with a given window.
*
**************************************/
void __far __pascal DeleteMenuInfoForWnd( HWND hWnd )
{
    FPTVMENUINFO fpMenuInfo, fpLastMenuInfo;
    HTVMENUINFO hMenuInfo, hLastMenuInfo, hTmpMenuInfo;
    HTVMENUINFO __far * hFirstMenuInfo;

    BOOL bFirst = TRUE;


    /* Get top of menu list. */
    hFirstMenuInfo = (HTVMENUINFO __far *) &hTVMenuList;

    /* Existing first node. */
    if( *hFirstMenuInfo == 0 ) return;

    /* Point to first node in list. */
    hMenuInfo = *hFirstMenuInfo;

    /*
    ** Process first node if associated
    ** with the hWnd.
    */

    while( bFirst && hMenuInfo != 0 )
    {
        /* Lock current node. */
        fpMenuInfo = (FPTVMENUINFO) GlobalLock( hMenuInfo ) ;

        /* If found the correct window handle. */
        if( fpMenuInfo->hWnd == hWnd )
        {
            /* Remove the menu item from menu. */
            DeleteMenu( GetTVMenuHandle(), fpMenuInfo->wParamAlias, MF_BYCOMMAND );
            DrawMenuBar( GetTVWindowHandle());

            /* Next node is to be new top node. */
            hTmpMenuInfo = fpMenuInfo->Next;

            /* Unlock top handle. */
            GlobalUnlock( hMenuInfo );

            /* Free top. */
            FreeMenuInfo( hMenuInfo );

            /* Assign new top. */
            *hFirstMenuInfo = hMenuInfo = hTmpMenuInfo;

        }

        /* Thru processing top node. */
        else bFirst = FALSE;
    }

    /* Empty list now? */
    if( hMenuInfo == 0 ) return;


    /*
    ** Go thru rest of nodes and
    ** delete any associated with the hWnd.
    */

    /* Last node is top node. */
    hLastMenuInfo = hMenuInfo;

    /* Lock top node. */
    fpMenuInfo = (FPTVMENUINFO) GlobalLock( hMenuInfo ) ;

    /* Assign Next node to temp. */
    hTmpMenuInfo = fpMenuInfo->Next;

    /* Unlock top handle. */
    GlobalUnlock( hMenuInfo );

    /* New current node. */
    hMenuInfo = hTmpMenuInfo;


    while( hMenuInfo != 0 )
    {
        /* Lock current node. */
        fpMenuInfo = (FPTVMENUINFO) GlobalLock( hMenuInfo ) ;

        /* If found the correct window handle. */
        if( fpMenuInfo->hWnd == hWnd )
        {
            /* Remove the menu item from menu. */
            DeleteMenu( GetTVMenuHandle(), fpMenuInfo->wParamAlias, MF_BYCOMMAND );
            DrawMenuBar( GetTVWindowHandle());

            /* Lock previous node. */
            fpLastMenuInfo = (FPTVMENUINFO) GlobalLock( hLastMenuInfo ) ;

            /* Previous node's "next node" is deleted node's "next node". */
//.........这里部分代码省略.........
开发者ID:ErisBlastar,项目名称:osfree,代码行数:101,代码来源:menulist.c

示例11: SaveDIB

WORD FAR SaveDIB(HDIB hDib, LPSTR lpFileName)
{
   BITMAPFILEHEADER bmfHdr; // Header for Bitmap file
   LPBITMAPINFOHEADER lpBI;   // Pointer to DIB info structure
   int fh;     // file handle for opened file
   OFSTRUCT of;     // OpenFile structure
   DWORD dwDIBSize;
   DWORD dwError;   // Error return from MyWrite

   if (!hDib)
      return ERR_INVALIDHANDLE;
   fh = OpenFile(lpFileName, &of, OF_CREATE | OF_READWRITE);
   if (fh == -1)
      return ERR_OPEN;

   /*
    * Get a pointer to the DIB memory, the first of which contains
    * a BITMAPINFO structure
    */
   lpBI = (LPBITMAPINFOHEADER)GlobalLock(hDib);
   if (!lpBI)
      return ERR_LOCK;

   // Check to see if we're dealing with an OS/2 DIB.  If so, don't
   // save it because our functions aren't written to deal with these
   // DIBs.

   if (lpBI->biSize != sizeof(BITMAPINFOHEADER))
   {
     GlobalUnlock(hDib);
     return ERR_NOT_DIB;
   }

   /*
    * Fill in the fields of the file header
    */

   /* Fill in file type (first 2 bytes must be "BM" for a bitmap) */
   bmfHdr.bfType = DIB_HEADER_MARKER;  // "BM"

   // Calculating the size of the DIB is a bit tricky (if we want to
   // do it right).  The easiest way to do this is to call GlobalSize()
   // on our global handle, but since the size of our global memory may have
   // been padded a few bytes, we may end up writing out a few too
   // many bytes to the file (which may cause problems with some apps,
   // like HC 3.0).
   //
   // So, instead let's calculate the size manually.
   //
   // To do this, find size of header plus size of color table.  Since the
   // first DWORD in both BITMAPINFOHEADER and BITMAPCOREHEADER conains
   // the size of the structure, let's use this.

   dwDIBSize = *(LPDWORD)lpBI + PaletteSize((LPSTR)lpBI);  // Partial Calculation

   // Now calculate the size of the image

   if ((lpBI->biCompression == BI_RLE8) || (lpBI->biCompression == BI_RLE4)) {

      // It's an RLE bitmap, we can't calculate size, so trust the
      // biSizeImage field

      dwDIBSize += lpBI->biSizeImage;
      }
   else {
      DWORD dwBmBitsSize;  // Size of Bitmap Bits only

      // It's not RLE, so size is Width (DWORD aligned) * Height

      dwBmBitsSize = WIDTHBYTES((lpBI->biWidth)*((DWORD)lpBI->biBitCount)) * lpBI->biHeight;

      dwDIBSize += dwBmBitsSize;
      
      // Now, since we have calculated the correct size, why don't we
      // fill in the biSizeImage field (this will fix any .BMP files which 
      // have this field incorrect).

      lpBI->biSizeImage = dwBmBitsSize;
      }


   // Calculate the file size by adding the DIB size to sizeof(BITMAPFILEHEADER)
                   
   bmfHdr.bfSize = dwDIBSize + sizeof(BITMAPFILEHEADER);
   bmfHdr.bfReserved1 = 0;
   bmfHdr.bfReserved2 = 0;

   /*
    * Now, calculate the offset the actual bitmap bits will be in
    * the file -- It's the Bitmap file header plus the DIB header,
    * plus the size of the color table.
    */
   bmfHdr.bfOffBits = (DWORD)sizeof(BITMAPFILEHEADER) + lpBI->biSize +
                      PaletteSize((LPSTR)lpBI);

   /* Write the file header */
   _lwrite(fh, (LPSTR)&bmfHdr, sizeof(BITMAPFILEHEADER));

   /*
    * Write the DIB header and the bits -- use local version of
//.........这里部分代码省略.........
开发者ID:willmomo,项目名称:ry2kojima,代码行数:101,代码来源:FILE.C

示例12: DeleteMenuInfoForAlias

/*************************************
*
*  Remove and free a menu info. structure
*  from a menu info. list.
*
**************************************/
BOOL __far __pascal DeleteMenuInfoForAlias( HTVMENUINFO __far * hFirstMenuInfo, WORD wParamAlias  )
{
    FPTVMENUINFO fpMenuInfo, fpTmpMenuInfo;
    HTVMENUINFO hMenuInfo, hTmpMenuInfo;


    /* Existing first node. */
    if( *hFirstMenuInfo == 0 ) return FALSE;

    /* Lock top handle. */
    fpMenuInfo = (FPTVMENUINFO) GlobalLock( *hFirstMenuInfo ) ;

    /* If deleting top node. */
    if( fpMenuInfo->wParamAlias == wParamAlias )
    {
        /* Remove the menu item from menu. */
        DeleteMenu( GetTVMenuHandle(), fpMenuInfo->wParamAlias, MF_BYCOMMAND );
        DrawMenuBar( GetTVWindowHandle());

        /* Next node is to be new top node. */
        hTmpMenuInfo = fpMenuInfo->Next;

        /* Unlock top handle. */
        GlobalUnlock( *hFirstMenuInfo );

        /* Free top. */
        FreeMenuInfo( *hFirstMenuInfo );

        /* Assign new top. */
        *hFirstMenuInfo = hTmpMenuInfo;

        /* Success. */
        return TRUE;
    }

    /* Unlock top handle. */
    GlobalUnlock( *hFirstMenuInfo );

    /* Find correct node and remove. */
    hTmpMenuInfo = *hFirstMenuInfo;
    hMenuInfo = GetNextMenuInfo( *hFirstMenuInfo );

    while( hMenuInfo != 0 )
    {
        /* Lock current node. */
        fpMenuInfo = (FPTVMENUINFO) GlobalLock( hMenuInfo ) ;

        /* If deleting current node. */
        if( fpMenuInfo->wParamAlias == wParamAlias )
        {
            /* Remove the menu item from menu. */
            DeleteMenu( GetTVMenuHandle(), fpMenuInfo->wParamAlias, MF_BYCOMMAND );
            DrawMenuBar( GetTVWindowHandle());

            /* Lock previous node. */
            fpTmpMenuInfo = (FPTVMENUINFO) GlobalLock( hTmpMenuInfo ) ;

            /* Previous node's "next node" is deleted node's "next node". */
            fpTmpMenuInfo->Next = fpMenuInfo->Next;

            /* Unlock previous node. */
            GlobalUnlock( hTmpMenuInfo );

            /* Unlock current node. */
            GlobalUnlock( hMenuInfo );

            /* Free top. */
            FreeMenuInfo( hMenuInfo );

            /* Success. */
            return TRUE;
        }

        /* Unlock it. */
        GlobalUnlock( hMenuInfo ) ;

        /* Get next node. */
        hTmpMenuInfo = hMenuInfo;
        hMenuInfo = GetNextMenuInfo( hMenuInfo );
    }

    /* Did not find menu. */
    return FALSE;
}
开发者ID:ErisBlastar,项目名称:osfree,代码行数:90,代码来源:menulist.c

示例13: winClipboardFlushXEvents


//.........这里部分代码省略.........
	  else if (event.xselectionrequest.target == atomUTF8String)
	    xiccesStyle = XUTF8StringStyle;
#endif
	  else if (event.xselectionrequest.target == atomCompoundText)
	    xiccesStyle = XCompoundTextStyle;
	  else
	    xiccesStyle = XStringStyle;

	  /*
	   * FIXME: Can't pass CF_UNICODETEXT on Windows 95/98/Me
	   */
	  
	  /* Get a pointer to the clipboard text, in desired format */
	  if (fUseUnicode)
	    {
	      /* Retrieve clipboard data */
	      hGlobal = GetClipboardData (CF_UNICODETEXT);
	    }
	  else
	    {
	      /* Retrieve clipboard data */
	      hGlobal = GetClipboardData (CF_TEXT);
	    }
	  if (!hGlobal)
	    {
	      ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
		      "GetClipboardData () failed: %08x\n",
		      GetLastError ());

	      /* Abort */
	      fAbort = TRUE;
	      goto winClipboardFlushXEvents_SelectionRequest_Done;
	    }
	  pszGlobalData = (char *) GlobalLock (hGlobal);

	  /* Convert the Unicode string to UTF8 (MBCS) */
	  if (fUseUnicode)
	    {
	      iConvertDataLen = WideCharToMultiByte (CP_UTF8,
						     0,
						     (LPCWSTR)pszGlobalData,
						     -1,
						     NULL,
						     0,
						     NULL,
						     NULL);
	      /* NOTE: iConvertDataLen includes space for null terminator */
	      pszConvertData = (char *) malloc (iConvertDataLen);
	      WideCharToMultiByte (CP_UTF8,
				   0,
				   (LPCWSTR)pszGlobalData,
				   -1,
				   pszConvertData,
				   iConvertDataLen,
				   NULL,
				   NULL);
	    }
	  else
	    {
	      pszConvertData = strdup (pszGlobalData);
	      iConvertDataLen = strlen (pszConvertData) + 1;
	    }

	  /* Convert DOS string to UNIX string */
	  winClipboardDOStoUNIX (pszConvertData, strlen (pszConvertData));
开发者ID:Magister,项目名称:x11rdp_xorg71,代码行数:66,代码来源:winclipboardxevents.c

示例14: cheat_handle_debug

void cheat_handle_debug ( HWND wnd )
{
	static const int	data_size[4] = { 1, 2, 4, 4 };
	struct debug_info	*debug = &cheat_state->debug;
	int					move = 0, hist_chng = 0;

	if ( !cheat_state->debug_enabled )
		return;

	/* go to pointer */
	if ( KEY_PRESSED(VK_NUMPAD1) )
	{
		setDebugPointer( *(void **)debug->cursor_data );
		hist_chng = 1;
	}

	/* go back */
	if ( KEY_PRESSED(VK_NUMPAD7) )
	{
		if ( debug->hist_pos > 0 )
		{
			debug->hist_pos--;
			hist_chng = 1;
		}
		else if ( debug->hist_pos == 0 )
			setDebugPointer( (void *)NULL );
	}

	/* change data type */
	if ( KEY_PRESSED(VK_DIVIDE) )
		debug->data_type = ( debug->data_type + 1 ) % 4;

	/* inc/dec value */
	if ( KEY_DOWN(VK_ADD) || KEY_DOWN(VK_SUBTRACT) )
	{
		const int	value = KEY_DOWN( VK_ADD ) ? 1 : -1;
		uint8_t		data[4] = { 0, 0, 0, 0 };

		if ( memcpy_safe(data, debug->ptr[debug->hist_pos] + debug->offset[debug->hist_pos], data_size[debug->data_type]) )
		{
			switch ( debug->data_type )
			{
#pragma warning( disable : 4244 )

			case 0:
				( *(uint8_t *)data ) += ( uint8_t ) value;
				break;

			case 1:
				( *(uint16_t *)data ) += ( uint16_t ) value;
				break;

			case 2:
				( *(uint32_t *)data ) += ( uint32_t ) value;
				break;

			case 3:
				( *(float *)data ) += (float)value / 10.0f;
				break;
			}

			memcpy_safe( debug->ptr[debug->hist_pos] + debug->offset[debug->hist_pos], data, data_size[debug->data_type] );
		}
	}

	/* copy info to clipboard */
	if ( KEY_PRESSED(VK_MULTIPLY) )
	{
		if ( OpenClipboard(wnd) )
		{
			HGLOBAL mem = GlobalAlloc( GMEM_MOVEABLE, sizeof(debug->ptr_hist_str) );

			if ( mem != NULL )
			{
				char	*str = (char *)GlobalLock( mem );

				strlcpy( str, debug->ptr_hist_str, sizeof(debug->ptr_hist_str) );
				Log( "%s", str );
				GlobalUnlock( str );

				EmptyClipboard();

				if ( !SetClipboardData(CF_TEXT, mem) )
					Log( "SetClipboardData() %d", GetLastError() );

				/*SetClipboardData(CF_TEXT, mem);*/
			}

			CloseClipboard();
		}
		else
		{
			Log( "OpenClipboard() %d", GetLastError() );
		}
	}

	if ( KEY_PRESSED(VK_NUMPAD4) )
		move -= data_size[debug->data_type];
	if ( KEY_PRESSED(VK_NUMPAD6) )
		move += data_size[debug->data_type];
//.........这里部分代码省略.........
开发者ID:BlastHackNet,项目名称:mod_s0beit_sa,代码行数:101,代码来源:cheat_generic.cpp

示例15: test_PrintDlgA

static void test_PrintDlgA(void)
{
    DWORD       res;
    LPPRINTDLGA pDlg;
    DEVNAMES    *pDevNames;
    LPCSTR driver;
    LPCSTR device;
    LPCSTR port;
    CHAR   buffer[MAX_PATH];
    LPSTR  ptr;


    pDlg = HeapAlloc(GetProcessHeap(), 0, (sizeof(PRINTDLGA)) * 2);
    if (!pDlg) return;


    /* will crash with unpatched wine */
    SetLastError(0xdeadbeef);
    res = PrintDlgA(NULL);
    ok( !res && (CommDlgExtendedError() == CDERR_INITIALIZATION),
        "returned %d with 0x%x and 0x%x (expected '0' and "
        "CDERR_INITIALIZATION)\n", res, GetLastError(), CommDlgExtendedError());

    ZeroMemory(pDlg, sizeof(PRINTDLGA));
    pDlg->lStructSize = sizeof(PRINTDLGA) - 1;
    SetLastError(0xdeadbeef);
    res = PrintDlgA(pDlg);
    ok( !res && (CommDlgExtendedError() == CDERR_STRUCTSIZE),
        "returned %d with 0x%x and 0x%x (expected '0' and "
        "CDERR_STRUCTSIZE)\n", res, GetLastError(), CommDlgExtendedError());

    ZeroMemory(pDlg, sizeof(PRINTDLGA));
    pDlg->lStructSize = sizeof(PRINTDLGA) + 1;
    pDlg->Flags = PD_RETURNDEFAULT;
    SetLastError(0xdeadbeef);
    res = PrintDlgA(pDlg);
    ok( !res && (CommDlgExtendedError() == CDERR_STRUCTSIZE),
        "returned %u with %u and 0x%x (expected '0' and "
        "CDERR_STRUCTSIZE)\n", res, GetLastError(), CommDlgExtendedError());


    ZeroMemory(pDlg, sizeof(PRINTDLGA));
    pDlg->lStructSize = sizeof(PRINTDLGA);
    pDlg->Flags = PD_RETURNDEFAULT;
    SetLastError(0xdeadbeef);
    res = PrintDlgA(pDlg);
    ok( res || (CommDlgExtendedError() == PDERR_NODEFAULTPRN),
        "returned %d with 0x%x and 0x%x (expected '!= 0' or '0' and "
        "PDERR_NODEFAULTPRN)\n", res, GetLastError(), CommDlgExtendedError());

    if (!res && (CommDlgExtendedError() == PDERR_NODEFAULTPRN)) {
        skip("No printer configured.\n");
        HeapFree(GetProcessHeap(), 0, pDlg);
        return;
    }

    ok(pDlg->hDevNames != NULL, "(expected '!= NULL')\n");
    pDevNames = GlobalLock(pDlg->hDevNames);
    ok(pDevNames != NULL, "(expected '!= NULL')\n");

    if (pDevNames) {
        ok(pDevNames->wDriverOffset, "(expected '!= 0' for wDriverOffset)\n");
        ok(pDevNames->wDeviceOffset, "(expected '!= 0' for wDeviceOffset)\n");
        ok(pDevNames->wOutputOffset, "(expected '!= 0' for wOutputOffset)\n");
        ok(pDevNames->wDefault == DN_DEFAULTPRN, "got 0x%x (expected DN_DEFAULTPRN)\n", pDevNames->wDefault);

        driver = (LPCSTR)pDevNames + pDevNames->wDriverOffset;
        device = (LPCSTR)pDevNames + pDevNames->wDeviceOffset;
        port = (LPCSTR)pDevNames + pDevNames->wOutputOffset;
        trace("driver '%s' device '%s' port '%s'\n", driver, device, port);

        /* The Driver Entry does not include a Path */
        ptr = strrchr(driver, '\\');
        ok( ptr == NULL, "got %p for '%s' (expected NULL for a simple name)\n", ptr, driver);

        /* The Driver Entry does not have an extension (fixed to ".drv") */
        ptr = strrchr(driver, '.');
        todo_wine {
        ok( ptr == NULL, "got %p for '%s' (expected NULL for no extension)\n", ptr, driver);
        }


        buffer[0] = '\0';
        SetLastError(0xdeadbeef);
        res = GetProfileStringA(PrinterPortsA, device, emptyA, buffer, sizeof(buffer));
        ptr = strchr(buffer, ',');
        ok( (res > 1) && (ptr != NULL),
            "got %u with %u and %p for '%s' (expected '>1' and '!= NULL')\n",
            res, GetLastError(), ptr, buffer);

        if (ptr) ptr[0] = '\0';
        ok( lstrcmpiA(driver, buffer) == 0,
            "got driver '%s' (expected '%s')\n", driver, buffer);
    }

    GlobalUnlock(pDlg->hDevNames);

    GlobalFree(pDlg->hDevMode);
    GlobalFree(pDlg->hDevNames);
    HeapFree(GetProcessHeap(), 0, pDlg);
//.........这里部分代码省略.........
开发者ID:AmesianX,项目名称:RosWine,代码行数:101,代码来源:printdlg.c


注:本文中的GlobalLock函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。