本文整理汇总了C++中LocalUnlock函数的典型用法代码示例。如果您正苦于以下问题:C++ LocalUnlock函数的具体用法?C++ LocalUnlock怎么用?C++ LocalUnlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LocalUnlock函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: MyEnumKey
unsigned long NEAR PASCAL MyEnumKey(HKEY hKey, WORD wIndex, HANDLE *hBuf)
{
HANDLE hTemp;
PSTR pBuf;
WORD wBufSize = BLOCKLEN, wSize;
unsigned long result = ERROR_OUTOFMEMORY;
if(!(*hBuf=LocalAlloc(LMEM_MOVEABLE, wBufSize)))
goto Error1;
if(!(pBuf=LocalLock(*hBuf)))
goto Error2;
while((result=RegEnumKey(hKey, wIndex, pBuf, (DWORD)wBufSize))
==ERROR_SUCCESS && (wSize=lstrlen(pBuf))>wBufSize-10) {
LocalUnlock(*hBuf);
wBufSize += BLOCKLEN;
if(!(hTemp=LocalReAlloc(*hBuf, wBufSize, LMEM_MOVEABLE))) {
result = ERROR_OUTOFMEMORY;
goto Error2;
}
pBuf = LocalLock(*hBuf=hTemp);
}
LocalUnlock(*hBuf);
if(result!=ERROR_SUCCESS || !wSize)
goto Error2;
goto Error1;
Error2:
LocalFree(*hBuf);
*hBuf = NULL;
Error1:
return(result);
}
开发者ID:chunhualiu,项目名称:OpenNT,代码行数:33,代码来源:cutils1.c
示例2: MyQueryValue
unsigned long NEAR PASCAL MyQueryValue(HKEY hKey, PSTR pSubKey, HANDLE *hBuf)
{
HANDLE hTemp;
PSTR pBuf;
WORD wBufSize = BLOCKLEN;
unsigned long result = ERROR_OUTOFMEMORY;
LONG lSize;
if(!(*hBuf=LocalAlloc(LMEM_MOVEABLE, wBufSize)))
goto Error1;
if(!(pBuf=LocalLock(*hBuf)))
goto Error2;
while((lSize=wBufSize, (result=RegQueryValue(hKey, pSubKey, pBuf, &lSize))
==ERROR_SUCCESS) && (WORD)lSize>wBufSize-10) {
LocalUnlock(*hBuf);
wBufSize += BLOCKLEN;
if(!(hTemp=LocalReAlloc(*hBuf, wBufSize, LMEM_MOVEABLE))) {
result = ERROR_OUTOFMEMORY;
goto Error2;
}
pBuf = LocalLock(*hBuf=hTemp);
}
LocalUnlock(*hBuf);
if(result!=ERROR_SUCCESS || !lSize)
goto Error2;
goto Error1;
Error2:
LocalFree(*hBuf);
*hBuf = NULL;
Error1:
return(result);
}
开发者ID:chunhualiu,项目名称:OpenNT,代码行数:34,代码来源:cutils1.c
示例3: GetProcAddress
// ---------------------------------------------------------------------------
//
HBITMAP __fastcall TForm1::SPI_LoadImage(String fileName) {
/* 対応プラグインの検索 */
for (int i = 0; i < hSPI->Count; i++) { // プラグイン関数の取得
SPI_ISSUPPORTED spi_issupported = (SPI_ISSUPPORTED) GetProcAddress((HMODULE) hSPI->Items[i], SPIPROC_ISSUPPORTED);
SPI_GETPICTURE spi_getpicture = (SPI_GETPICTURE) GetProcAddress((HMODULE) hSPI->Items[i], SPIPROC_GETPICTURE);
if (spi_issupported == NULL || spi_getpicture == NULL) {
continue;
}
// File内容をロードする
HANDLE handle; // = NULL;
if ((handle = CreateFile_Read(fileName.w_str())) == INVALID_HANDLE_VALUE) {
return NULL;
}
DWORD filesize = GetFileSize(handle, NULL), readsize;
LPSTR data = (LPSTR) Heap_Malloc(filesize);
SetFilePointer(handle, 0, NULL, FILE_BEGIN);
if (!ReadFile(handle, data, filesize, &readsize, NULL)) {
CloseHandle(handle);
}
CloseHandle(handle);
// ロードできる形式かどうかをチェックする
if (spi_issupported(AnsiString(fileName).c_str(), (DWORD) data) == 0) {
Heap_Free(data);
continue;
}
// 画像を展開する
HLOCAL info, bm;
if (spi_getpicture(data, filesize, 1, &info, &bm, NULL, 0) != 0) {
Heap_Free(data);
}
LPBITMAPINFO bmpinfo = (LPBITMAPINFO) LocalLock(info); // BITMAPINFO構造体
LPBYTE bmbits = (LPBYTE) LocalLock(bm); // 画像データ
// 取得した情報からBITMAPハンドルを生成する
HDC dc = GetDC(0);
HBITMAP bitmap = CreateDIBitmap(dc, &bmpinfo->bmiHeader, CBM_INIT, bmbits, bmpinfo, DIB_RGB_COLORS);
ReleaseDC(0, dc);
// Free etc...
LocalUnlock(info);
LocalFree(info);
LocalUnlock(bm);
LocalFree(bm);
Heap_Free(data);
return bitmap;
}
return NULL;
}
开发者ID:leiqunni,项目名称:v2iewx,代码行数:61,代码来源:main.cpp
示例4: MDIWndProc
/*
MDIWndProc
*/
LRESULT CALLBACK MDIWndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HANDLE hInfo;
PINFO pInfo;
MSG msg;
EventRecord macEvent;
LONG thePoints = GetMessagePos();
PAINTSTRUCT ps;
msg.hwnd = hwnd;
msg.message = message;
msg.wParam = wParam;
msg.lParam = lParam;
msg.time = GetMessageTime();
msg.pt.x = LOWORD(thePoints);
msg.pt.y = HIWORD(thePoints);
WinEventToMacEvent(&msg, &macEvent);
switch (message)
{
case WM_CREATE:
case WM_MDICREATE:
break;
case WM_DESTROY:
hInfo = (HANDLE)GetWindowLong(hwnd, GWL_USERDATA);
if (hInfo)
{
if ((pInfo = (PINFO)LocalLock(hInfo)) != NULL){
if (pInfo->gi)
// close the graphic import component
CloseComponent(pInfo->gi);
// Destroy our port association
DestroyPortAssociation((CGrafPort *)GetHWNDPort(pInfo->hwndChildWindow));
}
LocalUnlock(hInfo);
}
break;
// Draw our graphic
case WM_PAINT:
BeginPaint(hwnd, &ps);
hInfo = (HANDLE)GetWindowLong(hwnd, GWL_USERDATA);
if (hInfo)
{
if ((pInfo = (PINFO)LocalLock(hInfo)) != NULL)
GraphicsImportDraw(pInfo->gi);
LocalUnlock(hInfo);
}
EndPaint(hwnd, &ps);
break;
default:
return DefMDIChildProc(hwnd, message, wParam, lParam);
}
return DefMDIChildProc(hwnd, message, wParam, lParam);
}
开发者ID:fruitsamples,项目名称:graphicimporter.win,代码行数:62,代码来源:GraphicImporter.c
示例5: ASSERT_VALID
void CEditView::ReadFromArchive(CArchive& ar, UINT nLen)
// Read certain amount of text from the file, assume at least nLen
// characters (not bytes) are in the file.
{
ASSERT_VALID(this);
LPVOID hText = LocalAlloc(LMEM_MOVEABLE, (nLen+1)*sizeof(TCHAR));
if (hText == NULL)
AfxThrowMemoryException();
LPTSTR lpszText = (LPTSTR)LocalLock(hText);
ASSERT(lpszText != NULL);
if (ar.Read(lpszText, nLen*sizeof(TCHAR)) != nLen*sizeof(TCHAR))
{
LocalUnlock(hText);
LocalFree(hText);
AfxThrowArchiveException(CArchiveException::endOfFile);
}
// Replace the editing edit buffer with the newly loaded data
lpszText[nLen] = '\0';
#ifndef _UNICODE
if (afxData.bWin32s)
{
// set the text with SetWindowText, then free
BOOL bResult = ::SetWindowText(m_hWnd, lpszText);
LocalUnlock(hText);
LocalFree(hText);
// make sure that SetWindowText was successful
if (!bResult || ::GetWindowTextLength(m_hWnd) < (int)nLen)
AfxThrowMemoryException();
// remove old shadow buffer
delete[] m_pShadowBuffer;
m_pShadowBuffer = NULL;
m_nShadowSize = 0;
ASSERT_VALID(this);
return;
}
#endif
LocalUnlock(hText);
HLOCAL hOldText = GetEditCtrl().GetHandle();
ASSERT(hOldText != NULL);
LocalFree(hOldText);
GetEditCtrl().SetHandle((HLOCAL)(UINT)(DWORD)hText);
Invalidate();
ASSERT_VALID(this);
}
开发者ID:rickerliang,项目名称:OpenNT,代码行数:49,代码来源:viewedit.cpp
示例6: SizeHintBar
/*
* SizeHintBar - resize the hint bar
*/
WORD SizeHintBar( statwnd *wnd )
{
HLOCAL hinfo;
HintWndInfo *info;
HFONT font;
HFONT oldfont;
HDC dc;
SIZE sz;
RECT area;
HWND hint;
hint = GetHintHwnd( wnd );
hinfo = GetProp( hint, HINT_PROP_ID );
info = LocalLock( hinfo );
dc = GetDC( hint );
font = GetMonoFont();
oldfont = SelectObject( dc, font );
GetTextExtentPoint( dc, "A", 1, &sz );
SelectObject( dc, oldfont );
ReleaseDC( hint, dc );
GetClientRect( info->parent, &area );
area.top = area.bottom - sz.cy - TOTAL_VERT;
MoveWindow( hint, area.left, area.top, area.right - area.left, area.bottom - area.top, TRUE );
updateHintText( wnd, info->curmsg );
GetWindowRect( hint, &area );
LocalUnlock( hinfo );
return( (WORD)( area.bottom - area.top ) );
} /* SizeHintBar */
开发者ID:ArmstrongJ,项目名称:open-watcom-v2,代码行数:32,代码来源:hint.c
示例7: getItemMsg
/*
* getItemMsg - find the hint message for the specified menu item
*/
static msg_id getItemMsg( statwnd *wnd, ctl_id menuid )
{
int i;
HWND hint;
HLOCAL hinfo;
HintWndInfo *info;
const MenuItemHint *hinttable;
msg_id msgid;
hint = GetHintHwnd( wnd );
hinfo = GetProp( hint, HINT_PROP_ID );
info = LocalLock( hinfo );
hinttable = info->hints;
msgid = HINT_EMPTY;
if( hinttable != NULL ) {
for( i = 0; i < info->hint_num_items; i++ ) {
if( hinttable[i].menuid == menuid ) {
msgid = hinttable[i].msgid;
break;
}
}
}
LocalUnlock( hinfo );
return( msgid );
} /* getItemMsg */
开发者ID:ArmstrongJ,项目名称:open-watcom-v2,代码行数:29,代码来源:hint.c
示例8: HandleSetHandlePrintHex
static
VOID
HandleSetHandlePrintHex(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam)
{
LPVOID pMem;
HANDLE hNewBuffer;
int ret;
LocalFree((HLOCAL)SendMessage(handle, EM_GETHANDLE, 0, 0L));
if (UnicodeUsed)
{
hNewBuffer = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, 100);
pMem = LocalLock(hNewBuffer);
strcpyw_((wchar_t*)pMem,NewTextW);
}
else
{
hNewBuffer = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT,50);
pMem = LocalLock(hNewBuffer);
strcpy_((char*)pMem,NewText);
}
LocalUnlock(pMem);
hNewBuffer = LocalHandle(pMem);
/* Updates the buffer and displays new buffer */
ret = SendMessage(handle, EM_SETHANDLE, (WPARAM)hNewBuffer, 0L);
htoa(ret,&TextBuffer[8]);
PrintTextXY(TextBuffer,ResultX,ResultY,16);
}
开发者ID:hoangduit,项目名称:reactos,代码行数:31,代码来源:edittest.c
示例9: CreateWindowEx
BOOL CStatusBar::Create(int x, int y, int iWidth, int iHeight, DWORD dwStyle, int nParts)
{
BOOL bRet = FALSE;
LPINT lpParts;
RECT rcClient;
int nWidth = 0;
m_hwndStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL, dwStyle, x, y, iWidth, iHeight, m_hParent, m_hMenu, m_hInst, NULL);
if (!m_hwndStatus)
{
return bRet;
}
GetClientRect(m_hParent, &rcClient);
//allocates the specified number of bytes from the heap
m_hLoc = LocalAlloc(LHND, sizeof(int) * nParts);
lpParts = (LPINT)LocalLock(m_hLoc);
nWidth = (rcClient.right - rcClient.left) / nParts;
for (int i = 0; i < nParts; i++)
{
lpParts[i] = nWidth;
nWidth += nWidth;
}
SendMessage(m_hwndStatus, SB_SETPARTS, (WPARAM)nParts, (LPARAM)lpParts);
LocalUnlock(m_hLoc);
LocalFree(m_hLoc);
bRet = TRUE;
return bRet;
}
开发者ID:DIOSZHOU,项目名称:WndProject,代码行数:27,代码来源:StatusBar.cpp
示例10: strncpy
void CStationDlg::OnClickedDecodeh(void)
{
CEdit *cetodo = (CEdit *) CWnd::GetDlgItem(IDC_TODO1);
int i,j;
cetodo->GetSel(i,j);
// NT SPECIFIC
HLOCAL h = cetodo->GetHandle();
LPCTSTR lpszText = (LPCTSTR)LocalLock(h);
char res[1000];
strncpy(res,&(lpszText[i]),j-i);
SetDlgItemText(IDC_DECDEC,res);
unsigned short f;
unsigned char *pf;
unsigned int b1,b2;
pf = (unsigned char *)&f;
sscanf(res,"%x %x",&b1,&b2);
pf[0] = b1;
pf[1] = b2;
CString sres;
sres.Format("%04X = %d",f,f);
SetDlgItemText(IDC_DECFLOAT,sres);
LocalUnlock(h);
// END OF NT SPECIFIC
}
开发者ID:AllegianceZone,项目名称:ICE,代码行数:26,代码来源:StationDlg.cpp
示例11: LocalFreePtr
void
LocalFreePtr(void *ptr)
{
HLOCAL hlocal;
hlocal = LocalHandle(ptr);
LocalUnlock(hlocal);
LocalFree(hlocal);
return;
}
开发者ID:XianliangJ,项目名称:gnuplot,代码行数:9,代码来源:wgnuplib.c
示例12: LocalReAllocPtr
void *
LocalReAllocPtr(void * ptr, UINT flags, UINT size)
{
HLOCAL hlocal;
hlocal = LocalHandle(ptr);
LocalUnlock(hlocal);
hlocal = LocalReAlloc(hlocal, size+1, flags);
return (char *)LocalLock(hlocal);
}
开发者ID:XianliangJ,项目名称:gnuplot,代码行数:9,代码来源:wgnuplib.c
示例13: MyGetProfileInt
int NEAR PASCAL MyGetProfileInt(WORD wAppName, WORD wKey, int nDefault)
{
HANDLE hAppName, hKey;
if(!(hAppName=MyLoadString(wAppName, NULL, LMEM_MOVEABLE)))
goto Error1;
if(!(hKey=MyLoadString(wKey, NULL, LMEM_MOVEABLE)))
goto Error2;
nDefault = GetProfileInt(LocalLock(hAppName), LocalLock(hKey), nDefault);
LocalUnlock(hKey);
LocalUnlock(hAppName);
Error2:
LocalFree(hKey);
Error1:
LocalFree(hAppName);
return(nDefault);
}
开发者ID:chunhualiu,项目名称:OpenNT,代码行数:19,代码来源:cutils1.c
示例14: get_printSetup_with_PRINTDLG
void get_printSetup_with_PRINTDLG(PRINTDLG *pd, char **o_devmode,
char **o_device, char **o_driver, char **o_output)
{
char *newDriver, *newDevice, *newOutput;
DEVMODE *pDevmode;
DEVNAMES *pDevnames;
pDevmode = LocalLock(pd->hDevMode);
*o_devmode = PassString(pDevmode->dmDeviceName);
LocalUnlock(pd->hDevMode);
pDevnames = LocalLock(pd->hDevNames);
newDriver = ((char*)pDevnames)+(pDevnames->wDriverOffset);
newDevice = ((char*)pDevnames)+(pDevnames->wDeviceOffset);
newOutput = ((char*)pDevnames)+(pDevnames->wOutputOffset);
*o_driver = PassString(newDriver);
*o_device = PassString(newDevice);
*o_output = PassString(newOutput);
LocalUnlock(pd->hDevNames);
}
开发者ID:ygmpkk,项目名称:house,代码行数:19,代码来源:cprinter_121.c
示例15: setupDevmode
static HANDLE setupDevmode(int size, char *pData)
{
HANDLE hDevmode;
DEVMODE *pDevmode;
hDevmode = (HANDLE) LocalAlloc(LMEM_MOVEABLE, size);
pDevmode = LocalLock(hDevmode);
memcpy((char*)pDevmode, pData, size);
LocalUnlock(hDevmode);
return hDevmode;
}
开发者ID:ygmpkk,项目名称:house,代码行数:11,代码来源:cprinter_121.c
示例16: UnlockWindowInfo
/*---------------------------------------------------------------------------*\
| UNLOCK WINDOW INFO
| This routine unlocks the memory the caller has previously locked.
\*---------------------------------------------------------------------------*/
BOOL FAR UnlockWindowInfo(HWND hWnd)
{
HANDLE hMem;
if(hMem = (HANDLE)GetWindowLongPtr(hWnd,0))
if(!LocalUnlock(hMem))
return(TRUE);
return(FALSE);
}
开发者ID:469306621,项目名称:Languages,代码行数:15,代码来源:Wininfo.c
示例17: LocalHandle
void TAppDictionary::FreeTable(TAppDictionaryEntry *pTable)
{
HANDLE hMem =
#ifdef STRICT
LocalHandle((void NEAR*)FP_OFF(pTable));
#else
LocalHandle(FP_OFF(pTable));
#endif
if (LocalUnlock(hMem))
LocalFree(hMem);
}
开发者ID:nicolaemariuta,项目名称:bachelorHomeworkAndStudy,代码行数:11,代码来源:APPDICT.CPP
示例18: WriteProfileInt
VOID NEAR PASCAL WriteProfileInt(WORD wAppName, WORD wKey, int nVal)
{
HANDLE hAppName, hKey;
char buf[10];
if(!(hAppName=MyLoadString(wAppName, NULL, LMEM_MOVEABLE)))
goto Error1;
if(!(hKey=MyLoadString(wKey, NULL, LMEM_MOVEABLE)))
goto Error2;
wsprintf(buf, "%d", nVal);
WriteProfileString(LocalLock(hAppName), LocalLock(hKey), buf);
LocalUnlock(hKey);
LocalUnlock(hAppName);
Error2:
LocalFree(hKey);
Error1:
LocalFree(hAppName);
}
开发者ID:chunhualiu,项目名称:OpenNT,代码行数:20,代码来源:cutils1.c
示例19: GetFile
//---------------------------------------------------------------------------
tTJSBinaryStream * tTVPSusieArchivePlugin::CreateStream(std::wstring localname,
unsigned long pos, unsigned long size)
{
HLOCAL memhandle = NULL;
int errorcode = 0xff & GetFile(const_cast<LPSTR>(ttstr(localname).AsNarrowStdString().c_str()), pos, (LPSTR)(void*)&memhandle,
0x0100, (FARPROC)ProgressCallback, 0);
if(errorcode || memhandle == NULL)
{
TVPThrowExceptionMessage(TVPSusiePluginError,
ttstr(TJS_W("tTVPSusieArchivePlugin::GetFile failed, errorcode = ")) +
ttstr((tjs_int)errorcode));
}
tTVPMemoryStream *memstream = new tTVPMemoryStream;
void *memblock = NULL;
try
{
memblock = LocalLock(memhandle);
if(memblock == NULL)
{
TVPThrowExceptionMessage(TVPSusiePluginError,
ttstr(TJS_W("tTVPSusieArchivePlugin::GetFile failed : invalid memory block.")));
}
// write to on-memory stream
memstream->WriteBuffer(memblock, size);
memstream->SetPosition(0);
}
catch(...)
{
if(memblock) LocalUnlock(memhandle);
LocalFree(memhandle);
delete memstream;
throw;
}
if(memblock) LocalUnlock(memhandle);
LocalFree(memhandle);
return memstream;
}
开发者ID:John-He-928,项目名称:krkrz,代码行数:42,代码来源:SusieArchive.cpp
示例20: DoCreateStatusBar
HWND DoCreateStatusBar(HWND hwndParent, int idStatus, HINSTANCE
hinst, int cParts)
{
HWND hwndStatus;
RECT rcClient;
HLOCAL hloc;
PINT paParts;
int i, nWidth;
// Ensure that the common control DLL is loaded.
InitCommonControls();
// Create the status bar.
hwndStatus = CreateWindowEx(
0, // no extended styles
STATUSCLASSNAME, // name of status bar class
(PCTSTR) NULL, // no text when first created
WS_CHILD | WS_VISIBLE, // creates a visible child window
0, 0, 0, 0, // ignores size and position
hwndParent, // handle to parent window
(HMENU) idStatus, // child window identifier
hinst, // handle to application instance
NULL); // no window creation data
// Get the coordinates of the parent window's client area.
GetClientRect(hwndParent, &rcClient);
// Allocate an array for holding the right edge coordinates.
hloc = LocalAlloc(LHND, sizeof(int) * cParts);
paParts = (PINT) LocalLock(hloc);
// Calculate the right edge coordinate for each part, and
// copy the coordinates to the array.
nWidth = rcClient.right / cParts;
int rightEdge = nWidth;
for (i = 0; i < cParts; i++) {
paParts[i] = rightEdge;
rightEdge += nWidth;
}
// Tell the status bar to create the window parts.
SendMessage(hwndStatus, SB_SETPARTS, (WPARAM) cParts, (LPARAM)
paParts);
// Free the array, and return.
LocalUnlock(hloc);
LocalFree(hloc);
::SetWindowTextW(hwndStatus, L"asasd");
return hwndStatus;
}
开发者ID:F145h,项目名称:wot-tundra,代码行数:52,代码来源:main.cpp
注:本文中的LocalUnlock函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论