The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: DC on December 10, 2005, 06:58:24 PM

Title: InitCommonControls Q
Post by: DC on December 10, 2005, 06:58:24 PM
this is from Icxelion's Tutorial Series:
.code
start:
    invoke GetModuleHandle, NULL
    mov    hInstance,eax
    invoke WinMain, hInstance,NULL,NULL, SW_SHOWDEFAULT
    invoke ExitProcess,eax
    invoke InitCommonControls

how does the "InitCommonControls" work if it's after the "ExitProcess"?
thanx,
DC
Title: Re: InitCommonControls Q
Post by: DC on December 10, 2005, 07:40:14 PM
just for the fun of it, I commented out the "InitCommonControls" line and it still works.
this is from "Tutorial 19: Tree View Control"
"InitCommonControls" isn't anywhere else in the code, so...
is that unnecessary? is it called from another fn?
I'm not getting it?
thanx,
DC
Title: Re: InitCommonControls Q
Post by: comrade on December 10, 2005, 11:47:28 PM
There is no execution after ExitProcess(), the CPU will never get to executing InitCommonControls

InitCommonControls is an obsolete API, and Microsoft documentation recommends using InitCommonControlsEx instead. It is probably that some controls will still work because they are already loaded in memory, but it is good practice to still call this function.
Title: Re: InitCommonControls Q
Post by: DC on December 10, 2005, 11:53:22 PM
thanx a bunch, I almost left it out since it seems to work without it.
Title: Re: InitCommonControls Q
Post by: G`HOST on December 11, 2005, 06:06:44 AM
whatever,the code doesnt execute after the ExitProcess,why is it include in the sourcecode of a tutorial ?and that too by someone like Iczelion ?Is it a mistake ?
Title: Re: InitCommonControls Q
Post by: Petroizki on December 11, 2005, 07:22:42 AM
Quote from: G`HOST on December 11, 2005, 06:06:44 AM
whatever,the code doesnt execute after the ExitProcess,why is it include in the sourcecode of a tutorial ?and that too by someone like Iczelion ?Is it a mistake ?
The idea is just probably to force the comctl32.dll library to be loaded at execution, making a useless "call" to some function like InitCommonControls does the trick.
Title: Re: InitCommonControls Q
Post by: G`HOST on December 11, 2005, 09:16:36 AM
Yes he (Iczlion in the tute) does mention that just include it anywhere in the code and  ofcource it is used to load comctl32.dll,but if the compiler doesnt read anything after the exitprocess how it gonna load the lib?
Title: Re: InitCommonControls Q
Post by: Petroizki on December 11, 2005, 12:52:02 PM
Quote from: G`HOST on December 11, 2005, 09:16:36 AM
Yes he (Iczlion in the tute) does mention that just include it anywhere in the code and  ofcource it is used to load comctl32.dll,but if the compiler doesnt read anything after the exitprocess how it gonna load the lib?
Why wouldn't it read it? ExitProcess is just a function call, of course compiler reads everything following it. Sure the function is not called during execution, but it's still included in the import table, and the dll get's loaded during the startup.
Title: Re: InitCommonControls Q
Post by: G`HOST on December 11, 2005, 01:55:22 PM
 :toothy thanx for correcting me there. :U