We know,Under Win32, instance handle and module handle are one and the same.
but who know what difference between them under Win16.
but who know what difference between them under Win16.
Windows 3.1 knows instance handles, task handles, and module handles. Instance handles are, in fact, selectors of the default data segments of the application instance. (This fact is sometimes used to change the data segment so that an operation can work on the default data segment of a different application?an ugly practice, but it works.) The task handle is the selector of a global memory block that contains task-specific parameters (such as the input queue that is associated with the task). The module handle is the selector of a global memory block that contains a modified version of the executable header associated with the module. (This memory block is also known as the module database.)
For applications in Windows 3.1, there is only one module database in the system for all instances of the application, whereas both the task database and the default data segment exist separately for each instance of the application. The GetModuleHandle API returns the handle (selector) of the module database, whereas a call to GetWindowWord with GWW_HINSTANCE passed as the second parameter returns the instance handle, and the GetCurrentTask API returns the task database handle. For other applications, the TaskFirst/TaskNext Toolhelp API functions can be employed to retrieve the task database handles.
For applications in Windows 3.1, there is only one module database in the system for all instances of the application, whereas both the task database and the default data segment exist separately for each instance of the application. The GetModuleHandle API returns the handle (selector) of the module database, whereas a call to GetWindowWord with GWW_HINSTANCE passed as the second parameter returns the instance handle, and the GetCurrentTask API returns the task database handle. For other applications, the TaskFirst/TaskNext Toolhelp API functions can be employed to retrieve the task database handles.
Under Win32, instance/module handles are basically memory handles, and in the current implementations are (linear) memory addresses.
Under Win16, instance and module handles represent memory segments. I don't remember if there was a "real mode" version of Win3.1. (3.0 supported real mode.) Under protected mode, the instance and module handles are segment selectors. Win16 was primarily targeted for 286 systems. 286s have protected mode but not paging. Instance handles were data selectors, and module handles were probably code selectors. At any rate, module handles represented individual EXE and DLL files.
(Out of print) "Undocumented Windows" by Matt Pietrek has details on the different kinds of handles. For each module handle, there could be several instance handles (representing different "launches"). The instance handles were not shared, so Win16 could always convert instance handles to module handles whenever a module handle was needed (a hidden overhead in Win16).
Under Win16, instance and module handles represent memory segments. I don't remember if there was a "real mode" version of Win3.1. (3.0 supported real mode.) Under protected mode, the instance and module handles are segment selectors. Win16 was primarily targeted for 286 systems. 286s have protected mode but not paging. Instance handles were data selectors, and module handles were probably code selectors. At any rate, module handles represented individual EXE and DLL files.
(Out of print) "Undocumented Windows" by Matt Pietrek has details on the different kinds of handles. For each module handle, there could be several instance handles (representing different "launches"). The instance handles were not shared, so Win16 could always convert instance handles to module handles whenever a module handle was needed (a hidden overhead in Win16).
Thank YOu Two.
but i am so hard to understand yous because of my language and
knowledge.
but i am so hard to understand yous because of my language and
knowledge.
Simply then :
In Win16 there was only one module handle for all copies of an app that are running but there was a separate instance handle for each one. If you wanted to talk to all copies of the application you used the module handle if you only wanted to talk to a single running copy you used the instance handle.
In Win16 there was only one module handle for all copies of an app that are running but there was a separate instance handle for each one. If you wanted to talk to all copies of the application you used the module handle if you only wanted to talk to a single running copy you used the instance handle.