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


C++ FillMemory函数代码示例

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


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

示例1: ErrMsg

void Platform_Win32_Sound_SoundStream_DSound::ClearBuffer(int bufferOffset, int bytesToClear)
	{
	if (!soundBuffer_)
		{
		}
		// Check the range of the bytesToClear parameter
	ErrMsg((bufferOffset+bytesToClear)<=size_,"Sound buffer out of range\n");

	// Obtain memory address of write block. This will be in two parts
    // if the block wraps around.
	LPVOID lpvPtr1;
    DWORD dwBytes1;
    LPVOID lpvPtr2;
    DWORD dwBytes2;
    HRESULT hr = soundBuffer_->Lock(bufferOffset, bytesToClear, &lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2, 0);

    // If DSERR_BUFFERLOST is returned, restore and retry lock.
    if (hr==DSERR_BUFFERLOST)
		{
        soundBuffer_->Restore();
	    hr = soundBuffer_->Lock(bufferOffset, bytesToClear, &lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2, 0);
		}
    ErrMsg(SUCCEEDED(hr),"Couldn't lock sound buffer\n");

	// Write to pointers.
	FillMemory(lpvPtr1, dwBytes1,0);
	if(lpvPtr2)
		{
        FillMemory(lpvPtr2, dwBytes2, 0);
	    }

	// Release the data back to DirectSound.
    hr=soundBuffer_->Unlock(lpvPtr1, dwBytes1, lpvPtr2, dwBytes2);
	ErrMsg(SUCCEEDED(hr),"Couldn't unlock sound buffer\n");
	}
开发者ID:RichardMarks,项目名称:Pixie,代码行数:35,代码来源:Platform_Win32_Sound_SoundStream_DSound.cpp

示例2: strcpy_s

void CNetworkLayerTestDlg::OnBnClickedButtonSend()
{
TRY_CATCH

	char buf[MAX_PATH];
	int len;

	strcpy_s( buf, MAX_PATH, "Sending ->" );
	m_SendList.AddString( buf );
	FillMemory( buf, MAX_PATH, 0 );

	m_SendText.GetWindowText( buf, MAX_PATH );
	m_SendList.AddString( buf );
	len = (unsigned int)strlen( buf );
	if ( BST_CHECKED == m_AddBreakLine.GetCheck() )
	{
		buf[len] = '\r';
		len++;
		buf[len] = '\n';
		len++;
	}

	Stream.Send( buf, len );

	FillMemory( buf, MAX_PATH, 0 );
	strcpy_s( buf, MAX_PATH, "->Sent" );
	m_SendList.AddString( buf );

	m_SendText.SetWindowText( "" );

CATCH_LOG("CNetworkLayerTestDlg::OnBnClickedButtonSend")
}
开发者ID:SupportSpace,项目名称:SupportCenter,代码行数:32,代码来源:NetworkLayerTestDlg.cpp

示例3: FillMemory

VOID CPokemonCodec::GetCatcherName(BYTE bCode[POKEMON_TRAINER_NAME_SIZE])
{
	if(m_pPokemon == NULL)
		return;

	if(m_pPokemon->Header.bNickNameLanguage == 0x00)
	{
		FillMemory(bCode, POKEMON_TRAINER_NAME_SIZE, 0xFF);
	}
	else
	{
		switch(m_dwLang)
		{
		case lang_jp:	// jp version
			MoveMemory(bCode, m_pPokemon->Header.bCatcherName, 5);
			bCode[5] = 0xFF;
			FillMemory(bCode + 6, POKEMON_TRAINER_NAME_SIZE - 6, 0x00);
			break;

		default:		// en version
			MoveMemory(bCode, m_pPokemon->Header.bCatcherName, POKEMON_TRAINER_NAME_SIZE);
			break;
		}
	}
}
开发者ID:h16o2u9u,项目名称:rtoss,代码行数:25,代码来源:PokemonCodec.cpp

示例4: CreateFile

