Questions tagged [hinstance]

HINSTANCE is a name given to a Handler instance in Window application

HINSTANCE is a name given to a Handler instance in Window application

18 questions
69
votes
4 answers

Determine the current HINSTANCE?

The HINSTANCE of a win32 application is passed to WinMain, but is there any other way of determining the current HINSTANCE (in case you couldn't tell, I'm very new to win32 programming!)? I need to create a window inside of a library and (since the…
dicroce
  • 45,396
  • 28
  • 101
  • 140
15
votes
5 answers

Forward declare HINSTANCE and friends

Is there a way to forward-declare the HINSTANCE type from the WinAPI without including the full (and big) windows.h header? For example, if I have a class RenderWindow which owns an HINSTANCE mInstance, i will have to include windows.h in…
abenthy
  • 883
  • 1
  • 8
  • 23
15
votes
1 answer

What is the purpose of hPrevInstance in WinMain

The definition of WinMain is: int CALLBACK WinMain( _In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow ); What I understand is: hInstance is a handle to the application's…
ApprenticeHacker
  • 21,351
  • 27
  • 103
  • 153
4
votes
2 answers

Self-Extracting Executable C++

I am trying to understand how self-extracting PE files work. Can somebody explain why my code isn't working, or fix the main() part. #include #include using namespace std; void ExtractResource(const HINSTANCE hInstance, WORD…
user2404495
  • 195
  • 1
  • 6
  • 17
2
votes
0 answers

Getting the HINSTANCE from HWND

GetWindowLong (GetTopWindow(NULL),GWL_HINSTANCE) returns 0 ... (Also tried with GetWindowLongPtr) Does anyone have an idea why is that? Also how do you convert LONG to HINSTANCE? GetTopWindow(NULL) does not return null EDIT: The check is for a…
Raedok
  • 51
  • 1
  • 7
2
votes
0 answers

rewrite a Win32 app using HINSTANCE to a Win32 console application

I have a win32 app that uses HINSTANCE. Here is the main.cpp: #include "stdafx.h" #include "testlib.c" int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int …
2
votes
1 answer

displaying a message when the user taps a key

The following snippet is meant to display the message when the user types a key. Even when the focus is not on the application. But there seems to be a problem with the following code. It doesn't call the function registered in the hook-chain with…
program-o-steve
  • 2,630
  • 15
  • 48
  • 67
1
vote
2 answers

How to terminate an application using the HINSTANCE

I am spawning an application from c++ with ShellExecute, so I have the HINSTANCE of the app. How can I close it now using that HINSTANCE? And can I use WaitForSingleObject() to wait for the app to finish?
riviraz
  • 479
  • 1
  • 10
  • 22
1
vote
1 answer

Passing an HINSTANCE to WNDCLASS using the main entry point

Consider the following code: #include LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) { MSG msg; HWND hwnd; …
Xantium
  • 11,201
  • 10
  • 62
  • 89
1
vote
2 answers

Are win32 hInstances unique?

I’m writing a cache handler that needs a unique ID number for every instance of the application, so that when someone has two projects open in two instances, the caches don’t get confused. According to this thread, it appears the HINSTANCE passed to…
TheTrueJard
  • 471
  • 4
  • 18
1
vote
0 answers

using a callback function from a 3rd party api in your own class that is a dll

I am trying to write a class in a dll that uses a callback function from another dll. currently i can get the callback to work when i am calling it in a main function but i am having problems integrating it in my own dll. I am using Hinstance in…
1
vote
1 answer

Cannot release Device Context, HWND, and cannot unregister Windows Class(OpenGL) -

I am following the http://nehe.gamedev.net/tutorial/creating_an_opengl_window_(win32)/13001/ OpenGL tutorial, and I got the code from that working. Now, I am trying to organise things by using multiple classes. As I was creating this class, I became…
Xcox123
  • 25
  • 4
1
vote
1 answer

C3767: candidate function(s) not accesible

I have this class: #pragma once #ifndef _DEFINES_H_ #include "Defines.h" #endif #ifndef _GAMETIME_H_ #include "GameTime.h" #endif #ifndef _UTILITIES_H_ #include "Utilities.h" #endif #ifndef _GAME_H_ using namespace System; namespace…
ThomasSquall
  • 644
  • 6
  • 21
0
votes
0 answers

mingw g++ Windows Subsystem WinMain not getting hInstance value

I'm converting a VS2015 C++ directx/winforms app to VS code using mingw G++ (both on windows 10). I have it compiling and linking after adding the -mwindows option (and a whole bunch of libraries) but upon stepping into the WinMain there is no value…
Walter ZAMBOTTI
  • 301
  • 1
  • 2
  • 10
0
votes
1 answer

Weird header can't be included in both main.cpp and window.cpp (a class)

I have to create a static-linking standalone .exe file from my .cpp and .h files. The only obstacle I need to overcome is being able to call the same function m_pListAll()from two .cpp files, main.cpp and window.cpp (defining a class called…
JoseOrtiz3
  • 1,785
  • 17
  • 28
1
2