本文整理汇总了C++中GlobalAllocPtr函数的典型用法代码示例。如果您正苦于以下问题:C++ GlobalAllocPtr函数的具体用法?C++ GlobalAllocPtr怎么用?C++ GlobalAllocPtr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GlobalAllocPtr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NewHandle
Handle NewHandle ( long size )
{
Handle mHand;
char *p;
memError = noErr;
mHand = (Handle) GlobalAllocPtr (GHND, (sizeof (Handle) + signatureSize));
if (mHand)
*mHand = (Ptr) GlobalAllocPtr (GHND, size);
if (!mHand || !(*mHand))
{
memError = memFullErr;
return NULL;
}
// put the signature after the pointer
p = (char *) mHand;
p += sizeof (Handle);
memcpy (p,cSig, signatureSize);
return mHand;
}
示例2: PacketAllocatePacket
LPPACKET PacketAllocatePacket( LPADAPTER AdapterObject, UINT Length )
{
LPPACKET lpPacket;
lpPacket = (LPPACKET)GlobalAllocPtr( GMEM_MOVEABLE|GMEM_ZEROINIT, sizeof(PACKET) );
if(lpPacket==NULL) {
D(bug("Packet32: PacketAllocatePacket: GlobalAlloc Failed\n"));
return NULL;
}
lpPacket->OverLapped.hEvent = CreateEvent(NULL,FALSE,FALSE,NULL);
if(!lpPacket->OverLapped.hEvent) {
D(bug("Packet32: PacketAllocatePacket: CreateEvent Failed\n"));
GlobalFreePtr(lpPacket);
return NULL;
}
lpPacket->Buffer = GlobalAllocPtr(GMEM_MOVEABLE,2048); // 1514
if(!lpPacket->Buffer) {
D(bug("Packet32: PacketAllocatePacket: GlobalAllocPtr Failed\n"));
if(lpPacket->OverLapped.hEvent) CloseHandle(lpPacket->OverLapped.hEvent);
GlobalFreePtr(lpPacket);
return NULL;
}
lpPacket->OverLapped.Offset = 0;
lpPacket->OverLapped.OffsetHigh = 0;
lpPacket->Length = Length;
lpPacket->BytesReceived = 0;
lpPacket->bIoComplete = FALSE;
lpPacket->free = TRUE;
return lpPacket;
}
示例3: LuminanceChrominance
void LuminanceChrominance(SImageRGB ImageRGB, SImage Y, SImage C0, SImage C1)
{
rgb RGB;
long l = 0;
int lum;
long i,j;
unsigned char * ImY = (unsigned char *) Y.Image;
unsigned char * ImC0 = (unsigned char *) C0.Image;
unsigned char * ImC1 = (unsigned char *) C1.Image;
int * Chromi0 = (int * ) GlobalAllocPtr(GMEM_FIXED | GMEM_ZEROINIT,(ImageRGB.Lmax-ImageRGB.Lmin+1)*(ImageRGB.Hmax-ImageRGB.Hmin+1)*sizeof(int));
int * Chromi1 = (int *) GlobalAllocPtr(GMEM_FIXED | GMEM_ZEROINIT,(ImageRGB.Lmax-ImageRGB.Lmin+1)*(ImageRGB.Hmax-ImageRGB.Hmin+1)*sizeof(int));
int MaxRouge=-255,MaxBleu=-255;
int MinRouge=255,MinBleu=255;
for (j= ImageRGB.Hmin;j<=ImageRGB.Hmax;j++)
{
for (i=ImageRGB.Lmin;i<=ImageRGB.Lmax;i++)
{
RGB = ImageRGB.Image[j*ImageRGB.Larg+i];
lum = (int)(0.3*RGB.r + 0.59*RGB.g + 0.11*RGB.b);
((unsigned char * )ImY)[l] = (unsigned char) lum;
Chromi0[l] = (int)RGB.r-lum;
Chromi1[l] = (int)RGB.b-lum;
if (Chromi0[l] > MaxRouge) MaxRouge =Chromi0[l];
if (Chromi1[l] > MaxBleu) MaxBleu = Chromi1[l] ;
if (Chromi0[l] < MinRouge) MinRouge = Chromi0[l] ;
if (Chromi1[l] < MinBleu) MinBleu = Chromi1[l] ;
l++;
}
}
l = 0;
// normalisation des chrominances
int normR,normB,norm;
if (MaxRouge==MinRouge) normR= 1; else normR = (MaxRouge-MinRouge)/255;
if (MaxBleu==MinBleu) normB= 1; else normB = (MaxBleu-MinBleu)/255;
if (normR>normB) norm = normR; else norm = normB;
for (j= ImageRGB.Hmin;j<=ImageRGB.Hmax;j++)
{
for (i=ImageRGB.Lmin;i<=ImageRGB.Lmax;i++)
{
RGB = ImageRGB.Image[j*ImageRGB.Larg+i];
((unsigned char * )ImC0)[l] = (unsigned char) (Chromi0[l]-MinRouge)/norm;
((unsigned char * )ImC1)[l] = (unsigned char) (Chromi1[l] -MinBleu)/norm;
l++;
}
}
GlobalFreePtr(Chromi0);
GlobalFreePtr(Chromi1);
}
示例4: sizeof
void CDib::LoadStream(IStream *pStr)
{
BITMAPFILEHEADER bitmapFileHeader;
ULONG ReadSize = 0;
HRESULT hr = S_OK;
hr = pStr->Read((void*)&bitmapFileHeader,sizeof(BITMAPFILEHEADER),&ReadSize);
if (SUCCEEDED(hr)&&(bitmapFileHeader.bfType == 0x4d42))
{
DWORD fileLength = bitmapFileHeader.bfSize;
DWORD size = fileLength - sizeof(BITMAPFILEHEADER);
BYTE* pDib = (BYTE*)GlobalAllocPtr(GMEM_MOVEABLE, size);
hr = pStr->Read((void*)pDib, size,&ReadSize);
if(SUCCEEDED(hr))
{
m_pBitmapInfo = (BITMAPINFO*)pDib;
m_pBitmapInfoHeader = (BITMAPINFOHEADER*) pDib;
m_pRGB = (RGBQUAD*)(pDib + m_pBitmapInfoHeader->biSize);
int m_numberOfColors = GetNumberOfColors();
if (m_pBitmapInfoHeader->biClrUsed == 0)
m_pBitmapInfoHeader->biClrUsed = m_numberOfColors;
DWORD colorTableSize = m_numberOfColors * sizeof(RGBQUAD);
m_pData = pDib + m_pBitmapInfoHeader->biSize + colorTableSize;
if (m_pRGB == (RGBQUAD*)m_pData) // No color table
m_pRGB = NULL;
m_pBitmapInfoHeader->biSizeImage = GetSize();
m_valid = TRUE;
return ;
}
}
m_valid = FALSE;
#ifdef _DEVELOVER_VERSION_L1
AfxMessageBox(_T("This isn't a bitmap file in Stream!"));
#endif
}
示例5: strcpy
void CDib::LoadFile(const char* dibFileName)
{
strcpy(m_fileName,dibFileName);
CFile dibFile(m_fileName, CFile::modeRead);
dibFile.Read((void*)&bitmapFileHeader,sizeof(BITMAPFILEHEADER));
if (bitmapFileHeader.bfType == 0x4d42)
{
DWORD fileLength = dibFile.GetLength();
size = fileLength -sizeof(BITMAPFILEHEADER);
pDib =(BYTE*)GlobalAllocPtr(GMEM_MOVEABLE, size);
dibFile.Read((void*)pDib, size);
dibFile.Close();
m_pBitmapInfo = (BITMAPINFO*) pDib;
m_pBitmapInfoHeader = (BITMAPINFOHEADER*) pDib;
m_pRGB = (RGBQUAD*)(pDib +
m_pBitmapInfoHeader->biSize);
int m_numberOfColors = GetNumberOfColors();
if (m_pBitmapInfoHeader->biClrUsed == 0)
m_pBitmapInfoHeader->biClrUsed =
m_numberOfColors;
DWORD colorTableSize = m_numberOfColors *
sizeof(RGBQUAD);
m_pData = pDib + m_pBitmapInfoHeader->biSize
+ colorTableSize;
if (m_pRGB == (RGBQUAD*)m_pData) // No color table
m_pRGB = NULL;
m_pBitmapInfoHeader->biSizeImage = GetSize();
m_valid = TRUE;
}
else
{
m_valid = FALSE;
AfxMessageBox("This isn't a bitmap file!");
}
}
示例6:
CModelFrame::CModelFrame()
{
m_Limited=600;
m_iDem=512;
m_bArroy=new BYTE[m_iDem];
Pallete=(LPBITMAPINFO)GlobalAllocPtr(GHND,
(sizeof (BITMAPINFO)+
(sizeof (RGBQUAD)*255 )));
Pallete->bmiHeader.biSize = 40;
Pallete->bmiHeader.biWidth = m_iDem;
Pallete->bmiHeader.biHeight = m_iDem;
Pallete->bmiHeader.biPlanes = 1;
Pallete->bmiHeader.biBitCount = 8;
Pallete->bmiHeader.biCompression=BI_RGB;
Pallete->bmiHeader.biSizeImage = 0;
Pallete->bmiHeader.biXPelsPerMeter = 0;
Pallete->bmiHeader.biYPelsPerMeter = 0;
Pallete->bmiHeader.biClrUsed = 0;
Pallete->bmiHeader.biClrImportant = 0;
for(int i=0;i<256;i++)
{
Pallete->bmiColors[i].rgbRed =
Pallete->bmiColors[i].rgbGreen =
Pallete->bmiColors[i].rgbBlue = i;
}
GetModel();
}
示例7: GetBITMAPINFOSize
///////////////////////////////////////
// member function CreateBITMAPINFO
///////////////////////////////////////
BOOL CDib::CreateBITMAPINFO()
{
UINT biSize;
// determine the amount of memory needed to hold BITMAPINFO
biSize = GetBITMAPINFOSize();
// Allocate the BITMAPINFO data structure
if (lpbinfo != NULL)
GlobalFreePtr(lpbinfo);
lpbinfo = (LPBITMAPINFO) GlobalAllocPtr(GMEM_MOVEABLE,biSize);
if (lpbinfo == NULL)
{
SetCDibState(FAIL_LPBI_ALLOC);
return FALSE;
}
// initialize the values to ZERO
memset(lpbinfo, 0, biSize);
return TRUE;
}
示例8: PacketGetNetType
//---------------------------------------------------------------------------
BOOLEAN PacketGetNetType (LPADAPTER AdapterObject,NetType *type)
{
BOOLEAN Status;
ULONG IoCtlBufferLength = (sizeof (PACKET_OID_DATA) + sizeof (ULONG) - 1);
PPACKET_OID_DATA OidData;
ODS ("Packet32: PacketSetFilter\n");
_ASSERTE (AdapterObject != NULL);
OidData = GlobalAllocPtr (
GMEM_MOVEABLE | GMEM_ZEROINIT,
IoCtlBufferLength
);
if (OidData == NULL)
{
return FALSE;
}
//get the link-layer type
OidData->Oid = OID_GEN_MEDIA_IN_USE;
OidData->Length = sizeof (ULONG);
Status = PacketRequest(AdapterObject,FALSE,OidData);
if(Status==FALSE)return FALSE;
type->LinkType=*((UINT*)OidData->Data);
//get the link-layer speed
OidData->Oid = OID_GEN_LINK_SPEED;
OidData->Length = sizeof (ULONG);
Status = PacketRequest(AdapterObject,FALSE,OidData);
type->LinkSpeed=*((UINT*)OidData->Data)*100;
GlobalFreePtr (OidData);
return Status;
}
示例9: AllocateSample
signed char* CSoundFile::AllocateSample(UINT nbytes)
//-------------------------------------------
{
signed char * p = (signed char *)GlobalAllocPtr(GHND, (nbytes+39) & ~7);
if (p) p += 16;
return p;
}
示例10: PacketOpenAdapter
LPADAPTER PacketOpenAdapter( LPCTSTR AdapterName, int16 mode )
{
LPADAPTER lpAdapter;
BOOLEAN Result = TRUE;
D(bug("Packet32: PacketOpenAdapter\n"));
// May fail if user is not an Administrator.
StartPacketDriver( TEXT("B2ether") );
lpAdapter = (LPADAPTER)GlobalAllocPtr( GMEM_MOVEABLE|GMEM_ZEROINIT, sizeof(ADAPTER) );
if (lpAdapter==NULL) {
D(bug("Packet32: PacketOpenAdapter GlobalAlloc Failed\n"));
return NULL;
}
TCHAR device_name[256];
_sntprintf(lpAdapter->SymbolicLink, lengthof(lpAdapter->SymbolicLink), TEXT("\\\\.\\B2ether_%s"), AdapterName );
_sntprintf(device_name, lengthof(device_name), TEXT("\\Device\\B2ether_%s"), AdapterName );
// Work around one subtle NT4 bug.
DefineDosDevice(
DDD_REMOVE_DEFINITION,
&lpAdapter->SymbolicLink[4],
NULL
);
DefineDosDevice(
DDD_RAW_TARGET_PATH,
&lpAdapter->SymbolicLink[4],
device_name
);
packet_filter = NDIS_PACKET_TYPE_DIRECTED |
NDIS_PACKET_TYPE_MULTICAST |
NDIS_PACKET_TYPE_BROADCAST;
if(mode == ETHER_MULTICAST_ALL) packet_filter |= NDIS_PACKET_TYPE_ALL_MULTICAST;
if(mode == ETHER_MULTICAST_PROMISCUOUS) packet_filter |= NDIS_PACKET_TYPE_PROMISCUOUS;
if (Result) {
lpAdapter->hFile = CreateFile(lpAdapter->SymbolicLink,
GENERIC_WRITE | GENERIC_READ,
0,
NULL,
// (os == VER_PLATFORM_WIN32_NT) ? CREATE_ALWAYS : OPEN_EXISTING,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
0
);
if (lpAdapter->hFile != INVALID_HANDLE_VALUE) {
if(*AdapterName && _tcscmp(AdapterName,TEXT("<None>")) != 0) {
PacketSetFilter( lpAdapter, packet_filter );
}
return lpAdapter;
}
}
D(bug("Packet32: PacketOpenAdapter Could not open adapter\n"));
GlobalFreePtr( lpAdapter );
return NULL;
}
示例11: riffCopyChunk
BOOL riffCopyChunk(HMMIO hmmioSrc, HMMIO hmmioDst, const LPMMCKINFO lpck)
{
MMCKINFO ck;
HPSTR hpBuf;
hpBuf = (HPSTR)GlobalAllocPtr(GHND, lpck->cksize);
if (!hpBuf) return (FALSE);
ck.ckid = lpck->ckid;
ck.cksize = lpck->cksize;
if (mmioCreateChunk(hmmioDst, &ck, 0)) goto rscc_Error;
if (mmioRead(hmmioSrc, hpBuf, lpck->cksize) != (LONG)lpck->cksize) goto rscc_Error;
if (mmioWrite(hmmioDst, hpBuf, lpck->cksize) != (LONG)lpck->cksize) goto rscc_Error;
if (mmioAscend(hmmioDst, &ck, 0)) goto rscc_Error;
if (hpBuf) GlobalFreePtr(hpBuf);
return (TRUE);
rscc_Error:
if (hpBuf) GlobalFreePtr(hpBuf);
return (FALSE);
} /* RIFFSupCopyChunk() */
示例12: PlaceMenuMRUItem
//*************************************************************
//
// PlaceMenuMRUItem()
//
// Purpose:
// Add MRU at the end of a menu
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// HMENU hMenu - Handle of menu where MRU must be added
// UINT uiItem - Item of menu entry where MRU must be added
//
// Return: void
//
//
// Comments:
// Used MRU is modified, for refresh the File menu
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
void PlaceMenuMRUItem( LPMRUMENU lpMruMenu, HMENU hMenu, UINT uiItem )
{
int i;
WORD wNbShow;
if ( lpMruMenu == NULL )
return;
// remove old MRU in menu
for ( i = 0; i <= ( int )( lpMruMenu->wNbLruMenu ); i++ )
RemoveMenu( hMenu, i + lpMruMenu->wIdMru, MF_BYCOMMAND );
if ( lpMruMenu->wNbItemFill == 0 )
return;
// If they are item, insert a separator before the files
InsertMenu( hMenu, uiItem, MF_SEPARATOR, lpMruMenu->wIdMru, NULL );
wNbShow = min( lpMruMenu->wNbItemFill, lpMruMenu->wNbLruShow );
for ( i = ( int )wNbShow - 1; i >= 0; i-- )
{
LPSTR lpTxt;
if ( lpTxt = ( LPSTR )GlobalAllocPtr( GHND, lpMruMenu->wMaxSizeLruItem + 20 ) )
{
wsprintf( lpTxt, "&%lu %s",
( DWORD )( i + 1 ), lpMruMenu->lpMRU + ( lpMruMenu->wMaxSizeLruItem * ( UINT )i ) );
InsertMenu( hMenu, ( ( ( WORD )i ) != ( wNbShow - 1 ) ) ? ( lpMruMenu->wIdMru + i + 2 ) : lpMruMenu->wIdMru,
MF_STRING, lpMruMenu->wIdMru + i + 1, lpTxt );
GlobalFreePtr( lpTxt );
}
}
}
示例13: SaveMruInReg
//*************************************************************
//
// SaveMruInReg()
//
// Purpose:
// Save MRU in the registry
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// LPSTR lpszKey - Points to a null-terminated string
// specifying the name of a key that
// this function opens or creates.
//
// Return: (BOOL)
// TRUE - Function run successfully
// FALSE - Function don't run successfully
//
//
// Comments:
// Win32 function designed for Windows NT and Windows 95
// See RegCreateKeyEx API for more info on lpszKey
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
BOOL SaveMruInReg( LPMRUMENU lpMruMenu, LPSTR lpszKey )
{
LPSTR lpTxt;
WORD i;
HKEY hCurKey;
DWORD dwDisp;
lpTxt = ( LPSTR )GlobalAllocPtr( GHND, lpMruMenu->wMaxSizeLruItem + 20 );
if ( lpTxt == NULL )
return FALSE;
RegCreateKeyEx( HKEY_CURRENT_USER, lpszKey, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hCurKey, &dwDisp );
for ( i = 0; i < lpMruMenu->wNbLruMenu; i++ )
{
char szEntry[16];
wsprintf( szEntry, "File%lu", ( DWORD )i + 1 );
if ( !GetMenuItem( lpMruMenu, i, FALSE, lpTxt, lpMruMenu->wMaxSizeLruItem + 10 ) )
*lpTxt = '\0';
RegSetValueEx( hCurKey, szEntry, 0, REG_SZ, ( unsigned char* )lpTxt, lstrlen( lpTxt ) );
}
RegCloseKey( hCurKey );
GlobalFreePtr( lpTxt );
return TRUE;
}
示例14: LoadMruInReg
//*************************************************************
//
// LoadMruInReg()
//
// Purpose:
// Load MRU from the registry
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// LPSTR lpszKey - Points to a null-terminated string
// specifying the name of a key that
// this function opens or creates.
//
// Return: (BOOL)
// TRUE - Function run successfully
// FALSE - Function don't run successfully
//
//
// Comments:
// Win32 function designed for Windows NT and Windows 95
// See RegOpenKeyEx API for more info on lpszKey
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
BOOL LoadMruInReg( LPMRUMENU lpMruMenu, LPSTR lpszKey )
{
LPSTR lpTxt;
WORD i;
HKEY hCurKey;
DWORD dwType;
lpTxt = ( LPSTR )GlobalAllocPtr( GHND, lpMruMenu->wMaxSizeLruItem + 20 );
if ( lpTxt == NULL )
return FALSE;
RegOpenKeyEx( HKEY_CURRENT_USER, lpszKey, 0, KEY_READ, &hCurKey );
for ( i = 0; i < lpMruMenu->wNbLruMenu; i++ )
{
char szEntry[16];
DWORD dwSizeBuf;
wsprintf( szEntry, "File%lu", ( DWORD )i + 1 );
*lpTxt = '\0';
dwSizeBuf = lpMruMenu->wMaxSizeLruItem + 10;
RegQueryValueEx( hCurKey, szEntry, NULL, &dwType, ( LPBYTE )lpTxt, &dwSizeBuf );
*( lpTxt + dwSizeBuf ) = '\0';
if ( *lpTxt == '\0' )
break;
SetMenuItem( lpMruMenu, i, lpTxt );
}
RegCloseKey( hCurKey );
GlobalFreePtr( lpTxt );
return TRUE;
}
示例15: PacketSetMaxLookaheadsize
//---------------------------------------------------------------------------
BOOLEAN PacketSetMaxLookaheadsize (LPADAPTER AdapterObject)
{
BOOLEAN Status;
ULONG IoCtlBufferLength = (sizeof (PACKET_OID_DATA) + sizeof (ULONG) - 1);
PPACKET_OID_DATA OidData;
ODS ("Packet32: PacketSetFilter\n");
_ASSERTE (AdapterObject != NULL);
OidData = GlobalAllocPtr (
GMEM_MOVEABLE | GMEM_ZEROINIT,
IoCtlBufferLength
);
if (OidData == NULL)
{
return FALSE;
}
//set the size of the lookahead buffer to the maximum available by the the NIC driver
OidData->Oid=OID_GEN_MAXIMUM_LOOKAHEAD;
OidData->Length=sizeof(ULONG);
Status=PacketRequest(AdapterObject,FALSE,OidData);
OidData->Oid=OID_GEN_CURRENT_LOOKAHEAD;
Status=PacketRequest(AdapterObject,TRUE,OidData);
GlobalFreePtr(OidData);
return Status;
}