bool CSerialPort::Open( LPCTSTR lpszComPort,LPCTSTR lpszConString ,int delay_us)
{
	CString sPort;
	sPort.Format(_T("\\\\.\\%s"), lpszComPort);

	m_hComm = CreateFile(sPort,  GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING,0,0);
	if (m_hComm == INVALID_HANDLE_VALUE)
	{
		CString str;
		GetErrorStr(str);
		LogMessage(str);
		return false;
	}
	Delay_US = delay_us;
	// Set Com Settings
	DCB dcb;
	FillMemory(&dcb, sizeof(dcb), 0);
	dcb.DCBlength = sizeof(dcb);
	if (!BuildCommDCB(lpszConString, &dcb))
	{   
		// Couldn't build the DCB. Usually a problem
		// with the communications specification string.
		CString str;
		GetErrorStr(str);
		LogMessage(str);
		LogMessage("Seri Port Hatasý. (BuildComDCB)");		
		CloseHandle(m_hComm);
		m_hComm = NULL;
		return false;
	}
	if (!SetCommState(m_hComm, &dcb))
	{
		CString str;
		GetErrorStr(str);
		LogMessage(str);
		LogMessage("Seri Port Hatasý. (SetCommState)");
		CloseHandle(m_hComm);
		m_hComm = NULL;
		return false;
	}
	COMMTIMEOUTS cm;
	FillMemory(&cm, sizeof(cm), 0);
	cm.ReadIntervalTimeout = 10;
	cm.ReadTotalTimeoutConstant = 10;
	if(!SetCommTimeouts(m_hComm,&cm))
	{
		CString str;
		GetErrorStr(str);
		LogMessage(str);
		LogMessage("Seri Port Hatasý. (SetCommTimeouts)");
		CloseHandle(m_hComm);
		m_hComm = NULL;
		return false;
	}	
	LogMessage("Seri port açýldý.");
	return true;
}
开发者ID:hozgur,项目名称:Colorway,代码行数:57,代码来源:SerialPort.cpp

示例5: Test_DIBBrush

void
Test_DIBBrush(void)
{
    struct
    {
        BITMAPINFOHEADER bmiHeader;
        WORD wColors[4];
        BYTE jBuffer[16];
    } PackedDIB =
    {
        {sizeof(BITMAPINFOHEADER), 4, 4, 1, 8, BI_RGB, 0, 1, 1, 4, 0},
        {1, 7, 3, 1},
        {0,1,2,3,  1,2,3,0,  2,3,0,1,  3,0,1,2},
    };
    LOGBRUSH logbrush;
    HBRUSH hBrush;

    /* Create a DIB brush */
    hBrush = CreateDIBPatternBrushPt(&PackedDIB, DIB_PAL_COLORS);
    ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n");
    if (!hBrush) return;

    FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77);
    SetLastError(ERROR_SUCCESS);

    ok_long(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush), sizeof(LOGBRUSH));
    ok_long(logbrush.lbStyle, BS_DIBPATTERN);
    ok_long(logbrush.lbColor, 0);
    ok_long(logbrush.lbHatch, (ULONG_PTR)&PackedDIB);

    ok_err(ERROR_SUCCESS);
    DeleteObject(hBrush);


    /* Create a DIB brush with undocumented iUsage 2 */
    hBrush = CreateDIBPatternBrushPt(&PackedDIB, 2);
    ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n");
    if (!hBrush) return;

    FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77);
    SetLastError(ERROR_SUCCESS);

    ok_long(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush), sizeof(LOGBRUSH));
    ok_long(logbrush.lbStyle, BS_DIBPATTERN);
    ok_long(logbrush.lbColor, 0);
    ok_long(logbrush.lbHatch, (ULONG_PTR)&PackedDIB);

    ok_err(ERROR_SUCCESS);
    DeleteObject(hBrush);

}
开发者ID:GYGit,项目名称:reactos,代码行数:51,代码来源:GetObject.c

示例6: strcpy_s

void CStreamFactoryDlg::ReadFromStream()
{
TRY_CATCH

	char buf[MAX_PATH];
	bool rec = m_stream->HasInData();// > 0;
	int count = 0;
	char* pbuf = buf;

	if ( rec )
	{
		strcpy_s( buf, MAX_PATH, "Receiving ->" );
		m_ReceiveList.AddString( buf );
		FillMemory( buf, MAX_PATH, 0 );
	}

	while ( m_stream->HasInData() )
	{
		try
		{
			m_stream->Receive( pbuf, 1 );
		}
		catch(CStreamException &e)
		{
			MLog_Exception(CExceptionBase(e,PREPARE_EXEPTION_MESSAGE(_T(__FUNCTION__))));
			OnBnClickedDisconnectButton(); ///TODO: send message
			return;
		}
		pbuf++;
		count++;
		if ( MAX_PATH - 1 == count )
		{
			m_ReceiveList.AddString( buf );
			FillMemory( buf, MAX_PATH, 0 );
			pbuf = buf;
			count = 0;
		}
	}

	if ( rec )
	{
		if ( count )
			m_ReceiveList.AddString( buf );
		FillMemory( buf, MAX_PATH, 0 );
		strcpy_s( buf, MAX_PATH, "->Received" );
		m_ReceiveList.AddString( buf );
	}

CATCH_LOG("CStreamFactoryDlg::ReadFromStream")
}
开发者ID:SupportSpace,项目名称:SupportCenter,代码行数:50,代码来源:StreamFactory.cpp

