News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

InitCommonControls Q

Started by DC, December 10, 2005, 06:58:24 PM

Previous topic - Next topic

DC

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
this isn't daja vu, I'm just learning it for the 37th time
http://www.bmath.net

DC

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
this isn't daja vu, I'm just learning it for the 37th time
http://www.bmath.net

comrade

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.

DC

thanx a bunch, I almost left it out since it seems to work without it.
this isn't daja vu, I'm just learning it for the 37th time
http://www.bmath.net

G`HOST

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 ?

Petroizki

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.

G`HOST

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?

Petroizki

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.

G`HOST

 :toothy thanx for correcting me there. :U