How can I declare a global variable to be used by all the classes in a VC++ project? I added the variable (HANDLE processHandle) in the .h file of the main function, but apparently this cannot be seen other classes in the app.
You need to declare it in a .cpp first, like so:
HANDLE hProc = NULL; //(or whatever).
Then you must either extern it in all the .cpp's that use it or (and this is my preference) extern it in a header file that's included in every .cpp (like for instance stdafx.h) like so: extern HANDLE hProc;
Greetings,
Rick
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.