示例7: DSOUND_PrimaryOpen

static HRESULT DSOUND_PrimaryOpen(DirectSoundDevice *device)
{
	DWORD buflen;
	LPBYTE newbuf;

	TRACE("(%p)\n", device);

	/* on original windows, the buffer it set to a fixed size, no matter what the settings are.
	   on windows this size is always fixed (tested on win-xp) */
	if (!device->buflen)
		device->buflen = ds_hel_buflen;
	buflen = device->buflen;
	buflen -= buflen % device->pwfx->nBlockAlign;
	device->buflen = buflen;

	device->mix_buffer_len = DSOUND_bufpos_to_mixpos(device, device->buflen);
	device->mix_buffer = HeapAlloc(GetProcessHeap(), 0, device->mix_buffer_len);
	if (!device->mix_buffer)
		return DSERR_OUTOFMEMORY;

	if (device->state == STATE_PLAYING) device->state = STATE_STARTING;
	else if (device->state == STATE_STOPPING) device->state = STATE_STOPPED;

    TRACE("desired buflen=%d, old buffer=%p\n", buflen, device->buffer);

    /* reallocate emulated primary buffer */
    if (device->buffer)
        newbuf = HeapReAlloc(GetProcessHeap(),0,device->buffer, buflen);
    else
        newbuf = HeapAlloc(GetProcessHeap(),0, buflen);

    if (!newbuf) {
        ERR("failed to allocate primary buffer\n");
        return DSERR_OUTOFMEMORY;
        /* but the old buffer might still exist and must be re-prepared */
    }

    DSOUND_RecalcPrimary(device);

    device->buffer = newbuf;

    TRACE("fraglen=%d\n", device->fraglen);

	device->mixfunction = mixfunctions[device->pwfx->wBitsPerSample/8 - 1];
	device->normfunction = normfunctions[device->pwfx->wBitsPerSample/8 - 1];
	FillMemory(device->buffer, device->buflen, (device->pwfx->wBitsPerSample == 8) ? 128 : 0);
	FillMemory(device->mix_buffer, device->mix_buffer_len, 0);
	device->last_pos_bytes = device->pwplay = device->pwqueue = device->playpos = device->mixpos = 0;
	return DS_OK;
}
开发者ID:Sunmonds,项目名称:wine,代码行数:50,代码来源:primary.c

示例8: hdd_format

static REG8 hdd_format(SXSIDEV sxsi, long pos) {

	FILEH	fh;
	long	r;
	UINT16	i;
	UINT8	work[256];
	UINT	size;
	UINT	wsize;

	if (sxsi_prepare(sxsi) != SUCCESS) {
		return(0x60);
	}
	if ((pos < 0) || (pos >= sxsi->totals)) {
		return(0x40);
	}
	pos = pos * sxsi->size + sxsi->headersize;
	fh = (FILEH)sxsi->hdl;
	r = file_seek(fh, pos, FSEEK_SET);
	if (pos != r) {
		return(0xd0);
	}
	FillMemory(work, sizeof(work), 0xe5);
	for (i=0; i<sxsi->sectors; i++) {
		size = sxsi->size;
		while(size) {
			wsize = min(size, sizeof(work));
			size -= wsize;
			CPU_REMCLOCK -= wsize;
			if (file_write(fh, work, wsize) != wsize) {
				return(0x70);
			}
		}
	}
	return(0x00);
}
开发者ID:FREEWING-JP,项目名称:np2pi,代码行数:35,代码来源:sxsihdd.c

示例9: InitFirstPage

