Tried searching but everything seems to be for VB C++. Is this even possible in dev c++ if so please tell me how to do it
power_computer
20
Junior Poster
Recommended Answers
Jump to PostAfter a little testing I don't think its possible to prevent someone from closing the console window. I tried the code below with vc++ 2008 Express, but it doesn't work because SetWindowLong() returns 0 and the windows error message is "Access is denied". I assume its a permission thing.
Jump to PostThis deactivates the close option. Remember that you'll have to catch ctrl-C too.
#define _WIN32_WINNT 0x0500 #include <windows.h> int main() { HWND hwnd = GetConsoleWindow(); HMENU hmenu = GetSystemMenu (hwnd, FALSE); HINSTANCE hinstance = (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE); while (DeleteMenu (hmenu, 0, MF_BYPOSITION)) ; system ("pause"); }
All 7 Replies
ArkM
1,090
Postaholic
power_computer
20
Junior Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
power_computer
20
Junior Poster
nucleon
114
Posting Pro in Training
Ancient Dragon
commented:
Very Good :) :)
+36
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
nucleon
114
Posting Pro in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.