View Full Version : GetCurrentInstance
marcuslee
10-09-2008, 04:18
I found GetCurrentInstance in the help file. I decided not to list it among my observations of gaps in the help file because the description and syntax are there. I just don't understand what the description means, so there might be reason to clairfy some, but that's why I am asking about it here.
What is thinBasic's application context instance?
When I ran a script with this in it, it returned 4194304. I don't know what that number is. I tried googling the phrase "application context instance," but none of the sites that came up had a an easy to understand definition.
Mark ???
ErosOlmi
10-09-2008, 07:22
Imagine it as a pointer used to get information about a module loaded by the Operating system. More or less it specifies a location in the memory where the module is loaded.
Module here is used not in thinBasic manner but in the operating system way. A module can be an executable or a DLL loaded by an executable. The same DLL used by different process, have different Instance values.
Once you have that handle, you can use it to get many info about the module. That handle is also a mandatory parameter for many API functions.
RobertoBianchi
10-09-2008, 10:21
Mark,
the INSTANCE comes from 16-bit Windows were it was the only way for identify the data segment when you running same program twice or you use one same DLL more time.
With Win32 & Win64 INSTANCE and MODULE are both the base address in memory of the module, so you can forgot the use of INSTANCE, I mean you can always use the module handle.
Regards,
Roberto
marcuslee
10-09-2008, 16:26
the INSTANCE comes from 16-bit Windows were it was the only way for identify the data segment when you running same program twice or you use one same DLL more time.
With Win32 & Win64 INSTANCE and MODULE are both the base address in memory of the module, so you can forgot the use of INSTANCE, I mean you can always use the module handle.
So, the keyword/function GetCurrentInstance is of no use anymore? If I misunderstood that, I am sorry. What do you mean by: "you can always use the module handle"?
Mark ???
RobertoBianchi
10-09-2008, 16:48
It depends, if you have already loaded the library you got have it's module handle so you can use it directly instead of call GetCurrentInstance(), otherwise you can use GetCurrentInstance() for grab the module instance.
Regards,
Roberto
ErosOlmi
10-09-2008, 16:53
Mark,
I do not think we need too much deeper on this because this matter is more related to compilers rather than interpreters (like thinBasic).
The main reason why we developed GetCurrentInstance function was to give a chance to thinBasic users to be able to call some Windows API functions that require the instance handle.
Ciao
Eros
marcuslee
10-09-2008, 16:58
I do not think we need too much deeper on this ...
Fair enough. Besides, as y'all have described it, it is probably something I will never use. Thank you for the answers, though.
Mark :)