I need to know a way to open a notepad document from one of my programs without opening a console window. The calling program is a standard window, so it would look bad if a console widow opened. There are a couple of things you should be aware of as well. I have already tried system("call ..."), which opens the console, and also, I can't include windows.h due to conflicting class names. Please help.
waldchr
-2
Junior Poster in Training
Recommended Answers
Jump to PostSo add a new source file to your project called runner.cpp
All this does, is
- include windows.h
- implements a thin wrapper, say myRunner() round say CreateProcess()
- and returnsrunner.h just contains the prototype of myRunner(), which in itself is NOT dependent on windows.h
Include …
Jump to PostWrite and compile it as a Windows program (without a window), you could use the
fstream
classes for file I/O :)
Jump to PostPlace this function into the separate .cpp file:
void ShowText(const char* filename) { ::ShellExecuteA(::GetDesktopWindow(), "open", "notepad.exe", filename, 0, SW_SHOWNORMAL); }
Include <windows.h> dependency into this file only.
This function works in console applications too.
All 10 Replies
Salem
5,138
Posting Sage
mvmalderen
2,072
Postaholic
waldchr
-2
Junior Poster in Training
mvmalderen
2,072
Postaholic
mvmalderen
2,072
Postaholic
Salem
5,138
Posting Sage
waldchr
-2
Junior Poster in Training
Salem
5,138
Posting Sage
ArkM
1,090
Postaholic
mvmalderen
commented:
Good job!
+5
waldchr
-2
Junior Poster 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.