static VOID InitFirstPage()
{
    PVOID BaseAddress;
    ULONG RegionSize;
    NTSTATUS ReturnCode;
    FARPROC NtAllocateVirtualMemory;

    NtAllocateVirtualMemory = GetProcAddress(GetModuleHandle("NTDLL.DLL"), "NtAllocateVirtualMemory");

    fprintf(stderr, "[email protected]%p\n", NtAllocateVirtualMemory);

    RegionSize = 0xf000;
    BaseAddress = (PVOID) 0x00000001;

    ReturnCode = NtAllocateVirtualMemory(GetCurrentProcess(),
                                         &BaseAddress,
	                                     0,
                                         &RegionSize,
                                         MEM_COMMIT | MEM_RESERVE,
                                         PAGE_EXECUTE_READWRITE);

     if (ReturnCode != 0) {
         fprintf(stderr, "NtAllocateVirtualMemory() failed to map first page, %#X\n",
                         ReturnCode);
         fflush(stderr);
         ExitProcess(1);
    }

    fprintf(stderr, "BaseAddress: %p, RegionSize: %#x\n", BaseAddress, RegionSize), fflush(stderr);

    FillMemory(BaseAddress, RegionSize, 0x41);

    return;
}
开发者ID:B-Rich,项目名称:osf_db,代码行数:34,代码来源:42211_0.c

示例10: Test_Pen

void
Test_Pen(void)
{
    LOGPEN logpen;
    HPEN hPen;

    FillMemory(&logpen, sizeof(LOGPEN), 0x77);
    hPen = CreatePen(PS_SOLID, 3, RGB(4,5,6));
    ok(hPen != 0, "CreatePen failed, skipping tests.\n");
    if (!hPen) return;
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_PEN, 0, NULL) == sizeof(LOGPEN), "\n");
    ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PEN, 0, NULL) == sizeof(LOGPEN), "\n");
    ok(GetObject(hPen, sizeof(BITMAP), NULL) == sizeof(LOGPEN), "\n");
    ok(GetObject(hPen, 0, NULL) == sizeof(LOGPEN), "\n");
    ok(GetObject(hPen, 5, NULL) == sizeof(LOGPEN), "\n");
    ok(GetObject(hPen, -5, NULL) == sizeof(LOGPEN), "\n");
    ok(GetObject(hPen, sizeof(LOGPEN), &logpen) == sizeof(LOGPEN), "\n");
    ok(GetObject(hPen, sizeof(LOGPEN)-1, &logpen) == 0, "\n");
    ok(GetObject(hPen, sizeof(LOGPEN)+2, &logpen) == sizeof(LOGPEN), "\n");
    ok(GetObject(hPen, 0, &logpen) == 0, "\n");
    ok(GetObject(hPen, -5, &logpen) == sizeof(LOGPEN), "\n");
    //ok(GetLastError() == ERROR_SUCCESS, "\n"); fails on win7

    /* test if the fields are filled correctly */
    ok(logpen.lopnStyle == PS_SOLID, "\n");

    ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PEN, sizeof(LOGPEN), &logpen) == 0, "\n");
    ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());

    DeleteObject(hPen);
}
开发者ID:GYGit,项目名称:reactos,代码行数:32,代码来源:GetObject.c

示例11: malloc

unsigned char *SampleImages( unsigned long nSizeX, unsigned long nSizeY )
{
	unsigned long x, y;
	unsigned char *image;

	image = (unsigned char*) malloc( nSizeX*nSizeY*3 );
	if (NULL != image) {
		// Picture 0: horizontal bars
		for (y=0; y<nSizeY; y++)
			FillMemory(
				image + 0*nSizeY*nSizeX + y*nSizeX,	// row start address
				nSizeX,	// row size in bytes
				(y&64)? 0 : 128 );	// image data: either 0 or 128

		// Picture 1:  checkered pattern
		for (y=0; y<nSizeY; y++)
			for (x=0; x<nSizeX; x++)
				image[1*nSizeY*nSizeX + y*nSizeX + x] =	
					(unsigned char) ((x^y)& 32)? 0 : 128;

		// Picture 2:  vertical bars
		for (y=0; y<nSizeY; y++)
			for (x=0; x<nSizeX; x++)
				image[2*nSizeY*nSizeX + y*nSizeX + x] =	
					(unsigned char) (x&256)? 0 : 128;
	}

	return image;
}
开发者ID:leiferlab,项目名称:mindcontrol,代码行数:29,代码来源:Talk2DLP.cpp

示例12: GetStatsuBarProtoRect

