· Начало · Отвђтить · Статистика · Поиск · FAQ · Правила · Установки · Язык · Выход · WASM.RU · Noir.Ru ·

 WASM Phorum —› WASM.WIN32 —› LockResource

Посл.отвђт Сообщенiе


Дата: Июл 5, 2004 23:33:29

Что делает эта функция? В Win32.hlp написано, что она возвращает указатель на данные ресурса, но у меня под win2k сколько ни тестировал, всегда
(LockResource(hResource)==hResource)


Дата: Июл 5, 2004 23:47:11

она возвращает указатель на данные ресурса
Просто в win2k чаще всего Handle = Адресс в памяти
А вот в win98 реще, незнаю почему - это гдето в ядре


Дата: Июл 6, 2004 01:39:46

I'm как бы сорри. Но Loger у тебя нет MSDN????????
Обзаведись им, ссылки в Faq от WASM.RU. Теперь описалово:

The LoadResource function loads the specified resource into global memory.

Syntax

HGLOBAL LoadResource( HMODULE hModule,
HRSRC hResInfo
);
Parameters

hModule
[in] Handle to the module whose executable file contains the resource. If hModule is NULL, the system loads the resource from the module that was used to create the current process.
hResInfo
[in] Handle to the resource to be loaded. This handle is returned by the FindResource or FindResourceEx function.
Return Value

If the function succeeds, the return value is a handle to the data associated with the resource.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.




Remarks

The return type of LoadResource is HGLOBAL for backward compatibility, not because the function returns a handle to a global memory block. Do not pass this handle to the GlobalLock or GlobalFree function. To obtain a pointer to the resource data, call the LockResource function.

To use a resource immediately, an application should use the following resource-specific functions to find and load the resource in one call.

Function Action To remove resource
FormatMessage Loads and formats a message-table entry No action needed
LoadAccelerators Loads an accelerator table DestroyAcceleratorTable
LoadBitmap Loads a bitmap resource DeleteObject
LoadCursor Loads a cursor resource DestroyCursor
LoadIcon Loads an icon resource DestroyIcon
LoadMenu Loads a menu resource DestroyMenu
LoadString Loads a string resource No action needed


For example, an application can use the LoadIcon function to load an icon for display on the screen, followed by DestroyIcon when done.

The system automatically deletes these resources when the process that created them terminates, however, calling the appropriate function saves memory and decreases the size of the process's working set.


Дата: Июл 6, 2004 02:36:16

Посмотреть реализацию что мешает:
    kernel32.>  8B4424 04       mov     eax, [dword ss:esp+4]               ; kernel32.77E814C7
    77E7E355    C2 0400         retn    4
Похоже, эта функция пережиток виндос 3 :).


Дата: Июл 6, 2004 07:18:07 · Поправил: rsrc

HGLOBAL досталась нам от Win16, если память выделена с атрибутом GMEM_FIXED, то это просто адрес, а если с атрибутом GMEM_MOVEABLE, то это уже описатель и поэтому надо вызывать GlobalLock(), LockResource() для того, чтобы получить адрес и блокировать от переразмещения память.
Ну а LoadResource() возвращает HGLOBAL (память c атрибутом GMEM_FIXED) и следовательно это адрес, а не описатель.

З.Ы. Читайте Дж. Круглински стр. 166, 168 :)


Powered by miniBB 1.6 © 2001-2002
Время загрузки страницы (сек.): 0.053