HINSTANCE 
Author Message
 HINSTANCE

How do we get instance of an application in non MFC
application? Any help is appreciated!

TIA
NB



Mon, 28 Feb 2005 04:29:57 GMT  
 HINSTANCE
It's passed as a parameter to WinMain
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> How do we get instance of an application in non MFC
> application? Any help is appreciated!

> TIA
> NB



Mon, 28 Feb 2005 04:38:54 GMT  
 HINSTANCE


Quote:
> It's passed as a parameter to WinMain
> --
> With best wishes,
>     Igor Tandetnik

You can also get it from an HWND belonging to the app (a sometimes useful
trick):

HINSTANCE hInst = (HINSTANCE)::GetWindowLong(hWnd, GWL_HINSTANCE);

Jay



Mon, 28 Feb 2005 04:43:22 GMT  
 HINSTANCE
Before you can do that, you must already have it - CreateWindow expects
HINSTANCE as a parameter.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:



> > It's passed as a parameter to WinMain
> > --
> > With best wishes,
> >     Igor Tandetnik

> You can also get it from an HWND belonging to the app (a sometimes
useful
> trick):

> HINSTANCE hInst = (HINSTANCE)::GetWindowLong(hWnd, GWL_HINSTANCE);

> Jay



Mon, 28 Feb 2005 04:52:22 GMT  
 HINSTANCE


Quote:
> Before you can do that, you must already have it - CreateWindow expects
> HINSTANCE as a parameter.
> --
> With best wishes,
>     Igor Tandetnik

I know, I know. :). I've just found it useful within WNDPROCs, when I need
to create some resource or something with the hInstance, but I'm fairly far
away from WinMain, and I'm none too happy with global variables. Once the
window is created, it can serve as a reference for the HINSTANCE...

Jay



Mon, 28 Feb 2005 04:55:59 GMT  
 HINSTANCE
Thanks guyz,

But I am trying to create window in a DLL. So I do not
have WinMain functoin in it.

NB

:learning mode Question

Quote:
>-----Original Message-----
>Before you can do that, you must already have it -

CreateWindow expects
Quote:
>HINSTANCE as a parameter.
>--
>With best wishes,
>    Igor Tandetnik

>"For every complex problem, there is a solution that is
simple, neat,
>and wrong." H.L. Mencken





>> > It's passed as a parameter to WinMain
>> > --
>> > With best wishes,
>> >     Igor Tandetnik

>> You can also get it from an HWND belonging to the app
(a sometimes
>useful
>> trick):

>> HINSTANCE hInst = (HINSTANCE)::GetWindowLong(hWnd,
GWL_HINSTANCE);

>> Jay

>.



Mon, 28 Feb 2005 04:59:42 GMT  
 HINSTANCE
You have DllMain then.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> Thanks guyz,

> But I am trying to create window in a DLL. So I do not
> have WinMain functoin in it.

> NB

> :learning mode Question

> >-----Original Message-----
> >Before you can do that, you must already have it -
> CreateWindow expects
> >HINSTANCE as a parameter.
> >--
> >With best wishes,
> >    Igor Tandetnik

> >"For every complex problem, there is a solution that is
> simple, neat,
> >and wrong." H.L. Mencken





> >> > It's passed as a parameter to WinMain
> >> > --
> >> > With best wishes,
> >> >     Igor Tandetnik

> >> You can also get it from an HWND belonging to the app
> (a sometimes
> >useful
> >> trick):

> >> HINSTANCE hInst = (HINSTANCE)::GetWindowLong(hWnd,
> GWL_HINSTANCE);

> >> Jay

> >.



Mon, 28 Feb 2005 05:04:44 GMT  
 HINSTANCE
-Igor

I think I made a big jump in learning :) this is ATL COM
component. I could not find that function too.

NB

Quote:
>-----Original Message-----
>You have DllMain then.
>--
>With best wishes,
>    Igor Tandetnik

>"For every complex problem, there is a solution that is
simple, neat,
>and wrong." H.L. Mencken



>> Thanks guyz,

>> But I am trying to create window in a DLL. So I do not
>> have WinMain functoin in it.

>> NB

>> :learning mode Question

>> >-----Original Message-----
>> >Before you can do that, you must already have it -
>> CreateWindow expects
>> >HINSTANCE as a parameter.
>> >--
>> >With best wishes,
>> >    Igor Tandetnik

>> >"For every complex problem, there is a solution that is
>> simple, neat,
>> >and wrong." H.L. Mencken




message

>> >> > It's passed as a parameter to WinMain
>> >> > --
>> >> > With best wishes,
>> >> >     Igor Tandetnik

>> >> You can also get it from an HWND belonging to the app
>> (a sometimes
>> >useful
>> >> trick):

>> >> HINSTANCE hInst = (HINSTANCE)::GetWindowLong(hWnd,
>> GWL_HINSTANCE);

>> >> Jay

>> >.

>.



Mon, 28 Feb 2005 05:18:07 GMT  
 HINSTANCE


Quote:
> -Igor

> I think I made a big jump in learning :) this is ATL COM
> component. I could not find that function too.

Not sure if mine is the same as yours (mine has a DllMain *and* it uses
ATL), but it has a global object called _Module of type CComModule (extern'd
in stdafx.h). This object has the module instance handle.