int GetStatsuBarProtoRect(HWND hwnd,char *szProto,RECT *rc)
{
	int nParts,nPanel;
	ProtocolData *PD;
	int startoffset=DBGetContactSettingDword(NULL,"StatusBar","FirstIconOffset",0);
	
	if (!UseOwnerDrawStatusBar) startoffset=0;

	nParts=SendMessage(hwnd,SB_GETPARTS,0,0);
	FillMemory(rc,sizeof(RECT),0);

	for (nPanel=0;nPanel<nParts;nPanel++)
	{
		PD=(ProtocolData *)SendMessage(pcli->hwndStatus,SB_GETTEXT,(WPARAM)nPanel,(LPARAM)0);
		if ( PD == NULL )
			return(0);
	
		if (!strcmp(szProto,PD->RealName))
		{
			SendMessage(hwnd,SB_GETRECT,(WPARAM)nPanel,(LPARAM)rc);
			rc->left+=startoffset;
			rc->right+=startoffset;
			return(0);
		}
	}
	return (0);
}
开发者ID:raoergsls,项目名称:miranda,代码行数:27,代码来源:clui.c

示例13: ExistDriver

bool ExistDriver()
{

	LPSTR driverName = "Winvnc video hook driver";
	DEVMODE devmode;
    FillMemory(&devmode, sizeof(DEVMODE), 0);
    devmode.dmSize = sizeof(DEVMODE);
    devmode.dmDriverExtra = 0;
    BOOL change = EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&devmode);
    devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
	BOOL result;
    DISPLAY_DEVICE dd;
    ZeroMemory(&dd, sizeof(dd));
    dd.cb = sizeof(dd);
	LPSTR deviceName = NULL;
    devmode.dmDeviceName[0] = '\0';
    INT devNum = 0;
	pEnumDisplayDevices pd;
	HMODULE hUser32=LoadLibrary("USER32");
	pd = (pEnumDisplayDevices)GetProcAddress( hUser32, "EnumDisplayDevicesA");
    while (result = (*pd)(NULL,devNum, &dd,0))
        {
          if (strcmp((const char *)&dd.DeviceString[0], driverName) == 0)
              break;
           devNum++;
        }
	return result;
}
开发者ID:adrianovieira,项目名称:cacic3-agente_windows,代码行数:28,代码来源:videodrivercheck.cpp

示例14: switch

VOID CPokemonCodec::SetNickName(BYTE bCode[POKEMON_NICK_NAME_SIZE])
{
	if(m_pPokemon == NULL)
		return;

	if(m_pPokemon->Header.bNickNameLanguage == 0x00)
	{
		if(m_dwLang == lang_jp)
			m_pPokemon->Header.bNickNameLanguage = 0x01;
		else
			m_pPokemon->Header.bNickNameLanguage = 0x02;
	}

	switch(m_pPokemon->Header.bNickNameLanguage)
	{
	case 0x01:		// jp version
		MoveMemory(m_pPokemon->Header.bNickName, bCode, 5);
		m_pPokemon->Header.bNickName[5] = 0xFF;
		FillMemory(m_pPokemon->Header.bNickName + 6, POKEMON_NICK_NAME_SIZE - 6, 0x00);
		break;

	default:		// en version
		MoveMemory(m_pPokemon->Header.bNickName, bCode, POKEMON_NICK_NAME_SIZE);
		break;
	}
}
开发者ID:h16o2u9u,项目名称:rtoss,代码行数:26,代码来源:PokemonCodec.cpp

示例15: while

void StreamSound::uploadSound(BYTE* buffer, DWORD size)
{    
    DWORD bytesRestToUpload = size;
    DWORD uploadOffset = 0;
    DWORD oggBytes;
    while( bytesRestToUpload > 0 )
    {
        oggBytes = _oggFile->readBlock( buffer + uploadOffset, bytesRestToUpload );
        bytesRestToUpload -= oggBytes;
        uploadOffset += oggBytes;
        if( bytesRestToUpload > 0 )
        {
            if( _isLooping )
            {
                _oggFile->reset();
            }
            else
            {
                FillMemory( buffer + uploadOffset, bytesRestToUpload, 0 );
                bytesRestToUpload = 0;
            }
        }
    }
    _playProgress += size;
}
开发者ID:AndreMeijer86,项目名称:base-pro-edition,代码行数:25,代码来源:stream.cpp


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