• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GlobalReAlloc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了GlobalReAlloc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
  }
}
开发者ID:pjmtdw,项目名称:kazesomiso,代码行数:59,代码来源:myprint_proc.cpp


示例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
开发者ID:PlanetAPL,项目名称:nars2000,代码行数:31,代码来源:afofns.c


示例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;
}
开发者ID:MichaelMcDonnell,项目名称:wine,代码行数:38,代码来源:hglobalstream.c


示例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;
	}
开发者ID:benbucksch,项目名称:AppWare,代码行数:31,代码来源:NAT2UNIV.CPP


示例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++;
}
开发者ID:BackupGGCode,项目名称:win16test,代码行数:25,代码来源:msg.c


示例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 */
开发者ID:hubei,项目名称:open-watcom,代码行数:28,代码来源:mem.c


示例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;
	}
开发者ID:benbucksch,项目名称:AppWare,代码行数:30,代码来源:NAT2UNIV.CPP


示例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;

}
开发者ID:jxfengzi,项目名称:AirPhoto,代码行数:35,代码来源:PIUtilitiesWin.cpp


示例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;
}
开发者ID:howard5888,项目名称:wineT,代码行数:36,代码来源:memlockbytes.c


示例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;
    }
}
开发者ID:CyberShadow,项目名称:Ditto,代码行数:59,代码来源:DIBUTIL.CPP


示例11: MyReAlloc

//********************************************************************
Handle MyReAlloc(Handle hMem,
				uint32_t dwSize,
				uint32_t dwFlag)
{
	return CFIO_ReAlloc?
		CFIO_ReAlloc(hMem, dwSize, dwFlag):
		GlobalReAlloc(hMem, dwSize, dwFlag);
}
开发者ID:PauloMigAlmeida,项目名称:cuneiform,代码行数:9,代码来源:rout_dll.cpp


示例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));
}
开发者ID:IFGHou,项目名称:Holodeck,代码行数:20,代码来源:GlobalReAlloc.cpp


示例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;
}
开发者ID:Nerovi,项目名称:LightOPC,代码行数:11,代码来源:dopack.cpp


示例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 ++;
}
开发者ID:axxapp,项目名称:winxgui,代码行数:12,代码来源:CMenuSpawn.cpp


示例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);
}
开发者ID:shivshankardayal,项目名称:Universal-C-C--,代码行数:12,代码来源:tif_win32.c


示例16: prim_globalReAlloc

void* prim_globalReAlloc(HGLOBAL arg1,DWORD arg2,UINT arg3)
{ static struct {HsPtr res1;HsInt gc_failed;HsPtr gc_failstring;} gc_result;
  HGLOBAL res1;int gc_failed;
	       char* gc_failstring;
  do {res1 = GlobalReAlloc(arg1, arg2, arg3);
      if ((gc_failed = ( res1==NULL ))) {gc_failstring = ErrorWin("GlobalReAlloc") ;}
      else {gc_failed = 0;}
      gc_result.res1 = (HGLOBAL)(res1);
      gc_result.gc_failed = gc_failed;
      gc_result.gc_failstring = gc_failstring;
      
      return(&gc_result);} while(0);
}
开发者ID:ygmpkk,项目名称:house,代码行数:13,代码来源:Win32MM_stub_ffi.c


示例17: get_rtf_text

static HGLOBAL get_rtf_text(ME_TextEditor *editor, const ME_Cursor *start, int nChars)
{
    EDITSTREAM es;
    ME_GlobalDestStruct gds;

    gds.hData = GlobalAlloc(GMEM_MOVEABLE, 0);
    gds.nLength = 0;
    es.dwCookie = (DWORD_PTR)&gds;
    es.pfnCallback = ME_AppendToHGLOBAL;
    ME_StreamOutRange(editor, SF_RTF, start, nChars, &es);
    GlobalReAlloc(gds.hData, gds.nLength+1, 0);
    return gds.hData;
}
开发者ID:AlexSteel,项目名称:wine,代码行数:13,代码来源:clipboard.c


示例18: AddScriptCmdArgs

void AddScriptCmdArgs(const TCHAR *arg)
{
  g_sdata.script_cmd_args = GlobalReAlloc(g_sdata.script_cmd_args,
    GlobalSize(g_sdata.script_cmd_args) + (lstrlen(arg) + 2/* quotes */ + 1 /* space */)*sizeof(TCHAR),
    0);

  TCHAR *args = (TCHAR *) GlobalLock(g_sdata.script_cmd_args);

  lstrcat(args, _T(" \""));
  lstrcat(args, arg);
  lstrcat(args, _T("\""));

  GlobalUnlock(g_sdata.script_cmd_args);
}
开发者ID:engineer0x47,项目名称:NSIS,代码行数:14,代码来源:makensisw.cpp


示例19: ReAllocHGlobal

void _fastcall ReAllocHGlobal(ParamBlk *parm)
{
	HGLOBAL hMem;
	hMem = GlobalReAlloc((HGLOBAL)p1.ev_long,(SIZE_T)p2.ev_long,GMEM_MOVEABLE|GMEM_ZEROINIT);
	if (hMem)
	{
		REPLACEDEBUGALLOC(p1.ev_long,hMem,p2.ev_long);		
		RET_INTEGER(hMem);
	}
	else
	{
		SAVEWIN32ERROR(GlobalReAlloc,GetLastError());
		RAISEERROREX(0);
	}
}
开发者ID:akrisiun,项目名称:VfpProj,代码行数:15,代码来源:vfp2cmarshal.c


示例20: NoStatStreamImpl_SetSize

static HRESULT WINAPI NoStatStreamImpl_SetSize(
				     IStream*      iface,
				     ULARGE_INTEGER  libNewSize)   /* [in] */
{
  NoStatStreamImpl* const This=(NoStatStreamImpl*)iface;
  HGLOBAL supportHandle;
  if (libNewSize.u.HighPart != 0)
    return STG_E_INVALIDFUNCTION;
  if (This->streamSize.u.LowPart == libNewSize.u.LowPart)
    return S_OK;
  supportHandle = GlobalReAlloc(This->supportHandle, libNewSize.u.LowPart, 0);
  if (supportHandle == 0)
    return STG_E_MEDIUMFULL;
  This->supportHandle = supportHandle;
  This->streamSize.u.LowPart = libNewSize.u.LowPart;
  return S_OK;
}
开发者ID:howard5888,项目名称:wineT,代码行数:17,代码来源:olepicture.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GlobalRegistry函数代码示例发布时间:2022-05-30
下一篇:
C++ GlobalRNG函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap