本文整理汇总了C++中GlobalReAlloc函数的典型用法代码示例。如果您正苦于以下问题:C++ GlobalReAlloc函数的具体用法?C++ GlobalReAlloc怎么用?C++ GlobalReAlloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GlobalReAlloc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SelPrinter
void SelPrinter(HWND hDlg){
PRINTDLG pd;
ZeroMemory(&pd,sizeof(PRINTDLG));
pd.lStructSize = sizeof(PRINTDLG);
pd.hwndOwner = hDlg;
HGLOBAL hNewDevMode = NULL;
HGLOBAL hNewDevNames = NULL;
if(hDevMode != NULL && hDevNames != NULL){
int size = GetSizeOfDevMode(hDevMode);
hNewDevMode = GlobalAlloc(GHND,size);
GlobalCpy(hNewDevMode,hDevMode,size);
size = GetSizeOfDevNames(hDevNames);
hNewDevNames = GlobalAlloc(GHND,size);
GlobalCpy(hNewDevNames,hDevNames,size);
}
pd.hDevMode = hNewDevMode;
pd.hDevNames = hNewDevNames;
pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC |
PD_NOPAGENUMS | PD_NOSELECTION | PD_HIDEPRINTTOFILE;
pd.nCopies = GetCurrentPrinterCopies();
pd.nFromPage = 1;
pd.nToPage = 1;
pd.nMinPage = 1;
pd.nMaxPage = 1;
if(PrintDlg(&pd)){
if(hPrintDC != NULL){
DeleteDC(hPrintDC);
}
hPrintDC = pd.hDC;
int size = GetSizeOfDevMode(pd.hDevMode);
if(hDevMode != NULL){
GlobalReAlloc(hDevMode,size,0);
}else{
hDevMode = GlobalAlloc(GHND,size);
}
GlobalCpy(hDevMode,pd.hDevMode,size);
size = GetSizeOfDevNames(pd.hDevNames);
if(hDevNames != NULL){
GlobalReAlloc(hDevNames,size,0);
}else{
hDevNames = GlobalAlloc(GHND,size);
}
GlobalCpy(hDevNames,pd.hDevNames,size);
}
SetCurrentDirectoryToExePath();
if(pd.hDevMode != NULL){
GlobalFree(pd.hDevMode);
}
if(pd.hDevMode != NULL){
GlobalFree(pd.hDevMode);
}
}
示例2: GlobalUnlock
UBOOL AfoDetectResize
(LPAFODETECT_STR lpafoDetectStr)
{
// If there is no more room, ...
if (lpafoDetectStr->uLineStrCnt EQ lpafoDetectStr->uLineStrNxt)
{
HGLOBAL hGlbLineStr;
// Unlock the global memory handle so we may resize it
GlobalUnlock (lpafoDetectStr->hGlbLineStr);
// Reallocate the AFOLINE_STR
// moving the old data to the new location, and
// freeing the old global memory
hGlbLineStr =
GlobalReAlloc (lpafoDetectStr->hGlbLineStr,
(lpafoDetectStr->uLineStrCnt + AFOLINESTR_INCR) * sizeof (AFOLINE_STR),
GMEM_MOVEABLE);
// Check for error
if (hGlbLineStr EQ NULL)
return FALSE;
// Save (possibly new) handle
lpafoDetectStr->hGlbLineStr = hGlbLineStr;
lpafoDetectStr->lpafoLineStr = GlobalLock (hGlbLineStr);
return TRUE;
} else
return TRUE;
} // End AfoDetectResize
示例3: HGLOBALStreamImpl_SetSize
/***
* This method is part of the IStream interface.
*
* It will change the size of a stream.
*
* TODO: Switch from small blocks to big blocks and vice versa.
*
* See the documentation of IStream for more info.
*/
static HRESULT WINAPI HGLOBALStreamImpl_SetSize(
IStream* iface,
ULARGE_INTEGER libNewSize) /* [in] */
{
HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
HGLOBAL supportHandle;
TRACE("(%p, %d)\n", iface, libNewSize.u.LowPart);
/*
* HighPart is ignored as shown in tests
*/
if (This->streamSize.u.LowPart == libNewSize.u.LowPart)
return S_OK;
/*
* Re allocate the HGlobal to fit the new size of the stream.
*/
supportHandle = GlobalReAlloc(This->supportHandle, libNewSize.u.LowPart, 0);
if (supportHandle == 0)
return E_OUTOFMEMORY;
This->supportHandle = supportHandle;
This->streamSize.u.LowPart = libNewSize.u.LowPart;
return S_OK;
}
示例4: sizeof
long UPSF::xxxx_To_UClr(
HGLOBAL& hUniv,
long& univSize,
long natv,
void* natvPtr,
long natvLen)
{
univSize = sizeof(short)*3L;
if(!(hUniv = GlobalReAlloc(hUniv, univSize, MEMFLAGS)))
return AUPSF_MEMORYERROR;
short* univPtr = (short*)GlobalLock(hUniv);
if(!univPtr)
return AUPSF_MEMORYERROR;
long retValue;
if(natv==AUPSF_NATV_RGBCOLOR)
{
if(natvLen != sizeof(COLORREF))
retValue = AUPSF_SIZEERROR;
else
retValue = RGBColor_To_UClr(univPtr, *(COLORREF*)natvPtr);
}
else
retValue = AUPSF_CANTCONVERT;
GlobalUnlock(hUniv);
return retValue;
}
示例5: add_message
static void add_message(const struct message *msg)
{
if (!sequence) {
sequence_size = 10;
sequence =
(struct message *) GlobalAlloc(GMEM_DISCARDABLE,
sequence_size *
sizeof(struct message));
}
if (sequence_cnt == sequence_size) {
sequence_size *= 2;
sequence =
(struct message *) GlobalReAlloc((char NEAR *) sequence,
sequence_size *
sizeof(struct message)
, GMEM_DISCARDABLE);
}
assert(sequence);
sequence[sequence_cnt].message = msg->message;
sequence[sequence_cnt].flags = msg->flags;
sequence[sequence_cnt].wParam = msg->wParam;
sequence[sequence_cnt].lParam = msg->lParam;
sequence_cnt++;
}
示例6: defined
/*
* MemReAlloc - allocate some memory
*/
void *MemReAlloc( void *ptr, unsigned size )
{
void *x;
#ifndef __OS2_PM__
#if defined( DEBUGMEM )
GLOBALHANDLE h;
h = GlobalHandle( FP_SEG( ptr ) );
GlobalUnlock( h );
x = GlobalLock( GlobalReAlloc( h, size, GMEM_ZEROINIT | GMEM_MOVEABLE ) );
#else
x = realloc( ptr, size );
#endif
#else
x = realloc( ptr, size );
#endif
#if defined( WANT_MSGS )
if( x == NULL ) {
MessageBox( HWND_DESKTOP, "AUUGH, Null Pointer", "Memory Allocation",
MB_OK | MB_ICONHAND | MB_SYSTEMMODAL );
}
#endif
return( x );
} /* MemReAlloc */
示例7:
long UPSF::xxxx_To_UFon(
HGLOBAL& hUniv,
long& univSize,
long natv,
void* natvPtr,
long natvLen)
{
univSize = natvLen;
if(!(hUniv = GlobalReAlloc(hUniv, univSize, MEMFLAGS)))
return AUPSF_MEMORYERROR;
long* univPtr = (long*)GlobalLock(hUniv);
if(!univPtr)
return AUPSF_MEMORYERROR;
long retValue = AUPSF_NOERROR;
if(natv==AUPSF_NATV_FONT)
{
// just store the font name--each platform will convert on import
// the attributes will be stored separately
hmemcpy(univPtr, natvPtr, natvLen);
}
else
retValue = AUPSF_CANTCONVERT;
GlobalUnlock(hUniv);
return retValue;
}
示例8: SetHandleSize
void SetHandleSize (Handle handle, size_t newSize)
{
Ptr p;
HANDLE hMem;
memError = noErr;
if (handle)
{
p = *handle;
if (p)
{
GlobalUnlockPtr (p);
hMem = GlobalReAlloc (GlobalPtrHandle (p), newSize, GHND);
if (hMem)
p = (Ptr)GlobalLock (hMem);
else
p = NULL;
}
if (p)
*handle = p;
else
memError = memFullErr;
}
else
memError = memWZErr;
}
示例9: HGLOBALLockBytesImpl_SetSize
/******************************************************************************
* This method is part of the ILockBytes interface.
*
* It will change the size of the byte array.
*
* See the documentation of ILockBytes for more info.
*/
static HRESULT WINAPI HGLOBALLockBytesImpl_SetSize(
ILockBytes* iface,
ULARGE_INTEGER libNewSize) /* [in] */
{
HGLOBALLockBytesImpl* const This=(HGLOBALLockBytesImpl*)iface;
HGLOBAL supportHandle;
/*
* As documented.
*/
if (libNewSize.u.HighPart != 0)
return STG_E_INVALIDFUNCTION;
if (This->byteArraySize.u.LowPart == libNewSize.u.LowPart)
return S_OK;
/*
* Re allocate the HGlobal to fit the new size of the stream.
*/
supportHandle = GlobalReAlloc(This->supportHandle, libNewSize.u.LowPart, 0);
if (supportHandle == 0)
return STG_E_MEDIUMFULL;
This->supportHandle = supportHandle;
This->byteArraySize.u.LowPart = libNewSize.u.LowPart;
return S_OK;
}
示例10: AllocRoomForDIB
HANDLE AllocRoomForDIB(BITMAPINFOHEADER bi, HBITMAP hBitmap)
{
DWORD dwLen;
HANDLE hDIB;
HDC hDC;
LPBITMAPINFOHEADER lpbi;
HANDLE hTemp;
// Figure out the size needed to hold the BITMAPINFO structure
// (which includes the BITMAPINFOHEADER and the color table).
dwLen = bi.biSize + PaletteSize((LPSTR) &bi);
hDIB = GlobalAlloc(GHND,dwLen);
// Check that DIB handle is valid
if (!hDIB)
return NULL;
// Set up the BITMAPINFOHEADER in the newly allocated global memory,
// then call GetDIBits() with lpBits = NULL to have it fill in the
// biSizeImage field for us.
lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
*lpbi = bi;
hDC = GetDC(NULL);
GetDIBits(hDC, hBitmap, 0, (UINT) bi.biHeight, NULL, (LPBITMAPINFO)lpbi,
DIB_RGB_COLORS);
ReleaseDC(NULL, hDC);
// If the driver did not fill in the biSizeImage field,
// fill it in -- NOTE: this is a bug in the driver!
if (lpbi->biSizeImage == 0)
lpbi->biSizeImage = WIDTHBYTES((DWORD)lpbi->biWidth *
lpbi->biBitCount) * lpbi->biHeight;
// Get the size of the memory block we need
dwLen = lpbi->biSize + PaletteSize((LPSTR) &bi) + lpbi->biSizeImage;
// Unlock the memory block
GlobalUnlock(hDIB);
// ReAlloc the buffer big enough to hold all the bits
if (hTemp = GlobalReAlloc(hDIB,dwLen,0))
return hTemp;
else
{
// Else free memory block and return failure
GlobalFree(hDIB);
return NULL;
}
}
示例11: MyReAlloc
//********************************************************************
Handle MyReAlloc(Handle hMem,
uint32_t dwSize,
uint32_t dwFlag)
{
return CFIO_ReAlloc?
CFIO_ReAlloc(hMem, dwSize, dwFlag):
GlobalReAlloc(hMem, dwSize, dwFlag);
}
示例12: My_GlobalReAlloc
BOOL My_GlobalReAlloc()
{
HGLOBAL hMem=NULL;
SIZE_T dwBytes=NULL;
UINT uFlags=NULL;
HGLOBAL returnVal_Real = NULL;
HGLOBAL returnVal_Intercepted = NULL;
DWORD error_Real = 0;
DWORD error_Intercepted = 0;
__try{
disableInterception();
returnVal_Real = GlobalReAlloc (hMem,dwBytes,uFlags);
error_Real = GetLastError();
enableInterception();
returnVal_Intercepted = GlobalReAlloc (hMem,dwBytes,uFlags);
error_Intercepted = GetLastError();
}__except(puts("in filter"), 1){puts("exception caught");}
return ((returnVal_Real == returnVal_Intercepted) && (error_Real == error_Intercepted));
}
示例13: gmem_realloc
static HGLOBAL gmem_realloc(HGLOBAL *hg, unsigned size)
{
HGLOBAL hn;
if (hn = *hg? GlobalReAlloc(*hg, size, loGMEM_FLAG):
GlobalAlloc(loGMEM_FLAG, size)) *hg = hn;
/* else
{
UL_WARNING((LOGID, "%!L gmem_alloc(%u) FAILED", size));
}*/
return hn;
}
示例14: GlobalAlloc
void CMenuSpawn::AddImageItem(const int idx, WORD cmd)
{
if (iImageItem == 0)
pImageItem = (ImageItem *) GlobalAlloc(GPTR, sizeof(ImageItem));
else
pImageItem = (ImageItem *) GlobalReAlloc((HGLOBAL) pImageItem, sizeof(ImageItem) * (iImageItem + 1), GMEM_MOVEABLE|GMEM_ZEROINIT);
ASSERT(pImageItem);
pImageItem[iImageItem].iCmd = (int) cmd;
pImageItem[iImageItem].iImageIdx = idx;
iImageItem ++;
}
示例15: _TIFFrealloc
tdata_t
_TIFFrealloc(tdata_t p, tsize_t s)
{
void* pvTmp;
if ((pvTmp = GlobalReAlloc(p, s, 0)) == NULL) {
if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) {
CopyMemory(pvTmp, p, GlobalSize(p));
GlobalFree(p);
}
}
return ((tdata_t)pvTmp);
}