HTH

Jay



Mon, 28 Feb 2005 05:24:13 GMT  
 HINSTANCE
I' trying to create window using CreateWindow. Which
require instance of the application. But this is DLL and I
really don't have any idea  how would that be retrived.
NB
Quote:
>-----Original Message-----
>You have DllMain then.
>--
>With best wishes,
>    Igor Tandetnik

>"For every complex problem, there is a solution that is
simple, neat,
>and wrong." H.L. Mencken



>> Thanks guyz,

>> But I am trying to create window in a DLL. So I do not
>> have WinMain functoin in it.

>> NB

>> :learning mode Question

>> >-----Original Message-----
>> >Before you can do that, you must already have it -
>> CreateWindow expects
>> >HINSTANCE as a parameter.
>> >--
>> >With best wishes,
>> >    Igor Tandetnik

>> >"For every complex problem, there is a solution that is
>> simple, neat,
>> >and wrong." H.L. Mencken




message

>> >> > It's passed as a parameter to WinMain
>> >> > --
>> >> > With best wishes,
>> >> >     Igor Tandetnik

>> >> You can also get it from an HWND belonging to the app
>> (a sometimes
>> >useful
>> >> trick):

>> >> HINSTANCE hInst = (HINSTANCE)::GetWindowLong(hWnd,
>> GWL_HINSTANCE);

>> >> Jay

>> >.

>.



Mon, 28 Feb 2005 05:24:12 GMT  
 HINSTANCE
-Jay

Yes I do have _Module.I think I can do
   _Module.m_hInst

Is this correct instance or do I need to call
   _Module.GetModuleInstance()

Thanks
NB

Quote:
>-----Original Message-----



>> -Igor

>> I think I made a big jump in learning :) this is ATL COM
>> component. I could not find that function too.

>Not sure if mine is the same as yours (mine has a DllMain
*and* it uses
>ATL), but it has a global object called _Module of type

CComModule (extern'd
Quote:
>in stdafx.h). This object has the module instance handle.

>HTH

>Jay

>.



Mon, 28 Feb 2005 05:34:37 GMT  
 HINSTANCE


Quote:
> -Jay

> Yes I do have _Module.I think I can do
>    _Module.m_hInst

> Is this correct instance or do I need to call
>    _Module.GetModuleInstance()

I would use the latter (the wrapper function).

Jay



Mon, 28 Feb 2005 05:40:56 GMT  
 HINSTANCE
I'd use _Module.GetModuleInstance(). In current implementation, it
simply returns m_hInst.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> -Jay

> Yes I do have _Module.I think I can do
>    _Module.m_hInst

> Is this correct instance or do I need to call
>    _Module.GetModuleInstance()

> Thanks
> NB
> >-----Original Message-----



> >> -Igor

> >> I think I made a big jump in learning :) this is ATL COM
> >> component. I could not find that function too.

> >Not sure if mine is the same as yours (mine has a DllMain
> *and* it uses
> >ATL), but it has a global object called _Module of type
> CComModule (extern'd
> >in stdafx.h). This object has the module instance handle.

> >HTH

> >Jay

> >.



Mon, 28 Feb 2005 05:54:59 GMT  
 HINSTANCE
hinst=GetModuleHandle(NULL);


Quote:
> How do we get instance of an application in non MFC
> application? Any help is appreciated!

> TIA
> NB



Mon, 28 Feb 2005 23:01:12 GMT  
 HINSTANCE
Thank you very much Igor and Jay.
It is appreciated.
NB

Quote:
>-----Original Message-----
>I'd use _Module.GetModuleInstance(). In current
implementation, it
>simply returns m_hInst.
>--
>With best wishes,
>    Igor Tandetnik

>"For every complex problem, there is a solution that is
simple, neat,
>and wrong." H.L. Mencken



>> -Jay

>> Yes I do have _Module.I think I can do
>>    _Module.m_hInst

>> Is this correct instance or do I need to call
>>    _Module.GetModuleInstance()

>> Thanks
>> NB
>> >-----Original Message-----



>> >> -Igor

>> >> I think I made a big jump in learning :) this is ATL
COM
>> >> component. I could not find that function too.

>> >Not sure if mine is the same as yours (mine has a
DllMain
>> *and* it uses
>> >ATL), but it has a global object called _Module of type
>> CComModule (extern'd
>> >in stdafx.h). This object has the module instance
handle.

>> >HTH

>> >Jay

>> >.

>.



Tue, 01 Mar 2005 01:51:50 GMT  
 
 [ 16 post ]  Go to page: [1] [2]

 Relevant Pages 

1. How to see the real values of the HWND, HINSTANCE etc when debugging

2. how to get HINSTANCE of a DLL

3. hInstance and hWnd

4. Need parent handle (hWnd) from hInstance in DLL

5. How to get the HINSTANCE of a dll?

6. Getting HINSTANCE in a DLL using ATL in VC++7.0

7. HINSTANCE Problem in IDL file

8. HINSTANCE and HWND

9. HINSTANCE for LoadIcon in ATL OCX

10. 'Where is hInstance?' or thereabouts

11. WinMain(HINSTANCE hangup?

12. nCmdShow and hInstance parameters in WinMain???

 

 
Powered by phpBB® Forum Software